# Loss of accuracy with cuCdiv?

I’m having a problem with the accuracy provided by cuCdiv.

My kernel is very simple:

``````__global__ void scaling_zero_padding(cufftDoubleComplex *data_d, cufftDoubleComplex *phi, cufftDoubleComplex *uk, int N)

{

int i = threadIdx.x + blockDim.x * blockIdx.x;

if(i<c*N)

{

if( (i<((c+1)*N/2)) && (i>=((c-1)*N/2)) ) uk[i] = make_cuDoubleComplex(0.,0.);

else uk[i] = cuCdiv(data_d[(i+N+N/2)%N],phi[(i+N+N/2)%N]);

}

}
``````

The inputs have the same precision as a Matlab equivalent program. I have checked it by simply changing

``````uk[i] = cuCdiv(data_d[(i+N+N/2)%N],phi[(i+N+N/2)%N]);
``````

to either

``````uk[i] = data_d[(i+N+N/2)%N];
``````

or

``````uk[i] = phi[(i+N+N/2)%N];
``````

However, the result of cuCdiv has always a precision of 5 digits only.

Am I doing anything wrong? Is this the normal accuracy of cuCdiv?

cuCdiv() operates on double-complex numbers. This requires that code is compiled for compute capability 1.3 or higher. Note that the compiler defaults to compiling for compute capability 1.0.

In order for me to look into this, can you please post a repro case consisting of the particular pair of cuCdiv() inputs, the observed cuCdiv() output, and the output of your complex division reference function? Please print all operands with the format %23.16e for full double-precision accuracy. Thanks.