Software Archive
Read-only legacy content
17060 Discussions

Creating Windows DLLs containing MIC offload code

Vladimir_S_
Beginner
606 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 (and I see that in my output directory a file called <dll-name>MIC.out has also been created). The DLL is consumed from an executable that dynamically loads the library at runtime, looks up the necessary API, and calls it. The problem is that I get the following error when I run the application:

offload error: cannot find offload entry ...

after which the process just exits (the behavior I would like to have some control over, but that is a separate question).

I can successfully run the offload samples (from the Intel C++ Composer's installation), but those are console applications and I am wondering if that has something to do with the problem. All compiler/linker switches are the same between the two (as far as I can assess).

Btw, I initially had the code that does MIC offload in a static library that the DLL was linking against (and I did see the <lib-name>MIC.a being created at compile time. I had the same issue when running the application.

Can anyone please advice me on what I am missing here?

Thank you.

0 Kudos
8 Replies
Kevin_D_Intel
Employee
606 Views

I'm sorry to hear about the problems using a DLL. I am not sure you are doing anything wrong. It is possible we have some outstanding issues with the mechanics associated with using a DLL. We are investigating some other related reports.

Is it your DLL that is reported in the error or one related to the compiler's run-time libraries?

I ask because in another case the user found it was currently necessary to set the MIC_LD_PRELOAD on the host to a list of dependent libraries (in that case MIC_LD_PRELOAD=/lib64/libifcore.so.5) and upload those libraries to the card also. In the absence of this, execution failed with the form of error you cited. I don't know whether that may help in your case also. We are still investigating this behavior.

If you by chance have a small reproducer then I'd be happy to investigate further and forward that to our Developers too.

0 Kudos
Vladimir_S_
Beginner
606 Views

The reported error is against a function in the DLL itself (the function's name in the error message is mingled, but there is a reference to the source file name, so I assume that is the case). The offload code (the one targeting MIC) does not have any explicit dependencies on external libraries. Also, for testing purposes, I replaced the real code with some basic loop and got the same behavior. I will try to put together and post a simple reproducer.

 

0 Kudos
Bernard
Valued Contributor I
606 Views

It seems that dll's entry point was not found , hence such a message.

0 Kudos
Bernard
Valued Contributor I
606 Views

So the Specific function entry point was not found and not dllmain()?

0 Kudos
Vladimir_S_
Beginner
606 Views

iliyapolak, I am not sure what to make out of your comment.

What seems to be not found is the piece of the offload code that was supposed to be compiled to run on MIC. So somehow that code is not present in the DLL. The MIC offload linker did not report any errors, but yet the code is not included, or somehow cannot be found by the offload infrastructure. So my hope was that it was due to a missing compiler or linker option, but based on Kevin's response, it may be something more severe.

As for the entry point in the DLL that the client application is calling, everything is fine there. 

0 Kudos
Bernard
Valued Contributor I
606 Views

Sorry for improper formulation of my answer I am using smartphone.Now regarding your problem If you think that offload MIC code is not present it is advised to check for presence of that code with dumpbin or other PE parsing/disassembling tool.

0 Kudos
Vladimir_S_
Beginner
606 Views

Kevin,

Here is the reproducer project (attached). It has a DLL and a console application that consumes it. All relevant code is in the dll.cpp and main.cpp files. I use Visual Studio 2012 (update 4), Intel C++ Composer XE 2013 SP1, and MPSS 3.1. You can compile and run the console application and observe the problem.

There are two offload calls in the example, one runs fine, and another fails with the offload error: cannot find offload entry.

It looks like the problem has to do with the failing function (that contains the offload code) having a parameter of a function pointer type. I also suspect it also has to do with the MIC compiler not understanding __stdcall specifier. At any rate the offload code should have nothing to do with the signature of the hosting routine.

Please advise if this is a bug in the compiler or if there is a syntactical error of some sort in the or code itself.

 Thank you.

 

0 Kudos
Vladimir_S_
Beginner
606 Views

It looks like there are two other cases when the 

offload error: cannot find offload entry ...

may occur:

1. When the function that initiates offload (or the offload routine itself) is defined inside a namespace.

2. When the DLL that contains Phi offload code also contains CUDA kernels (I am using CUDA Toolkit v. 5.5). 

Can someone comment on this?

Thank you.

0 Kudos
Reply