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.
1. 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'
2. 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 function `main':
test.c:(.text+0x140): undefined reference to `__intel_new_proc_init_R'
3. 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 function `main':
test.c:(.text+0x128): multiple definition of `main'
/tmp/icczmGFBD.o:test.c:(.text+0x0): first defined here
/tmp/icczmGFBD.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'
/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:
1 __attribute__((target(mic)))
2 int foo(int a, int b){
3 return a+b;
4 }
5
6 int main()
7 {
8 int c=0;
9 int a=1, b=2;
10 #pragma offload target (mic)
11 {
12 c = foo(a, b);
13 }
14 printf("c: %d\n", c);
15 return 0;
16 }