I wrote a simple cuda file that successfully build in visual studio 2010 & nsight eclipse
the code is here
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cufft.h>
#include <cutil_inline.h>
typedef float2 Complex;
int main(int argc, char** argv)
{
const int NX = 1024;
const int BATCH = 90000;
const int SIGNAL_SIZE = NX * BATCH;
Complex* h_signal = (Complex*)malloc(sizeof(Complex) * SIGNAL_SIZE);
for (unsigned int i = 0; i < SIGNAL_SIZE; ++i) {
h_signal[i].x = rand() / (float)RAND_MAX;
h_signal[i].y = 0;
}
Complex* d_signal;
cutilSafeCall(cudaMalloc((void**)&d_signal, sizeof(Complex)*SIGNAL_SIZE));
cutilSafeCall(cudaMemcpy(d_signal, h_signal, sizeof(Complex)*SIGNAL_SIZE,
cudaMemcpyHostToDevice));
cufftHandle plan;
cufftSafeCall(cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH));
cufftSafeCall(cufftExecC2C(plan, (cufftComplex *)d_signal, (cufftComplex *)d_signal, CUFFT_FORWARD));
cutilSafeCall(cudaMemcpy(h_signal, d_signal, SIGNAL_SIZE*sizeof(Complex),
cudaMemcpyDeviceToHost));
//Destroy CUFFT context
cufftSafeCall(cufftDestroy(plan));
// cleanup memory
free(h_signal);
cutilSafeCall(cudaFree(d_signal));
cudaThreadExit();
cutilExit(argc, argv);
}
I changed NX & BATCH four times for example with
const int NX = 1024;
const int BATCH = 90000;
const int SIGNAL_SIZE = NX * BATCH;
cufftHandle plan;
cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);
I successfully run Sample in visual studio 2010 & 2012 (windows 7 64 bit) but in ubuntu 12.04 (32 bit) nsight eclipse give this Error
CUFFT_ALLOC_FAILED
for cufftPlan1d function
I change BATCH to 80000 (NX = 1024) & this error occurred in ubuntu but in visual studio 2010 i run without any errors!
I use Cuda toolkit 5.5 that has this feature:
Transform sizes up to 128 million elements in single precision
and 80000 * 1024 = 81920000 elements < 128 million elements
I change BATCH to 8000 (NX = 1024) & that error does not occured in ubuntu
Please Help Me
thanks
cudaThreadExit()has been deprecated in favour ofcudaDeviceReset(), see this document - Vitality