Jeppe Druedahl
Jeppe Druedahl

Reputation: 21

Declare simd using exp from math.h on TDM-GCC 4.92

I need to vectorize a loop with a call to the exp-function in math.h. However, compiling a file with this

#include <math.h>
#include <omp.h>

#pragma omp declare simd
extern double __cdecl exp(double);

seems not to be possible, as I get the following error

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

I am using TDM-GCC 4.9.2 on a Windows 7 machine.

What is the problem? Any solutions?

Upvotes: 0

Views: 340

Answers (1)

mcleod_ideafix
mcleod_ideafix

Reputation: 11428

You need to add the math library to the list of libraries to link with:

gcc -O3 -fopenmp testSIMD.c -lm

Unlike other libraries, this is not added by default.

But I don't think it will help you. The #pragma omp declare simd applies to new function declarations, not existing library functions. You may need to write your own version of exp().

Upvotes: 0

Related Questions