PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

cufft using pgi compiler

Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message

Joined: 23 Jul 2010
Posts: 1

PostPosted: Tue Jul 27, 2010 8:04 am    Post subject: cufft using pgi compiler Reply with quote

Can I call cufft using pgi compiler?

My code is:

#include <stdio.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cufft.h>

#define NX 1200
#define NY 1200

int main(int argc, char *argv[])
cufftHandle plan;
cufftComplex *devPtr;
cufftComplex data[NX*NY];
int i;
struct timeval t1,t2,t3,t4;
long c_fft,c_all;

/* source data creation */
for(i= 0 ; i < NX*NY ; i++){
data[i].x = 1.0f;
data[i].y = 1.0f;


/* GPU memory allocation */
cudaMalloc((void**)&devPtr, sizeof(cufftComplex)*NX*NY);

/* transfer to GPU memory */
cudaMemcpy(devPtr, data, sizeof(cufftComplex)*NX*NY, cudaMemcpyHostToDevice);


/* creates 2D FFT plan */
cufftPlan2d(&plan, NX, NY, CUFFT_C2C);

/* executes FFT processes */
cufftExecC2C(plan, devPtr, devPtr, CUFFT_FORWARD);

/* executes FFT processes (inverse transformation) */
cufftExecC2C(plan, devPtr, devPtr, CUFFT_INVERSE);


/* transfer results from GPU memory */
cudaMemcpy(data, devPtr, sizeof(cufftComplex)*NX*NY, cudaMemcpyDeviceToHost);

/* deletes CUFFT plan */

/* frees GPU memory */


printf("%13ld microseconds for fft\n",c_fft);
printf("%13ld microseconds for all\n",c_all);

/* for(i = 0 ; i < NX*NY ; i++){
printf("data[%d] %f %f\n", i, data[i].x, data[i].y);

return 0;

I compiled with "pgcc -I /opt/pgi/linux86-64/10.2/cuda/include/ -L /usr/local/cuda/lib/ fft2d.c -lcufft" and got the error message like this:
PGC-F-0249-#error -- --- !!! UNSUPPORTED COMPILER !!! --- (/opt/pgi/linux86-64/10.2/cuda/include/host_defines.h: 41)
PGC/x86-64 Linux 10.2-0: compilation aborted

This code works with "gcc -I /usr/local/cuda/include/ -L /usr/local/cuda/lib/ fft2d.c -lcufft"

Could anyone suggest what I can do to solve fft using the pgi compiler?

Thank you.
Back to top
View user's profile

Joined: 30 Jun 2004
Posts: 6741
Location: The Portland Group Inc.

PostPosted: Tue Jul 27, 2010 3:20 pm    Post subject: Reply with quote

Hi nutty,

While we have the rights to redistribute NVIDIA's CUDA header files, we don't have the right to modify them. Hence, we aren't allowed to remove the "#if !defined(__GNUC__)" guard nor port the headers to work around the GNU specific C constructs.

It's possible that this will change in the future, for now you'll need to use gcc or nvcc to compile this code.

Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © phpBB Group