AnsweredAssumed Answered

Problem with 64 bit memory

Question asked by notooth on Feb 21, 2013
Latest reply on Feb 22, 2013 by himanshu.gautam

Hello,

 

I have the following code which does not work with bit field larger than 32. Please help.

__kernel void Generate21(__global ulong* out)

{

          int num = get_global_id(0);

          out[num] = 1<<32 ^ 1<<22; // any number larger than 31 returned wrong result

}

 

unsigned long Matrix[64];

cl_mem cl_Matrix = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(Matrix[63]), NULL, NULL);

cl_kernel Genrerate21 = clCreateKernel(program, "Generate21", NULL);

status = clSetKernelArg(Genrerate21, 0, sizeof(cl_mem), (void *)&cl_Matrix);

*global_work_size = 1;

status = clEnqueueNDRangeKernel(commandQueue, Genrerate21, 1, NULL, global_work_size, NULL, 0, NULL, NULL);

status = clEnqueueReadBuffer(commandQueue, cl_Matrix, CL_TRUE, 0, sizeof(Matrix[63]), &Matrix[63], 0, NULL, NULL);

 

for (char i=63; i>=0; i--)

  printf("%d", (Matrix[63]>>i)&1);

 

Outcomes