javaparallel-processingopenclgpgpujocl

Java: Cast or reference multidimensional array into single dimensional array


I have a program written in Java which involves massive amount of multidimensional array. I am trying to parallelize it using JOCL (OpenCL), but multidimensional array has to be converted to single dimensional array before being passed to OpenCL.

Besides rewriting the entire program using one dimensional array, is there any other solution?


Solution

  • Here is what I do in C++ when I have multidimensional arrays :

    for (int i = 0 ; i < n ; i++) {
        queue.enqueueWriteBuffer(buffer, CL_FALSE, i*m*sizeof(int), m*sizeof(int), data[i]);
    }
    

    Same when I need to read, just be careful in your kernel with your indexes.

    Can't you do the same in Java ?