Hi,

I've setups my kernel to return a simple value to test wether the kernel is working, but I think its returning bits instead of the value.

In main, I prepped the variable passing like this:

double distances[NUM_ATOMS];

memObjects[0] = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, NUM_RAYS*sizeof(double), rayA, NULL);
memObjects[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, NUM_ATOMS*sizeof(double), NULL, NULL);

errNum = clSetKernelArg(CheckKernel, 0, sizeof(cl_mem), &memObjects[0]);
errNum |= clSetKernelArg(CheckKernel, 1, sizeof(cl_mem), &memObjects[1]);

size_t globalWorkSize[1] = { NUM_ATOMS };
size_t localWorkSize[1] = { 1 };

errNum = clEnqueueNDRangeKernel(commandQueue, CheckKernel, 1, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL);

clFinish(commandQueue);

errNum = clEnqueueReadBuffer(commandQueue, memObjects[1], CL_TRUE, 0, NUM_ATOMS*sizeof(double), distances, 0, NULL, NULL);

for(t=0;t<NUM_ATOMS;t++)
{
cout << distances[t] << endl;
}


The kernel:

__kernel void Check_for_intersection(__global const double rayA,
__global double *distances){
int gid = get_global_id(0);
distances[gid] = 0;
}


I've tried many different values for distances and got this:

distances[gid] = 0; returns 0.0078125
distances[gid] = 1; returns 32
distances[gid] = 2; returns 2048
distances[gid] = 3; returns 32768
distances[gid] = 4; returns 262144
distances[gid] = 5; returns 1.04858e+06
distances[gid] = 6; returns 4.19431e+06
distances[gid] = 7; returns 1.67772e+07
distances[gid] = 8; returns 5.03317e+07
distances[gid] = 9; returns 1.00663e+08

Also, if I do math in the kernel with a passed variable like:

double a = 1;
distances[AtomID] = a + rayA;


I get this error:

Error in kernel:
<program source>:16:27: error: invalid operands to binary expression ('double' and 'double const __attribute__((address_space(1))) *')
distances[AtomID] = a + rayA;
' ~ ^ ~~~~


Does anyone have a clue what's wrong?