关于lenovo thinkpad的Ubuntu 12.04中的MPI输出问题

时间:2014-04-30 04:01:46

标签: c linux ubuntu mpi

我使用openMPI为MPI编程。这是我正在尝试执行的程序的代码片段。

#include <stdio.h>
#include <mpi.h>
int main (argc, argv)
    int argc;
    char *argv[];
{
    int rank, size;
    MPI_Init (&argc, &argv);    /* starts MPI */
    MPI_Comm_rank (MPI_COMM_WORLD, &rank);  /* get current process id */
    MPI_Comm_size (MPI_COMM_WORLD, &size);  /* get number of processes */
    printf( "Hello world from process %d of %d\n", rank, size );
    MPI_Finalize();
    return 0;
}

但是,当我使用命令mpirun -np 2 ./mpi为2个进程运行程序时,我得到了两个进程的输出,但两者都只给出了进程0。这是我的输出代码段:

Hello world from process 0 of 1

Hello world from process 0 of 1

有谁能告诉我这个问题的原因。我在联想thinkpad SL410系列上使用Ubuntu 12.04。 感谢。

0 个答案:

没有答案
相关问题