I have a long doubly-nested for loop to go over for many trials. I want to do this in parallel because these trials are independent of one another. How do I implement this efficiently in Java similar to OpenMP in C++? I would be running this on a node with 64 processors, so I want each core to do one measure.
Relevant code:
//I want each measure to perform the doubly nested loop at the same time.
for (int i : measures) {
for (int j = 0; j < N; j++) {
for (int k = 0; k < N; k++) {
array[i*N*N + j*N + k] = someFunc(i,j,k);
}
}
}
Edit: Still having issues:
//sim is a 1D array of type double
//gM is an array of type SMconf
//gene[foo].annot is a LinkedHashSet of URIs.
//Javadoc http://www.semantic-measures-library.org/sml/docs/apidocs/
Arrays.parallelSetAll( sim, i -> {
try {
engine.compare( gM[i/(N*N)], gene[(i/N)%N].annot, gene[i % N].annot );
}
catch (SLIB_Ex_Critic ex) {
Logger.getLogger(Exp2.class.getName()).log(Level.SEVERE, null, ex);
}
});
Error:

someFuncsignature to accept directly the array item instead of its position in the array.