24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 1954  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 348求调剂 +6 小懒虫不懒了 2026-03-27 7/350 2026-04-02 11:18 by sanrepian
[考研] 考研调剂 +12 Amber00 2026-03-31 12/600 2026-04-02 09:04 by sanrepian
[考研] 343求调剂085601 +4 要努力学习x 2026-03-29 5/250 2026-04-02 09:01 by xuhui0306
[考研] 化学工程专硕324分,一志愿中国矿业大学求调剂 +7 耿耿1314 2026-04-01 7/350 2026-04-02 07:40 by 尚水阁主
[考研] 349求调剂 +6 吃的不少 2026-04-01 6/300 2026-04-01 17:55 by JYD2011
[考研] 324求调剂 +10 hanamiko 2026-03-26 12/600 2026-04-01 16:59 by oooqiao
[考研] 材料专硕306英一数二 +7 z1z2z3879 2026-03-31 7/350 2026-04-01 14:50 by ZXlzxl0425
[论文投稿] chinese chemical letters英文版投稿求助 120+4 Yishengeryi 2026-03-30 5/250 2026-04-01 14:11 by 陆小果画大饼
[考研] 材料工程085601数二英一335求调剂 +5 双马尾痞老板2 2026-03-31 5/250 2026-03-31 19:07 by Wang200018
[考研] 318求调剂 +10 陈晨79 2026-03-30 10/500 2026-03-31 17:37 by 544594351
[考研] 学硕274求调剂 +17 Li李鱼 2026-03-26 17/850 2026-03-31 15:19 by 客尔美德
[考研] 一志愿浙江大学工科动力工程370,数一121,专业课135,现在能去哪里 +3 080700调剂 2026-03-30 4/200 2026-03-31 12:00 by KLMY666
[考研] 一志愿大连理工大学,机械工程学硕,341 +3 西瓜田的守望者 2026-03-30 3/150 2026-03-31 11:08 by asdfzly
[考研] 348求调剂 +6 小懒虫不懒了 2026-03-28 6/300 2026-03-30 10:29 by Evan_Liu
[考研] 调剂考研 +3 王杰一 2026-03-29 3/150 2026-03-29 08:09 by fmesaito
[硕博家园] 招收生物学/细胞生物学调剂 +4 IceGuo 2026-03-26 5/250 2026-03-29 01:25 by griffith2014
[考研] 312,生物学求调剂 +3 小译同学abc 2026-03-28 3/150 2026-03-28 15:32 by 落睿可思
[考研] 复试调剂 +3 raojunqi0129 2026-03-28 3/150 2026-03-28 15:27 by 落睿可思
[考研] 304求调剂 +6 曼殊2266 2026-03-27 6/300 2026-03-28 14:10 by 唐沐儿
[考研] 315调剂 +4 0860求调剂 2026-03-26 5/250 2026-03-27 11:23 by wangjy2002
信息提示
请填处理意见