I write a C file named "test.c", which contains offload operation on mic. Then I compile it to assembly file using the command "icc -S test.c". This produced two assembly files named "test.s" and "testMIC.s". When I continue to compile them to executable file, there are errors as follows.
use commad "icc test.s"
/tmp/iccG8ZTVA.o: In function
main': test.c:(.text+0x30): undefined reference to
__kmpc_begin' test.c:(.text+0x6f): undefined reference to__offload_target_acquire' test.c:(.text+0x11f): undefined reference to
__offload_offload' test.c:(.text+0x15b): undefined reference to `__kmpc_end'use commad "icc testMIC.s"
/tmp/icc7qv8qX.o: In function
__offload_entry_test_c_10main': test.c:(.text+0x1d): undefined reference to
__intel_new_proc_init_R' test.c:(.text+0xd5): undefined reference to__offload_target_enter' test.c:(.text+0x111): undefined reference to
__offload_target_leave' /tmp/icc7qv8qX.o: In functionmain': test.c:(.text+0x140): undefined reference to
__intel_new_proc_init_R'use commad "icc test.s testMIC.s"
/tmp/iccEOtVAs.o: In function
foo': test.c:(.text+0x170): multiple definition of
foo' /tmp/icczmGFBD.o:test.c:(.text+0x170): first defined here /tmp/iccEOtVAs.o: In functionmain': test.c:(.text+0x128): multiple definition of
main' /tmp/icczmGFBD.o:test.c:(.text+0x0): first defined here /tmp/icczmGFBD.o: In functionmain': test.c:(.text+0x30): undefined reference to
__kmpc_begin' test.c:(.text+0x6f): undefined reference to__offload_target_acquire' test.c:(.text+0x11f): undefined reference to
__offload_offload' test.c:(.text+0x15b): undefined reference to__kmpc_end' /tmp/iccEOtVAs.o: In function
__offload_entry_test_c_10main': test.c:(.text+0x1d): undefined reference to__intel_new_proc_init_R' test.c:(.text+0xd5): undefined reference to
__offload_target_enter' test.c:(.text+0x111): undefined reference to__offload_target_leave' /tmp/iccEOtVAs.o: In function
main': test.c:(.text+0x140): undefined reference to `__intel_new_proc_init_R'
Is there any one can help me solve this problem?
the test.c:
__attribute__((target(mic)))
int foo(int a, int b){
return a+b;
}
int main()
{
int c = 0;
int a=1, b=2;
#pragma offload target (mic)
{
c = foo(a, b);
}
printf("c: %d\n", c);
return 0;
}