【问题标题】:MPI hello world program not showing the same results as the rest of the class?MPI hello world 程序显示的结果与其他班级的结果不同?
【发布时间】:2014-11-06 03:28:20
【问题描述】:

这是简单的 MPI 程序:

#include <stdio.h>
#include <mpi.h>
main(int argc, char ** argv)
{
int rank,size;


MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);

if(rank==0)
{
printf("Hello world, I'm process %d of %d and I'm the boss\n",rank,size);}


else{
printf("Hello world, I'm process %d of %d\n",rank,size);
}

MPI_Finalize();
}

这是老师使用的完全相同的代码!

这是我得到的编译结果:

mpicc hello.c -o hellompi
mpirun -np 8 ./hellompi

Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss

显然正确的代码会产生:

Hello world, I'm process 0 of 7 and I'm the boss
Hello world, I'm process 1 of 7 
Hello world, I'm process 2 of 7 
Hello world, I'm process 3 of 7 
Hello world, I'm process 4 of 7 
Hello world, I'm process 5 of 7 
Hello world, I'm process 6 of 7 
Hello world, I'm process 7 of 7 

显然我需要卸载 OpenMPI,MPI 然后安装正确的 MPI... 我该怎么做?

哦,是的,这就是我跑步时得到的:

cat /proc/cpuinfo | grep processor

processor      :0
processor      :1
processor      :2
processor      :3
processor      :4
processor      :5
processor      :6
processor      :7

另外,即使当我使用 mpirun -np 2 时,我也不会有任何不同

所以我 sudo apt-get remove mpi

然后它看起来像卸载但我运行

mpich版本

仍然获得 3.0.1 版本

【问题讨论】:

标签: parallel-processing mpi


【解决方案1】:

好的,是的,我卸载了 OpenMPI,它立即工作

sudo apt-get remove openmpi-common

我首先卸载然后重新安装了 MPI,但没有任何效果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-14
    • 1970-01-01
    • 2019-10-04
    • 1970-01-01
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    相关资源
    最近更新 更多