我怎样才能获得预期的输出MPI_Comm_rank始终写入0
rank 0
size 2
rank 1
size 2
或这些线路的某个置换?
ranktest.c
#include <mpi.h>
#include <stdio.h>
int main(int argc, char *argv[]){
MPI_Init(NULL, NULL);
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
printf("rank %d\n", world_rank);
printf("size %d\n", world_size);
MPI_Finalize();
return 0;
}
编译和运行
[email protected]:~$ mpicc ranktest.c
[email protected]:~$ mpirun -np 2 ./a.out
rank 0
size 1
rank 0
size 1
在不同的主机上:
[email protected]:~$ mpicc ranktest.c
[email protected]:~$ mpirun -np 2 ./a.out
rank 0
size 2
rank 1
size 2
我已经试过
[email protected]:~$ sudo aptitude reinstall openmpi-bin libopenmpi-dev
但没有任何变化。/etc/openmpi/openmpi-default-hostfile和/etc/openmpi/openmpi-mca-params.conf都只包含两个主机上的注释。这里可能有什么不同?
更改为MPI_Init(&argc, &argv)
,或者,int main()
也不做任何事情。
真正的问题,这要归功于user3469194:
[email protected] ~ $ sudo aptitude remove libopenmpi-dev mpich2
[email protected] ~ $ sudo aptitude install libmpich2-dev openmpi-bin
[email protected] ~ $ mpicc ranktest.c
[email protected] ~ $ mpirun -np 2 ./a.out
rank 0
size 1
rank 0
size 1
[email protected] ~ $ sudo aptitude remove libmpich2-dev openmpi-bin
[email protected] ~ $ sudo aptitude install libopenmpi-dev mpich2
[email protected] ~ $ mpicc ranktest.c
[email protected] ~ $ mpirun -np 2 ./a.out
[linuxmint:16539] [[INVALID],INVALID] ORTE_ERROR_LOG: A system-required executable either could not be found or was not executable by this user in file ../../../../../../orte/mca/ess/singleton/ess_singleton_module.c at line 357
(加得多)
回应一些建议: (见this github repo,承诺为12月1日,2012年)
尝试移动world_rank和world_si的定义在MPI_Init()之前,它会改变什么吗?或者
[email protected]:~/svn/524hw4$ git checkout 7b5e229 ranktest.c (reverse-i-search)`clean': [email protected]:~/Documents/School/12fall2012/524apc524/hw/hw4$ make ^Cean && make ranktest && mpirun -np 2 ranktest [email protected]:~/svn/524hw4$ make clean && make ranktest && mpirun -np 2 ranktest rm -f heat_serial heat_omp heat_mpi heat_serial_O* ranktest mpicc ranktest.c -o ranktest *** An error occurred in MPI_Comm_rank *** before MPI was initialized *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort) [perrin:15206] Abort before MPI_INIT completed successfully; not able to guarantee that all other processes were killed! *** An error occurred in MPI_Comm_rank *** before MPI was initialized *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort) [perrin:15207] Abort before MPI_INIT completed successfully; not able to guarantee that all other processes were killed! [email protected]:~/svn/524hw4$ git checkout HEAD ranktest.c
,我家的电脑上:
当然,这并不工作这么好
[email protected]:~/Documents/School/12fall2012/524apc524/hw/hw4$ git checkout 7b5e229 ranktest.c
[email protected]:~/Documents/School/12fall2012/524apc524/hw/hw4$ vim ranktest.c
[email protected]:~/Documents/School/12fall2012/524apc524/hw/hw4$ make clean && make ranktest && mpirun -np 2 ranktest
rm -f heat_serial heat_omp heat_mpi heat_serial_O* ranktest
mpicc ranktest.c -o ranktest
Attempting to use an MPI routine before initializing MPICH
Attempting to use an MPI routine before initializing MPICH
[email protected]:~/Documents/School/12fall2012/524apc524/hw/hw4$ git checkout HEAD ranktest.c
这几乎总是被编译运行的程序的问题一个MPI与另一个MPIRUN。第一台机器(hustlenbustle)是否也安装了mpich2?事情在路上出现在哪里?特别是
which mpicc
和which mpirun
的结果是什么?
我在每次尝试之前,在每台计算机上重新编译。我继续和made a make target为此。然而,由于每个请求:
[email protected]:~$ which mpicc
/usr/bin/mpicc
[email protected]:~$ which mpirun
/usr/bin/mpirun
[email protected]:~/svn/524hw4$ which mpicc
/usr/bin/mpicc
[email protected]:~/svn/524hw4$ which mpirun
/usr/bin/mpirun
而且,对于shiggles,这里是一些资质搜索hnb和perrin输出。让我知道我是否应该寻找别的东西。
在开放MPI以下命令应打印出的版本:
mpirun -V
。如果它不打印mpiexec (OpenRTE) 1.x.x.
那么你可能会有运行时间不匹配。
[email protected]:~$ mpirun -V
mpirun (Open MPI) 1.4.3
[email protected]:~/svn/524hw4$ mpirun -V
mpirun (Open MPI) 1.4.1
不过,我重新编译为每个测试。
也许sudo aptitude reinstall SOMETHING
可能有帮助吗?
尝试在'MPI_Init()'之前移动'world_rank'和'world_size'的定义,它会改变什么吗? –
这几乎总是一个用另一个mpirun运行用一个MPI编译的程序的问题。第一台机器(hustlenbustle)是否也安装了mpich2?事情在路上出现在哪里?特别是,mpicc和mpirun的结果是什么? –
在Open MPI下,以下命令应该输出版本:'mpirun -V'。如果它不打印'mpiexec(OpenRTE)1.x.x.',那么你可能会遇到运行时间不匹配。 –