[英]Declare simd using exp from math.h on TDM-GCC 4.92
我需要使用math.h中的exp函數調用來向量化循環。 但是,用此編譯文件
#include <math.h>
#include <omp.h>
#pragma omp declare simd
extern double __cdecl exp(double);
似乎不可能,因為出現以下錯誤
D:\Dropbox\OpenMP>gcc -O3 -fopenmp testSIMD.c
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text+0x198): undefi
ned reference to `_ZGVcN4v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text+0x348): undefi
ned reference to `_ZGVdN4v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x26f)
: undefined reference to `_ZGVbN2v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x286)
: undefined reference to `_ZGVbN2v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x3af)
: undefined reference to `_ZGVbN2v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x3c6)
: undefined reference to `_ZGVbN2v_exp'
collect2.exe: error: ld returned 1 exit status
我在Windows 7計算機上使用TDM-GCC 4.9.2。
問題是什么? 有什么辦法嗎?
您需要將數學庫添加到庫列表中以進行鏈接:
gcc -O3 -fopenmp testSIMD.c -lm
與其他庫不同,默認情況下不添加此庫。
但我認為這不會幫助您。 #pragma omp declare simd
適用於新的函數聲明,不適用於現有的庫函數。 您可能需要編寫自己的exp()
版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.