Im preparing for a project using JNI to accelerate some calculations for physical modeling. Native part does the calculations on a group of arrays each having more than 10M elements.
Question: Which option would be more suitable for performance:
1) Using 8 threads in java each working on 1/8 part of arrays through a native call(jni-->c++). Do I need to crop whole array into smaller arrays to prevent unnecessary array copying?
2) Using single thread in java that calls a native which is 8-threaded (pthreads?)
Can I use pointer arithmetics to select only the necessary part to use in a thread?
I need to work on a single copy(or original) of arrays, does a c++ thread copy the whole array for itself? What about java thread? Which one isnt copying, I will use that one.
Note: Im using GetPrimitiveArrayCritical()
to prevent array copying(working on original) of JNI interface.
Calculations take long enough that JNI overhead can be neglected.
GetPrimitiveArrayCritical()
pins the java array so GC stops working until native function releases it, does this affect other java threads accesibility?
Actually all is in a extern "C"
if it is important .
OS: 64 bit windows7
CPU: fx8150
jvm: 64 bit
GCC: 64 bit
Thanks.