在TDM-GCC 4.92上使用math.h中的exp声明simd

时间:2015-04-11 12:37:15

标签: gcc openmp tdm-mingw

我需要通过调用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。

有什么问题?任何解决方案?

1 个答案:

答案 0 :(得分:0)

您需要将数学库添加到要链接的库列表中:

gcc -O3 -fopenmp testSIMD.c -lm

与其他库不同,默认情况下不会添加。

但我认为它不会对你有所帮助。 #pragma omp declare simd适用于新函数声明,而不适用于现有库函数。您可能需要编写自己的exp()版本。