karbous
November 18, 2010, 6:03pm
21
as I wrote a bit earlier, allocate the image buffer in the host code and pass it as follows:
cl_uchar* image = new cl_uchar[N*M];
cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(cl_uchar), image, &error);
It is a good habit to refer to different types wit cl_* in the host code, so that it is same size as in the OpenCL kernel code.
karbous
November 18, 2010, 6:03pm
22
as I wrote a bit earlier, allocate the image buffer in the host code and pass it as follows:
cl_uchar* image = new cl_uchar[N*M];
cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(cl_uchar), image, &error);
It is a good habit to refer to different types wit cl_* in the host code, so that it is same size as in the OpenCL kernel code.
as I wrote a bit earlier, allocate the image buffer in the host code and pass it as follows:
cl_uchar* image = new cl_uchar[N*M];
cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(cl_uchar), image, &error);
It is a good habit to refer to different types wit cl_* in the host code, so that it is same size as in the OpenCL kernel code.
Oh. That did you mean. I already tried it and it was no solution.
The error just happens when I change one or more array-values in my CL C code.
as I wrote a bit earlier, allocate the image buffer in the host code and pass it as follows:
cl_uchar* image = new cl_uchar[N*M];
cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(cl_uchar), image, &error);
It is a good habit to refer to different types wit cl_* in the host code, so that it is same size as in the OpenCL kernel code.
Oh. That did you mean. I already tried it and it was no solution.
The error just happens when I change one or more array-values in my CL C code.
karbous
November 18, 2010, 8:48pm
25
never mind, than try out to pass m and n as integer kernel parameters. Also try out to change private arrays
float c0[2];
float c[2];
float d[2];
to vectors and index them accordingly
float4 c0; //access it like c0.x - previous c0[0], c0.y - alias c0[1]
float4 c, d;
I’m not sure how much NVidia supports arrays in private space…
karbous
November 18, 2010, 8:48pm
26
never mind, than try out to pass m and n as integer kernel parameters. Also try out to change private arrays
float c0[2];
float c[2];
float d[2];
to vectors and index them accordingly
float4 c0; //access it like c0.x - previous c0[0], c0.y - alias c0[1]
float4 c, d;
I’m not sure how much NVidia supports arrays in private space…
never mind, than try out to pass m and n as integer kernel parameters. Also try out to change private arrays
float c0[2];
float c[2];
float d[2];
to vectors and index them accordingly
float4 c0; //access it like c0.x - previous c0[0], c0.y - alias c0[1]
float4 c, d;
I’m not sure how much NVidia supports arrays in private space…
With these variables is no problem at all.
The failure just occures when I change “image”.
Do I possibly handle that array in a wrong way?
never mind, than try out to pass m and n as integer kernel parameters. Also try out to change private arrays
float c0[2];
float c[2];
float d[2];
to vectors and index them accordingly
float4 c0; //access it like c0.x - previous c0[0], c0.y - alias c0[1]
float4 c, d;
I’m not sure how much NVidia supports arrays in private space…
With these variables is no problem at all.
The failure just occures when I change “image”.
Do I possibly handle that array in a wrong way?
karbous
November 19, 2010, 8:26am
29
Yes, you handle it in wrong way (I must have been blinded that I didn’t see it before). You declared it as an array of unsigned chars (cl_uchar is 8-bit), but you are assigning in that array integer values (cl_int 32-bit values). Make the types to be the same.
karbous
November 19, 2010, 8:26am
30
Yes, you handle it in wrong way (I must have been blinded that I didn’t see it before). You declared it as an array of unsigned chars (cl_uchar is 8-bit), but you are assigning in that array integer values (cl_int 32-bit values). Make the types to be the same.
Yes, you handle it in wrong way (I must have been blinded that I didn’t see it before). You declared it as an array of unsigned chars (cl_uchar is 8-bit), but you are assigning in that array integer values (cl_int 32-bit values). Make the types to be the same.
Now I tried an explicit typecast:
image[index++] = (unsigned char)(255 * k);
but its still the same error.
Yes, you handle it in wrong way (I must have been blinded that I didn’t see it before). You declared it as an array of unsigned chars (cl_uchar is 8-bit), but you are assigning in that array integer values (cl_int 32-bit values). Make the types to be the same.
Now I tried an explicit typecast:
image[index++] = (unsigned char)(255 * k);
but its still the same error.
karbous
November 19, 2010, 8:45am
33
strange, just make sure and declare the array as cl_int rather than explicit cast - I know it should be the same, but lets make really sure…
karbous
November 19, 2010, 8:45am
34
strange, just make sure and declare the array as cl_int rather than explicit cast - I know it should be the same, but lets make really sure…
I tried it, but its still the same…
/** Allocate image buffer **/
cl_int image2[M*N];
int h = 0;
for(int i = 0; i < M; i++)
for(int j = 0; j < N; j++)
{
image2[h] = (cl_int)image[i][j];
h++;
}
cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(cl_int/*cl_uchar*/), image2, &error);
checkErr(error, "Buffer::outCL(image)");
/*****/
I tried it, but its still the same…
/** Allocate image buffer **/
cl_int image2[M*N];
int h = 0;
for(int i = 0; i < M; i++)
for(int j = 0; j < N; j++)
{
image2[h] = (cl_int)image[i][j];
h++;
}
cl::Buffer imageCL( context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, M*N*sizeof(cl_int/*cl_uchar*/), image2, &error);
checkErr(error, "Buffer::outCL(image)");
/*****/
karbous
November 19, 2010, 9:06am
37
also there is missing any cl::CommandQueue::enqueueCopyBuffer if you still pass buffers instead of simply variables to the kernel
karbous
November 19, 2010, 9:06am
38
also there is missing any cl::CommandQueue::enqueueCopyBuffer if you still pass buffers instead of simply variables to the kernel