Java: Cast or reference multidimensional array into single dimensional array

567 views Asked by At

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?

1

There are 1 answers

1
dkg On BEST ANSWER

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 ?