I have a piece of code like this, running on 4 MPI process.
for (i=0;i<niter;i++){
//.. do something with temprs
memcpy(rs, temprs,..) // copy temprs content to rs
MPI_Gather(rs,...0...); //gather result to 0
if (mpiRank == 0) writeToDisk(rs);
}
I want to put 2 last line of code into a function comm_and_save then threaded it so that It can run in parallel with the remaining code, something like below:
boost::thread t1;
for (i=0;i<niter;i++){
//.. do something with temprs
t1.join(); // make sure previous comm_and_save done
memcpy(rs, temprs,..) // copy temprs content to rs
t1 = boost::thread( comm_and_save, rs );
}
However, the code sometime run, sometime hang, sometime throws some error:
local QP operation err (QPN 5a0407, WQE @ 00000f02, CQN 280084, index 100677)
[ 0] 005a0407
[ 4] 00000000
[ 8] 00000000
[ c] 00000000
[10] 0270c84f
[14] 00000000
[18] 00000f02
[1c] ff100000
Please enlighten me which part I'm doing incorrectly Thank you
Use MPI_Init_thread
:
http://www.mpi-forum.org/docs/mpi-20-html/node165.htm
and check return status: Available level of thread support
Cheerz.