1

I downloaded the example from https://www.olcf.ornl.gov/tutorials/mixing-openacc-with-gpu-libraries/ The codes are given in the above mwntioned links

1) using pgcc

pgc++ -c cuFFT.cu
pgcc -acc   -Mcudalib=cufft fft.c cufft.o
works perfectly fine

2) using pgc++

pgc++ -c cuFFT.cu
pgc++ -acc   -Mcudalib=cufft fft.cpp (or .c samefiles) cufft.o

I get the following error

    undefined reference to launchCUFFT(float*, int, void*)
     pgacclnk: child process exit status 1: /usr/bin/ld
JimBamFeng
  • 709
  • 1
  • 4
  • 20

1 Answers1

1

You're running into a C/C++ linking mismatch.

To get this to work in PGI 17.9 tools I had to:

  1. rename cuFFT.cu to cuFFT.cpp
  2. edit the malloc line in fft.c from:

    float *data = malloc(2*n*sizeof(float));
    

    to:

    float *data = (float *)malloc(2*n*sizeof(float));
    
  3. modify the declaration in fft.c from:

    extern void launchCUFFT(float *d_data, int n, void *stream);
    

    to:

    extern "C" void launchCUFFT(float *d_data, int n, void *stream);
    
  4. Issue the following compile commands:

    $ pgc++ -c cuFFT.cpp
    $ pgc++ -acc   -Mcudalib=cufft fft.c cuFFT.o
    
Robert Crovella
  • 143,785
  • 11
  • 213
  • 257