简体   繁体   中英

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?

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 ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM