Hello all,
I’m trying to use a sinusoid as an input to a CUDA program I wrote but am having problems with the data types.
[codebox]
cuFloatComplex *alldata;
cudaMallocHost((void **)&alldata, inputLength * sizeof(cuFloatComplex));
for(int i = 0; i < inputLength; i++) { // CREATE ALL DATA, pad_length of zeros
n = (n+rand()/RAND_MAX-1/2)/2;
alldata[i].x = cos(2*3.1415926*(100/1000)*i);
alldata[i].y = sin(2*3.1415926*(100/1000)*i);
}
cuFloatComplex* totalOutput_d;
CUDA_SAFE_CALL(cudaMalloc((void**)&totalOutput_d, inputLength * sizeof(cuFloatComplex)));
cudaMemcpy(totalOutput_d, alldata, input_data_size*sizeof(cuFloatComplex), cudaMemcpyHostToDevice);
cufftComplex* output_h;
CUDA_SAFE_CALL(cudaMallocHost((void **)&output_h, input_data_size * sizeof(cufftComplex)));
cudaMemcpy(output_h, totalOutput_d, input_data_size * sizeof(cufftComplex), cudaMemcpyDeviceToHost);
for(int j=0; j<input_data_size; j++){
printf("%d: %f\n",j,output_h[j].x);
}
[/codebox]
Unfortunately, my output is a series of 1’s input_data_size elements long. Obviously, these values should be decimals - so some kind of truncation is taking place.
I’m assuming it’s due to the data type cuFloatComplex… any suggestions?
Thanks in advance! :)