0

我编写了一个名为“test.c”的 C 文件,其中包含对 mic 的卸载操作。然后我使用命令“icc -S test.c”将它编译成汇编文件。这产生了两个名为“test.s”和“testMIC.s”的汇编文件。当我继续将它们编译为可执行文件时,出现如下错误。

  1. 使用逗号“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'

  2. 使用逗号“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'

  3. 使用逗号“icc test.s testMIC.s”

    /tmp/iccEOtVAs.o: 在函数foo': test.c:(.text+0x170): multiple definition offoo' /tmp/icczmGFBD.o:test.c:(.text+0x170): 首先定义在这里 /tmp/iccEOtVAs.o: 在函数main': test.c:(.text+0x128): multiple definition ofmain' /tmp/icczmGFBD.o: test.c:(.text+0x0): 首先在这里定义 /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 ): 未定义引用__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 functionmain': 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;
}
4

1 回答 1

0

使用命令生成两个汇编文件 test.s 和 testMIC.s 后

% icc -S 测试.c

您应该能够使用以下命令生成可执行文件 a.out

% icc 测试.s

编译器检测到 test.s 有卸载代码,因此它搜索 testMIC.s 并链接它们以生成可以从主机运行的可执行文件 a.out。

但是,发出“icc testMIC.s”或“icc test.s testMIC.s”都是不正确的

于 2014-02-28T21:46:22.710 回答