Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
17060 Discussions

undefined reference to `__offload_target_acquire' and `__offload_offload'

Chris_N_
Beginner
1,361 Views

The following program compiles fine and runs on the MIC:

#include <stdlib.h>
#include <stdio.h>
main() {
float micret=1.001;
int mici;
#pragma offload target (mic:0) inout(micret, mici)
for(mici=0;mici<=1000; mici++){
micret*=1.001;
}
fprintf(stderr,"FOUND %g\n",micret);
}

## output from the executable (subsequent to "export OFFLOAD_REPORT=2") is:

[Offload] [MIC 0] [File] prog.c
[Offload] [MIC 0] [Line] 9
[Offload] [MIC 0] [Tag] Tag0
[Offload] [MIC 0] [CPU Time] 0.000000 (seconds)
[Offload] [MIC 0] [CPU->MIC Data] 8 (bytes)
[Offload] [MIC 0] [MIC Time] 0.000100 (seconds)
[Offload] [MIC 0] [MIC->CPU Data] 8 (bytes)

FOUND 2.72235

However, when I try to add that code into the body of a function in a large executable, I get the following errors:

undefined reference to `__offload_target_acquire'
undefined reference to `__offload_offload'

While the small test program was compiled with icc directly, for the large program I am using cmake; make.

Can anybody suggest why I am getting these errors?

Thank you, Chris.

0 Kudos
6 Replies
Chris_N_
Beginner
1,361 Views

I should clarify that those errors were obtained during compilation and I was unable to obtain a working executable.

0 Kudos
Frances_R_Intel
Employee
1,361 Views

When you compiled your small test case, you ran the compilervars script. I'm not sure how your makefile is written, and I am certainly no expert on cmake, but you need to make sure the LD_LIBRARY_PATH and MIC_LD_LIBRARY_PATH variables are getting properly set. The routines you are missing in this case are in /opt/intel/composerxe/lib/intel64. 

0 Kudos
Chris_N_
Beginner
1,361 Views

Thank you very much Frances.

Turns out that I can avoid the errors and get it to compile when I omit the gromacs compilation cmake flag -DGMX_PREFER_STATIC_LIBS=ON

Without knowing exactly what that does in the gromacs cmake call, does it make sense that a mic offload doesn't work with static libraries? If not, then I guess that I should look into the routines that you mention.

Thank you,

Chris.

0 Kudos
Frances_R_Intel
Employee
1,361 Views

The libraries you need exist as .so but not as .a files. If I understand what I read when I searched for GMX_PREFER_STATIC_LIBS on the web, cmake should have gone ahead and used the .so files when it couldn't find any .a files. So I really don't know why it had trouble. Sorry.

0 Kudos
Chris_N_
Beginner
1,361 Views

Thank you Frances, this will be useful information once we get the offloading done and want to reenable the GMX_PREFER_STATIC_LIBS setting for use with CPU+MIC.

0 Kudos
Chris_N_
Beginner
1,361 Views

Thank you Frances, this will be useful information once we get the offloading done and want to reenable the GMX_PREFER_STATIC_LIBS setting for use with CPU+MIC.

0 Kudos
Reply