cufft: ERROR: CUFFT_INVALID_PLAN

Hi,

I got this error message when I try to do 1D Complex FFT larger then 2048 pts. The code is the following:

////////////////////////////////////////////////////////////////////////////////

// Test de FFT avec CUDA

////////////////////////////////////////////////////////////////////////////////

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <math.h>

/ includes, project

#include <cufft.h>

#include <cutil.h>

// Complex data type

typedef float2 Complex; 

////////////////////////////////////////////////////////////////////////////////

// declaration, forward

void runTest(int argc, char** argv);

#define ASCII_OUTPUT  0

#define SIGNAL_SIZE	4096

////////////////////////////////////////////////////////////////////////////////

// Program main

////////////////////////////////////////////////////////////////////////////////

int main(int argc, char** argv) 

{

    runTest(argc, argv);

   CUT_EXIT(argc, argv);

}

////////////////////////////////////////////////////////////////////////////////

//! Run a simple test for CUDA

////////////////////////////////////////////////////////////////////////////////

void runTest(int argc, char** argv) 

{

    int i;

   CUT_CHECK_DEVICE();

	

    // Allocate host memory for the signal

    Complex* h_signal = (Complex*)malloc(sizeof(Complex) * SIGNAL_SIZE);

    // Initalize the memory for the signal

    for (unsigned int i = 0; i < SIGNAL_SIZE; ++i) {

        h_signal[i].x = rand() / (float)RAND_MAX;

        h_signal[i].y = 0;

    }

   int mem_size = sizeof(Complex) * SIGNAL_SIZE;

  

    // Allocate device memory for signal

    Complex* d_signal;

    CUDA_SAFE_CALL(cudaMalloc((void**)&d_signal, mem_size));

    // Copy host memory to device

    CUDA_SAFE_CALL(cudaMemcpy(d_signal, h_signal, mem_size,

                              cudaMemcpyHostToDevice));

   // CUFFT plan

    cufftHandle plan;

    CUFFT_SAFE_CALL(cufftPlan1d(&plan, mem_size, CUFFT_DATA_C2C, 1));

   // Transform signal and kernel

    CUFFT_SAFE_CALL(cufftExecute(plan, d_signal, d_signal, CUFFT_FORWARD));

   // Copy device memory to host

    Complex* h_result_signal = h_signal;

    CUDA_SAFE_CALL(cudaMemcpy(h_result_signal, d_signal, mem_size,

                              cudaMemcpyDeviceToHost));

   // Modif - output

    if(ASCII_OUTPUT)

    {

	for(i=0; i < SIGNAL_SIZE; i++)

    	{

      printf("%f\n", h_result_signal[i].y);

    	}

    }

   // cleanup memory

    free(h_signal);

    //free(h_result_signal);

    //cufftDestroy(plan);

    cudaFree(d_signal);

'

}

The code work great with FFT < 2048, but I’ve got this error message with 4096 pts FFT:

cufft: ERROR: cufft.cu, line 118

cufft: ERROR: CUFFT_INVALID_PLAN

The CUFTT doc indicate a max fft length of 16384. Does this max length is just for real FFT ?

Thanks !

Edgardz

You should call the plan creation with the length of the transform, not the number of bytes.

CUFFT_SAFE_CALL(cufftPlan1d(&plan, mem_size, CUFFT_DATA_C2C, 1));

should be

CUFFT_SAFE_CALL(cufftPlan1d(&plan, SIGNAL_SIZE, CUFFT_DATA_C2C, 1));

Ahh… gosh … shame on me !

Thanks you !

Edgardz