2014-02-27 22 views
0

我寫了一個名爲「test.c」的C文件,其中包含麥克風的卸載操作。然後使用命令「icc -S test.c」將它編譯成彙編文件。這產生了兩個名爲「test.s」和「testMIC.s」的彙編文件。當我繼續將它們編譯爲可執行文件時,出現如下錯誤。如何編譯包含卸載到麥克風的彙編文件

  1. 使用commad 「ICC test.s」

    /tmp/iccG8ZTVA.o:在功能main': test.c:(.text+0x30): undefined reference to __kmpc_begin' test.c的:(文本+ 0x6f):未定義參照__offload_target_acquire' test.c:(.text+0x11f): undefined reference to __offload_offload」 test.c的:(文本+ 0x15b):未定義參考`__kmpc_end」

  2. 使用commad 「ICC testMIC.s」

    /tmp/icc7qv8qX.o:在功能__offload_entry_test_c_10main': test.c:(.text+0x1d): undefined reference to __intel_ne w_proc_init_R ' test.c的:(文本+ 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. 使用commad 「ICC test.s testMIC.s」

    /tmp/iccEOtVAs.o:在功能foo': test.c:(.text+0x170): multiple definition of富」 /tmp/icczmGFBD.o:test.c:(.text+0x170):第一這裏定義 /tmp/iccEOtVAs.o:在功能main': test.c:(.text+0x128): multiple definition of主 /tmp/icczmGFBD.o:test.c:(.text+0x0):首先在這裏定義 /tmp/icczmGFBD.o:在函數main': test.c:(.text+0x30): undefined reference to __kmpc_begin' (.text + 0x15b):未定義的引用__kmpc_end' /tmp/iccEOtVAs.o: In function __offload_entry_test_c_10main': test.c :(。text + 0x1d):undefined參考__intel_new_proc_init_R' test.c:(.text+0xd5): undefined reference to __offload_target_enter」。 test.c的:(文字+ 0x111):未定義的引用__offload_target_leave' /tmp/iccEOtVAs.o: In function主 ': test.c的:(文字+ 0x140):未定義的引用`__intel_new_proc_init_R'

是有沒有人可以幫我解決這個問題?

有test1.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; 
} 
+2

的assemblyfile不編譯它組裝。所以你必須調用匯編器而不是編譯器。 – Devolus

+0

您需要包含您用於鏈接器的庫。 – m0skit0

+0

嘗試添加-openmp選項:icc -openmp test.s –

回答

0

使用命令生成兩個組裝文件test.s和testMIC.s後

%ICC -S test.c的

你應該能夠使用以下命令生成可執行文件a.out

%icc test.s

編譯器檢測到test.s已卸載代碼,因此它會搜索testMIC.s並將其鏈接到生成可從主機運行的可執行文件a.out。

然而,這是不正確頒發的「國際刑事法院testMIC.s」,也不是「國際刑事法院test.s testMIC.s」