簡體   English   中英

在線程上使用MPI的正確方法是什么

[英]What is the correct way to use MPI with thread

我有一段這樣的代碼,在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

請告訴我我做錯了哪一部分謝謝

使用MPI_Init_threadhttp : MPI_Init_thread

並檢查返回狀態:線程支持的可用級別

Cheerz。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM