0

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 offoo' /tmp/icczmGFBD.o:test.c:(.text+0x170): first defined here /tmp/iccEOtVAs.o: In function main': test.c:(.text+0x128): multiple definition ofmain' /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 functionmain': 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;
}
Brad Werth
  • 371
  • 1
  • 10

1 Answers1

0

After generating two assembly files test.s and testMIC.s using the command

% icc -S test.c

You should be able to generate the executable a.out with the following command

% icc test.s

The compiler detects that test.s has offload code, so it searches for testMIC.s and link them to generate the executable a.out that you can run from host.

However, it is not correct to issue "icc testMIC.s" nor "icc test.s testMIC.s"