Hi again,
I have some strange things happening in my kernel.
this is my kernel call:
calculate_parametric_sets<<<dimGrid, dimBlock>>>(
d_alpha_x,
d_delta_x,
h_dx,
d_i_min,
d_i_max,
d_offset_x,
h_xsource, h_x_plane,
dimGrid.y,
blockSize_x, blockSize_y, block_offset_x, block_offset_y
);
this is the kernel header:
__global__ void calculate_parametric_sets(
float *alpha,
const float *delta,
const float d,
const int *index_min,
const int *index_max,
const unsigned int *prefix_sum,
const float source, const float plane,
int gridY,
unsigned int blockSize_x, unsigned int blockSize_y, unsigned int offset_x, unsigned int offset_y
)
So you can see *delta is a constant array of floats. The thing is when I run this my kernel
// set blockindex
int bx = blockIdx.x;
int by = blockIdx.y;
// set threadindex
int tx = threadIdx.x;
int ty = threadIdx.y;
// determine x, y and z pending on threadindex and blocksize
int i = (tx+offset_x) + (bx % gridY) * blockSize_x; // offset is used to tell which subblock will be calculated
int j = (ty+offset_y) + by * blockSize_y;
int k = floorf(bx / gridY);
// determine index of voxel
int index = i + (nx-1)*(j + k *(ny-1));
float d_inv_delta;
float l_delta;
// ends here
l_delta = delta[index];
d_inv_delta = d / l_delta;
if(l_delta > 0){
int pos = prefix_sum[index];
float temp_alpha;
temp_alpha = (plane + (index_min[index] - 1)*d-source) / l_delta;
alpha[pos] = temp_alpha;
for(int i=1; i<(index_max[index]-index_min[index]); i++) {
temp_alpha = temp_alpha + d_inv_delta;
alpha[pos+i] = temp_alpha;
}
} else {
//VANAF HIER GAAT HET MIS! vervang is 0 door prefix_sum[index] dan krijg ik allemaal vreemde delta waardes.
int pos = 0;//prefix_sum[index];
float temp_alpha;
temp_alpha = (plane + (index_max[index] - 1)*d-source) / l_delta;
alpha[pos] = temp_alpha;
for(int i=1; i<index_max[index]-index_min[index]; i++) {
temp_alpha = temp_alpha + d_inv_delta;
alpha[pos+i] = temp_alpha;
}
}
}
in the if part it all goes fine but when i come to the else part and change the int pos = 0; to int pos = prefix_sum[index] the values of delta will be rubbish
good values:
Delta X values
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
-21.375000 -19.125000 -16.875000 -14.625000 -12.375000 -10.125000 -7.875000 -5.625000 -3.375000 -1.125000 1.125000 3.375000 5.625000 7.875000 10.125000 12.375000
bad values:
Delta X values
0.000000 0.000000 0.000000 14281679716281643063034706579685376.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000042 0.000000 0.000000 0.000044 0.000000 0.000000
0.000000 0.000000 0.000000 0.000014 0.000000 0.000000 0.000000 14289081359776530351698328443420672.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000044
14289016986894487511924033688961024.000000 0.000000 0.000169 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 14289028128354841080346507781079040.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000014 0.000000 14281679716281643063034706579685376.000000 0.000000 0.000169 0.000000 0.000000 0.000000 0.000000 0.000042 0.000000 0.000000 0.000044 0.000000 0.000004 0.000000
0.000000 0.000000 0.000014 0.000000 0.000000 0.000000 14289081359776530351698328443420672.000000 0.000000 0.000000 0.000000 0.000000 0.000042 0.000000 0.000000 0.000044 14289016986894487511924033688961024.000000
0.000000 0.000001 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 14289018224834526797304308588085248.000000 0.000000 0.000000 0.000000 0.000042 0.000000 0.000000 0.000000
0.000000 14281679716281643063034706579685376.000000 0.000000 0.000001 0.000000 0.000042 0.000000 0.000000 203131272386593161216.000000 0.000000 0.000000 0.000044 0.000000 0.000000 0.000042 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 14289018224834526797304308588085248.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000044 14289016986894487511924033688961024.000000 0.000001
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 14289020700714605368064858386333696.000000 0.000000 0.000000 293008659327554821292032.000000 0.000000 0.000000 0.000000 0.000000 0.000000
14281679716281643063034706579685376.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000044 0.000000 286140864254286233600.000000 0.000000 0.000000 0.000000
0.000011 0.000000 0.000000 0.000000 14289081359776530351698328443420672.000000 0.000000 0.000000 0.000000 0.000000 0.000003 0.000000 0.000000 0.000044 14289016986894487511924033688961024.000000 0.000000 0.000170
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 14289023176594683938825408184582144.000000 0.000000 0.000000 286141268874565255168.000000 0.000000 0.000000 0.000000 0.000011 0.000000 14281679716281643063034706579685376.000000
0.000011 0.000169 0.000000 0.000000 0.000000 0.000000 0.000003 0.000000 0.000000 0.000044 0.000000 0.000000 0.000000 0.000000 0.000000 0.000011
0.000000 0.000000 0.000000 14289028128354841080346507781079040.000000 0.000000 0.000000 0.000000 0.000000 3250747750631925088256.000000 0.000000 0.000000 3379226722276527308800.000000 14289016986894487511924033688961024.000000 0.000000 13149700263988921630720.000000 0.000000
0.000042 0.000000 0.000000 0.000000 0.000000 14289028128354841080346507781079040.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000011 0.000000 14281679716281643063034706579685376.000000 0.000042
0.000169 4578260301993044082688.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 18313015312274318950400.000000 0.000000 0.000000 0.000000 0.000011 0.000000
It looks like I’m calling some part of the memory which is not the original d_delta_x but I don’t know exactly.
I hope some1 can help me.
Thanks Jordy