Problems with JOCL version of Dijkstra

I’m trying to implement a JOCL based version of Dijkstra’s Single Source Shortest Path Algoritm outlined in OpenCL Programming Guide book. I’m having a hard time despite having implemented other JOCL based algorithms and don’t seem to find the problem.

Basically what I do is


private static final int MEM_OBJECT_MASK_ARRAY = 3;
[...]
int vertexCount = 4
final int[] maskArray = new int[vertexCount];
final Pointer maskArrayPointer = Pointer.to(maskArray);
[...]
memObject = new cl_mem[6];
[...]
memObject[MEM_OBJECT_MASK_ARRAY] = clCreateBuffer(context,
	CL_MEM_READ_WRITE, Sizeof.cl_int * vertexCount, null, null);
[...]
final long[] globalWorkSize = new long[] { vertexCount };
final long[] localWorkSize = new long[] { 1 };

clEnqueueNDRangeKernel(queue, intializationKernel, 1, null,
	globalWorkSize, localWorkSize,0,
	null, null);

clEnqueueReadBuffer(queue, memObject[MEM_OBJECT_MASK_ARRAY],
					CL_TRUE, 0, Sizeof.cl_int * vertexCount, maskArrayPointer,
0, null, null);


__kernel void initializeBuffers( __global int *maskArray, __global float *costArray, __global float *updatingCostArray,
                                 int sourceVertex, int vertexCount ) {
    int tid = get_global_id(0);
    if (sourceVertex == tid) {
        maskArray[tid] = 1;
        [...]
    }  else {
        maskArray[tid] = 0;
        [...]
    }
}

The complete code can be found at https://gist.github.com/3363728

  1. Create array,
  2. create pointer to that array,
  3. create the buffer allocating enough bytes,
  4. enqueue the kernel to run with a global work size equal to the number of vertices
  5. read results back from that buffer to the memory of the pointer.

The kernel itself just writes 0 to all but one bucket of the array, writing 1 to only a target bucket but I only get random numbers back, which normally tells me that I’ve set some offsets or sizes wrong but everything is in order (at least in my opinion). There must be something basic I am missing.

Can somebody spot the error?

It was a stupid mistake. Nearing the final version of the code, after I removed some debug code I changed references to the source code. So no kernels were compiled.

This is what you get for staying up late: hours of debugging.