AnsweredAssumed Answered

kernel input arguments

Question asked by binghy on Sep 15, 2015
Latest reply on Oct 8, 2015 by nibal

Hi, maybe I'm missing something and I'm getting lost.

 

I have three buffers that point to global memory (__global uint2 *input_buffer, __global *uint4 carrier_buffer, __global *uint4 data_buffer).

 

Each of them has been created in this way:

1) input_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, 128*sizeof(cl_uint2), &input, &errNum);

2) carrier_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, 128*sizeof(cl_uint4), &carrier, &errNum);

3) data_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, 128*sizeof(cl_uint4), &data, &errNum);

 

The variables are first initialized and then filled on the host before creating the buffers:

1) cl_uint2 *input ---- input = (cl_uint2*)malloc(128*sizeof(cl_uint2)) ---- memset(&input[0], 0, 128*sizeof(cl_uint2)) ---- and then filled properly calling another function on the host to which the *input pointer is passed

2) cl_uint4 *carrier ---- carrier = (cl_uint4*)malloc(128*sizeof(cl_uint4)) ---- memset(&carrier[0], 0, 128*sizeof(cl_uint4)) ---- and then filled calling another function on the host to which the *carrier pointer is passed

3) cl_uint4 *data ---- data = (cl_uint4*)malloc(128*sizeof(cl_uint4)) ---- memset(&data[0], 0, 128*sizeof(cl_uint4)) ---- and then filled calling another function on the host to which the *data pointer is passed

Everything's fine.

 

Then I execute the program with all the stuff in the kernel, and execution completes. But if I try accessing the buffers by CodeXL to check the correctness, Visual Studio gets stucked. Sometimes it allows me to check data and they are random numbers, not what I expect.

 

What am I doing wrong?

 

Thanks in advance

 

Marco

Outcomes