Sin and cos in parallel for loop

Hello PGI community,

I would need your help.

I wrote a code called SFT.cpp to calculate the spatial Fourier transform of an electric field.

I used the code many times on a platform with IBM Power 822LC “Minsky” Servers and NVIDIA Tesla P100 GPUs.
I compiled using gcc/7.2.1, pgi/17.4 and the command:
pgc++ -acc -ta=tesla:cc60 -Minfo=accel -O4 -fastsse -o SFT.exe SFT.cpp

Now, I’m trying to use the code on a new platform containing Intel E5 and Intel Xeon nodes with NVIDIA P100 Pascal and NVIDIA V100 Volta GPUs.
I’m compiling using gcc/8.3.0, pgi/19.4 and the command:
pgc++ -fast -Minfo=accel -ta=tesla:managed -o SFT.exe SFT.cpp

The piece originating the problem is a nested for loop with

#pragma acc parallel 
#pragma acc loop gang

The most internal loop contains sin and cos functions, which seem responsible for the errors. If I remove those functions the code compiles successfully.

These are the errors:
PGCC-S-0155-Procedures called in a compute region must have acc routine information: cos (SFT.cpp: 309)
PGCC-S-0155-Accelerator region ignored; see -Minfo messages (SFT.cpp: 282)
main:
282, Accelerator region ignored
309, Accelerator restriction: call to ‘cos’ with no acc routine information
PGCC/x86-64 Linux 19.4-0: compilation completed with severe errors

Any idea on how to solve this issue?

Thanks a lot.
Cheers,

Hi antocl,

Try adding the following at the top of the file:

#ifdef _OPENACC
#include <accelmath.h>
#endif

This will pull in the device versions of sin and cos that you can use in an OpenACC compute region.

Hope this helps,
Mat

Thanks a lot, that worked!