Offload mode and configure script.

Offload mode and configure script.


I am currently working on a C code, trying to make use of the offload mode. The code uses a configure script that creates a static library, which is used by a file containing '#pragma offload' as well. When I simply try to configure and build (I'm using export CC="icc -openmp") I get an error "undefined reference to '__offload_target_acquire'" and '__offload_offload'. I've tried using xiar, but that doesn't change anything.

I have also tried to link dynamically to as a last resort. The build is successful, but then I receive an error: "cannot find offload entry __offload_entry_..." when trying to run the executable.

I would like to know what is the process when dealing with configure scripts and offload mode. Are there any compiler flags that can be used to resolve the problem with libraries, or is the error lying on the configure script side and it has to be modified or rewritten? 

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

What happens if you just add "-offload-attribute-target=mic" to the compiler options for the files that are used to build the library? I believe that should do it (unless for some reason not all the routines in the library can be compiled with the offload attribute - e.g. they contain #pragma offload directives themselves.)


There are no errors during the building with added "-offload-attribute-target=mic". However, I again get "offload error: cannot find offload entry __offload_entry_..." when trying to run the executable.

I have the same problem, i.e., I get the same link error that goes away when I use -ffload-attribute-target=mic but results in a runtime error along the lines of

offload error: cannot find offload entry __offload_entry__<mangled function name>

Any clues?

When building the final executable, try adding the following option to the final link step: -offload-option,mic,ld,"--no-undefined"

That may help expose the routine that is missing the needed offload attribute decoration.

This User guide section may help when building static archives if that applies to your case: About Creating Offload Libraries with xiar and xild

The __offload_entry_<mangled_function_name> is a mangled name generated for each entry point to offloaded code. The entry points should have been automatically generated and stored in the library when it was compiled with the Intel compilers and the "-offload-attribute-target=mic" option. In looking at this issue again, I see two possibilities: 1) the name was not generated by the compiler or 2) the name was truncated when the library was created.

If the name was not generated by the compiler, the most likely cause is that the compiler was not told to generate the offload version of the routine. But the "-offload-attribute-target=mic" should have taken care of that. If people want to revisit the issue, they could try putting the offload target directives directly in the source code and include files and see what happens.

The more likely cause is that ar and xiar are set to truncate names if they get too long. This truncation is configurable and the solution in this case would be to turn off truncation.

Leave a Comment

Please sign in to add a comment. Not a member? Join today