To make the question more interesting , below is my br code. It is not very long and not very elaborate, but in my ignorance I would like to know :
- why the 2D part seems to work and the 3D part fails. The last thing which gets printed is : Passe 34 just before entering the kernel;
- why although the 2D part seems to work, the returned value is always 0 when I would expect it to be 10. (the value set inside the kernel).
====================================== source code below ================================================
kernel void interpolate3D(float dim, float VOLREC[][][], float IMAGE[][], float theta, out float result<>
{
result = 10.;
}
kernel void interpolate2D(float dim, float VOLREC[][], float IMAGE[][], float theta, out float result<>
{
result = 10.;
}
int main(int argc, char** argv)
{
int dim = 10;
int i = 0;
int j = 0;
int k = 0;
float VR3D<dim, dim, dim>;
float Image3D<dim, dim>;
float RES3D<dim, dim, dim>;
float VR<dim, dim>;
float Image<dim>;
float RES<dim, dim>;
float* inputVR;
float* inputImage;
float* inputVR3D;
float* inputImage3D;
float output[10][10];
float* output3D;
printf(" Start \n");
inputVR = (float*)malloc(sizeof *inputVR*dim*dim);
inputImage = (float*)malloc(sizeof *inputImage*dim);
streamRead(VR, inputVR);
streamRead(Image, inputImage);
interpolate2D((float)dim, VR, Image, 0., RES);
streamWrite(RES, output);
for(i=0; i<dim; i++){
for(j=0; j<dim; j++){
printf(" Output %d %d : %d \n", i, j, output
);
//printf(" Output %d %d : \n", i, j);
}
}
inputVR3D = (float*)malloc(sizeof *inputVR3D*dim*dim*dim);
printf(" Passe 31 \n");
inputImage3D = (float*)malloc(sizeof *inputImage3D*dim*dim);
printf(" Passe 32 \n");
output3D = (float*)malloc(sizeof *output3D*dim*dim*dim);
streamRead(VR3D, inputVR3D);
printf(" Passe 33 \n");
streamRead(Image3D, inputImage3D);
printf(" Passe 34 \n");
interpolate3D((float)dim, VR3D, Image3D, 0., RES3D);
printf(" Passe 35 \n");
streamWrite(RES3D, output);
printf(" Done 3D\n");
}