我编写了一个名为“test.c”的 C 文件,其中包含对 mic 的卸载操作。然后我使用命令“icc -S test.c”将它编译成汇编文件。这产生了两个名为“test.s”和“testMIC.s”的汇编文件。当我继续将它们编译为可执行文件时,出现如下错误。
使用逗号“icc test.s”
/tmp/iccG8ZTVA.o: 在函数
main': test.c:(.text+0x30): undefined reference to
__kmpc_begin' test.c:(.text+0x6f): 未定义引用__offload_target_acquire' test.c:(.text+0x11f): undefined reference to
__offload_offload' test.c:(.text+0x15b): 未定义引用 `__kmpc_end'使用逗号“icc testMIC.s”
/tmp/icc7qv8qX.o: 在函数
__offload_entry_test_c_10main': test.c:(.text+0x1d): undefined reference to
__intel_new_proc_init_R' test.c:(.text+0xd5): 未定义引用__offload_target_enter' test.c:(.text+0x111): undefined reference to
__offload_target_leave' /tmp/icc7qv8qX.o: 在函数main': test.c:(.text+0x140): undefined reference to
__intel_new_proc_init_R'使用逗号“icc test.s testMIC.s”
/tmp/iccEOtVAs.o: 在函数
foo': test.c:(.text+0x170): multiple definition of
foo' /tmp/icczmGFBD.o:test.c:(.text+0x170): 首先定义在这里 /tmp/iccEOtVAs.o: 在函数main': test.c:(.text+0x128): multiple definition of
main' /tmp/icczmGFBD.o: test.c:(.text+0x0): 首先在这里定义 /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 ): 未定义引用__kmpc_end' /tmp/iccEOtVAs.o: In function
__offload_entry_test_c_10main': test.c:(.text+0x1d): 未定义引用__intel_new_proc_init_R' test.c:(.text+0xd5): undefined reference to
__offload_target_enter' test.c:(.text+0x111): 未定义引用__offload_target_leave' /tmp/iccEOtVAs.o: In function
main': test.c:(.text+0x140 ): 对 `__intel_new_proc_init_R' 的未定义引用
有没有人可以帮我解决这个问题?
测试.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;
}