Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Creating Windows DLLs containing MIC offload code on VS2012

Linm_F_
Beginner
708 Views

Hello Everyone,

I am trying to build a Windows DLL that contains code that does offload to MIC. I managed to compile the DLL, but it failed (and I see that in my output directory a file called <dll-name>MIC.out has not been created). 

   Tools:  windows sever 2012R2 , visual studio 2012, Intel Parallel Studio 2015 .

    I create two projects: one is a DLL project inculding a function ,another is a main function which call the DLL.

    DLL project: (demodll)

 Export.h :         extern "C" __declspec(dllexport) double decode_process(int n);

 Export.cpp: 

__declspec(dllexport) double decode_process(int n)
{
    double sum = 0.0;
#pragma offload target(mic) inout(sum)
    {
        for (int i = 0; i < n;i++)
        for (int j = 0; j < n; j++)
            sum += i*j;
    }
    return sum;

}

Main function (Demo):

#include<iostream>
#include "../demodll/Export.h"

#pragma comment(lib,"demodll.lib")
using namespace std;
int main()
{

    cout<<decode_process(1000);

    return 0;
}

   When I Compile the demodll ,   errors occured.:

   5  error #10340:problem encountered when performing target compliation

   3 error #1292: *MIC* unknown attribute "dllexport"                      Export.cpp

    It means the Intel C++ compiler cannot  recognize the "dllexport"  on MIC , but if I comment out the words : #pragma offload target(mic) inout(sum), it succded

and the whole solution works correctly, which means the Intel compiler can recognize the "dllexport"  on CPU

    Can anyone please advice me on what I can do that the Intel  compiler recognize the "dllexport"  on MIC ?

Thank you.

0 Kudos
1 Reply
Plaza_del_Olmo__Juli
708 Views

I am basically having the same kind of problems, trying to build a DLL with offload code in VS2013.

It looks to me that the problem is that since MIC is linux-based, it does not recognize Windows specific stuff (dllexport, or in my case, it does not open source file "windows.h")

All I have found this notice

https://software.intel.com/en-us/articles/xeon-phi-coprocessor-fat-binary-for-windows-static-and-dynamic-link-library-with-offload

Saying that using older versions of Intel compiler , you need to handle .DLL and .so libraries separately.

Is there any tutorial or walkthrough to create a DLL using offload code? Or how to use .dll and .so libraries separately?

 

 

0 Kudos
Reply