问题描述
我在读和教程练习MPI程序。在那里,我看到了寻找过程的秩的一个例子。但是,同样的例子是我的机器(Ubuntu的10.04)上提供不同的输出..
下面是节目
I was reading and practicing MPI programs from a tutorial. There I saw an example of finding a rank of a process. But the same example is giving different output on my machine(Ubuntu 10.04)..Here is the program
#include <stdio.h>
#include <mpi.h>
main(int argc, char **argv)
{
int ierr, num_procs, my_id;
ierr = MPI_Init(&argc, &argv);
/* find out MY process ID, and how many processes were started. */
ierr = MPI_Comm_rank(MPI_COMM_WORLD, &my_id);
ierr = MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
printf("Hello world! I'm process %i out of %i processes\n",
my_id, num_procs);
ierr = MPI_Finalize();
}
根据本教程的预期成果是
The expected output according to the tutorial is
期望输出:
Hello world! I'm process 0 out of 4 processes.
Hello world! I'm process 2 out of 4 processes.
Hello world! I'm process 1 out of 4 processes.
Hello world! I'm process 3 out of 4 processes.
输出,我正在
Hello world! I'm process 0 out of 1 processes
Hello world! I'm process 0 out of 1 processes
Hello world! I'm process 0 out of 1 processes
Hello world! I'm process 0 out of 1 processes
我的机器采用了英特尔酷睿i3,戴尔Inspiron并有Ubuntu的10.04 OS.Help我解决问题。
My machine uses intel i3,Dell Inspiron and is having Ubuntu 10.04 OS.Help me resolving the problem.
推荐答案
我刚才编译和在我的Ubuntu运行您的程序:
I have just compiled and run your program on my Ubuntu:
tom@tom-ThinkPad-T500:~/MPI_projects/Start/net2/net2/bin/Debug$ mpirun -n 6 ./output
Hello world! I'm process 3 out of 6 processes
Hello world! I'm process 4 out of 6 processes
Hello world! I'm process 0 out of 6 processes
Hello world! I'm process 2 out of 6 processes
Hello world! I'm process 1 out of 6 processes
Hello world! I'm process 5 out of 6 processes
您的可执行文件输入文件夹,然后运行:
Enter the folder with your executable file and run:
的mpirun -np 2 ./output
或
的mpirun -np 6 ./output
-np修改称为进程数的标志()。
the flag -np modifies the number of called processes (http://linux.die.net/man/1/mpirun).
您还可以运行的mpirun
不带任何标志显示很多有用的信息。
You can also run mpirun
without any flags to display lots of useful info.
另一个有趣的命令是的mpirun -info
,它会显示打印MPI构建信息。
Another interesting command is mpirun -info
, which will show print MPI build information.
这是我的输出的第一部分:
This is the first part of my output:
tom@tom-ThinkPad-T500:~/MPI_projects/Start/net2/net2/bin/Debug$ mpirun -info
HYDRA build details:
Version: 1.4.1
Release Date: Wed Aug 24 14:40:04 CDT 2011
最后的手段是重新安装或更新使用MPI例如,下面的命令:命令和apt-get安装libcr-dev的MPICH2 MPICH2-DOC
这篇关于MPI意外的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!