24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1912  |  回复: 4

wlw515

金虫 (初入文坛)

[求助] 并行初学者遇到了点问题,已经被困很久了,希望大家帮助一下,不胜感激已有1人参与

我现在想在从c++中实现并行,然后开始接触这一块,但是遇到了点问题。具体的程序如下:
if(MyPID==0)
{
  N=6;
    MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);

}
    MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);
     Epetra_Map Map(N,0,Comm);
     cout<<Map;
  这段程序我就是想验证一下广播可不可以使用,但是结果一直出错,显示这样的错误:
Number of Global Elements  = 6
Number of Global Points    = 6
Maximum of all GIDs        = 5
Minimum of all GIDs        = 0
Index Base                 = 0
Constant Element Size      = 1

Number of Local Elements   = 2
Number of Local Points     = 2
Maximum of my GIDs         = 1
Minimum of my GIDs         = 0

         MyPID           Local Index        Global Index  
             0                 0                 0   
             0                 1                 1   
Fatal error in PMPI_Barrier: Message truncated, error stack:
PMPI_Barrier(425)...................: MPI_Barrier(MPI_COMM_WORLD) failed
MPIR_Barrier_impl(332)..............: Failure during collective
MPIR_Barrier_impl(327)..............:
MPIR_Barrier(292)...................:
MPIR_Barrier_intra(150).............:
barrier_smp_intra(111)..............:
MPIR_Bcast_impl(1452)...............:
MPIR_Bcast(1476)....................:
MPIR_Bcast_intra(1287)..............:
MPIR_Bcast_binomial(239)............:
MPIC_Recv(353)......................:
MPIDI_CH3U_Request_unpack_uebuf(568): Message truncated; 4 bytes received but buffer size is 1
Fatal error in PMPI_Barrier: Message truncated, error stack:
PMPI_Barrier(425)...................: MPI_Barrier(MPI_COMM_WORLD) failed
MPIR_Barrier_impl(332)..............: Failure during collective
MPIR_Barrier_impl(327)..............:
MPIR_Barrier(292)...................:
MPIR_Barrier_intra(150).............:
barrier_smp_intra(111)..............:
MPIR_Bcast_impl(1452)...............:
MPIR_Bcast(1476)....................:
MPIR_Bcast_intra(1287)..............:
MPIR_Bcast_binomial(239)............:
MPIC_Recv(353)......................:
MPIDI_CH3U_Request_unpack_uebuf(568): Message truncated; 4 bytes received but buffer size is 1
Fatal error in PMPI_Barrier: Other MPI error, error stack:
PMPI_Barrier(425).......: MPI_Barrier(MPI_COMM_WORLD) failed
MPIR_Barrier_impl(332)..: Failure during collective
MPIR_Barrier_impl(327)..:
MPIR_Barrier(292).......:
MPIR_Barrier_intra(150).:
barrier_smp_intra(111)..:
MPIR_Bcast_impl(1452)...:
MPIR_Bcast(1476)........:
MPIR_Bcast_intra(1287)..:
MPIR_Bcast_binomial(310): Failure during collective
我很想知道广播在这里到底哪里除了问题,还请大家帮忙解答一下
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zoghin

新虫 (初入文坛)

【答案】应助回帖

感谢参与,应助指数 +1
MPI_Bcast 不要限制在某个进程中,每个进程都需运行这个程序
Dowhatyouwanttodo!
2楼2016-08-02 18:22:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wlw515

金虫 (初入文坛)

引用回帖:
2楼: Originally posted by zoghin at 2016-08-02 18:22:14
MPI_Bcast 不要限制在某个进程中,每个进程都需运行这个程序

如果要输入某个数值的话不在特定进程就出错了啊

发自小木虫IOS客户端
3楼2016-08-03 09:55:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zoghin

新虫 (初入文坛)

引用回帖:
3楼: Originally posted by wlw515 at 2016-08-03 09:55:42
如果要输入某个数值的话不在特定进程就出错了啊
...

scanf可以放在特定线程,但线程需要MPI_Bcast无法放在特定线程,只需将root线程设scanf的线程
Dowhatyouwanttodo!
4楼2016-08-04 12:49:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wlw515

金虫 (初入文坛)

引用回帖:
4楼: Originally posted by zoghin at 2016-08-04 12:49:09
scanf可以放在特定线程,但线程需要MPI_Bcast无法放在特定线程,只需将root线程设scanf的线程...

好的好的,多谢了

发自小木虫IOS客户端
5楼2016-08-05 18:34:18
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 wlw515 的主题更新
信息提示
请填处理意见