__global__ void msinc_kernel(unsigned int na, cuDoubleComplex *alpha, double pm, cuDoubleComplex *y)
{
double eps1=sqrt(6.0*pm);
int i = blockIdx.x * blockDim.x + threadIdx.x;
double x=cuCreal(alpha[i]);
double y2=cuCimag(alpha[i]);
if ( i < na)
if (cuCabs(alpha[i]) > eps1)
{
double a=exp(-2.0*y2)*cos(2.0*y2)-1.0, b=sin(2.0*x)*exp(-2.0*y2);
double c=-2.0*y2, d=2.0*x;
y[i] = make_cuDoubleComplex((a*c+b*d)/(c*c+d*d), (b*c-a*d)/(c*c+d*d));
}
else
{
double x1 = (1-x*x/6.0+y2*y2/6.0)*cos(x)-x*y2*sin(x)/3.0;
double y1 = (1-x*x/6.0+y2*y2/6.0)*sin(x)+x*y2*cos(x)/3.0;
y[i] = make_cuDoubleComplex(x1, y1);
}
y[i]=make_cuDoubleComplex(cuCreal(alpha[i]), cuCimag(alpha[i]));
__syncthreads();
return;
}
This is my kernel function, everything else works fine except for the y2=cuCimag(), the results running in graphics is
(-9.686006e-08,-1.409392e+307)
(4.885526e-08,-1.550387e+307)
(4.621565e-08,-1.550387e+307)
(-2.569997e-08,-1.409392e+307)
(3.371802e-08,-1.268397e+307)
(-3.896651e-08,-1.691383e+307)
(8.329686e-08,-1.338894e+307)
(-5.119202e-08,-1.268396e+307)
(-3.486711e-08,-1.338895e+307)
(-7.364092e-08,-1.550387e+307)
but in emu mode I can get the correct result as :
(-9.686006e-08,7.296060e-08)
(4.885526e-08,-8.956707e-08)
(4.621565e-08,-5.357445e-08)
(-2.569997e-08,6.052441e-08)
(3.371802e-08,9.878985e-08)
(-3.896651e-08,8.984847e-08)
(8.329686e-08,-2.966926e-08)
(-5.119202e-08,1.571757e-08)
(-3.486711e-08,-1.148769e-08)
(-7.364092e-08,-8.289431e-08)
what’s wrong with it ???