I have a structure in a file that is included in the host and kernel code
typedef struct { float x, y, z, dir_x, dir_y, dir_z; int radius; } WorklistStruct;
I create this structure in my C ++ host code and pass it through a buffer to the OpenCL core.
If I select a processor device for calculation, I get the following result:
printf ( "item:[%f,%f,%f][%f,%f,%f]%d,%d\n", item.x, item.y, item.z, item.dir_x, item.dir_y, item.dir_z , item.radius ,sizeof(float));
Leading:
item:[20.169043,7.000000,34.933712][0.000000,-3.000000,0.000000]1,4
Device (CPU):
item:[20.169043,7.000000,34.933712][0.000000,-3.000000,0.000000]1,4
And if I choose a GPU (AMD) device to calculate, strange things happen:
Leading:
item:[58.406261,57.786015,58.137501][2.000000,2.000000,2.000000]2,4
Device (GPU):
item:[58.406261,2.000000,0.000000][0.000000,0.000000,0.000000]0,0
Notably, sizeof (float) is garbage on gpu.
I assume that there is a problem with the layouts of the floats on different devices.
Note: the structure is contained in an array of structures of this type, and each structure in this array is garbage on the GPU
Anyone have an idea why this is so and how I can predict it?
EDIT I added% d to and and replaced it with 1, the result: 1065353216
EDIT : here are two structures that I use
typedef struct { float x, y, z,//base coordinates dir_x, dir_y, dir_z;//directio int radius;//radius } WorklistStruct; typedef struct { float base_x, base_y, base_z; //base point float radius;//radius float dir_x, dir_y, dir_z; //initial direction } ReturnStruct;
I tested some other things, this seems like a problem with printf. The values seem to be correct. I passed the arguments to the return structure, read them, and these values were correct.
I do not want to publish all the related code, it will be several hundred lines. If no one has an idea, I would compress it a bit.
Oh, and for printing I use #pragma OPENCL EXTENSION cl_amd_printf : enable .
Edit: Looks like a problem with printf. I just don't use it anymore.