我有一段这样的代码,在4 MPI进程上运行。
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);
}
我想将最后一行代码放入函数 comm_and_save ,然后对其进行线程处理,以便它可以与其余代码并行运行,如下所示:
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 );
}
但是,代码有时会运行,有时挂起,有时会抛出一些错误:
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
请告诉我哪个部分我做错了 谢谢
答案 0 :(得分:0)