マイクのオフロード操作を含む「test.c」という名前の C ファイルを作成します。次に、コマンド「icc -S test.c」を使用してアセンブリ ファイルにコンパイルします。これにより、「test.s」および「testMIC.s」という名前の 2 つのアセンブリ ファイルが作成されました。それらを実行可能ファイルにコンパイルし続けると、次のようなエラーが発生します。
コマンド「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_leave への未定義参照__offload_target_enter' test.c:(.text+0x111): undefined reference to
' /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: 関数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' /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' への未定義の参照
この問題を解決するのに役立つ人はいますか?
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;
}