Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MPI\u Comm\u列组始终写入0_C_Openmpi_Mpich - Fatal编程技术网

MPI\u Comm\u列组始终写入0

MPI\u Comm\u列组始终写入0,c,openmpi,mpich,C,Openmpi,Mpich,如何获得预期的输出 rank 0 size 2 rank 1 size 2 还是这些线条的排列 朗克测试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_s

如何获得预期的输出

rank 0
size 2
rank 1
size 2
还是这些线条的排列

朗克测试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;
}
在其他主机上:

tsbertalan@stamp:~$ mpicc ranktest.c
tsbertalan@stamp:~$ mpirun -np 2 ./a.out 
rank 0
size 2
rank 1
size 2
我试过了

tsbertalan@hustlenbustle:~$ sudo aptitude reinstall openmpi-bin libopenmpi-dev
但一切都没有改变。/etc/openmpi/openmpi默认主机文件和/etc/openmpi/openmpi-mca-params.conf在两台主机上都只包含注释。这里可能有什么不同

更改为
MPI\u Init(&argc,&argv)
,或者更改为
int main()
,也不起任何作用

真正的问题,多亏了用户3469194:

linuxmint@linuxmint ~ $ sudo aptitude remove libopenmpi-dev mpich2
linuxmint@linuxmint ~ $ sudo aptitude install libmpich2-dev openmpi-bin
linuxmint@linuxmint ~ $ mpicc ranktest.c
linuxmint@linuxmint ~ $ mpirun -np 2 ./a.out
rank 0
size 1
rank 0
size 1
linuxmint@linuxmint ~ $ sudo aptitude remove libmpich2-dev openmpi-bin
linuxmint@linuxmint ~ $ sudo aptitude install libopenmpi-dev mpich2
linuxmint@linuxmint ~ $ mpicc ranktest.c
linuxmint@linuxmint ~ $ 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
(还有更多)

对一些建议的回应: (参见,2012年12月1日的承诺。)


尝试将world_rank和world_size的定义移到MPI_Init()之前,它会改变什么吗

当然,这不太管用:

tsbertalan@perrin:~/svn/524hw4$ git checkout 7b5e229 ranktest.c
(reverse-i-search)`clean': tsbertalan@hustlenbustle:~/Documents/School/12fall2012/524apc524/hw/hw4$ make ^Cean && make ranktest && mpirun -np 2 ranktest
tsbertalan@perrin:~/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!
tsbertalan@perrin:~/svn/524hw4$ git checkout HEAD ranktest.c
或者,在我的家用电脑上:

tsbertalan@hustlenbustle:~/Documents/School/12fall2012/524apc524/hw/hw4$ git checkout 7b5e229 ranktest.c
tsbertalan@hustlenbustle:~/Documents/School/12fall2012/524apc524/hw/hw4$ vim ranktest.c 
tsbertalan@hustlenbustle:~/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
tsbertalan@hustlenbustle:~/Documents/School/12fall2012/524apc524/hw/hw4$ git checkout HEAD ranktest.c

这几乎总是一个使用一个MPI编译的程序与另一个MPI运行的问题。第一台机器(hustlenbustle)是否也安装了mpich2?路径上的东西出现在哪里?特别是,
哪个mpicc
哪个mpirun
的结果是什么

每次尝试之前,我都会在每台计算机上重新编译。为了这个,我继续前进。但是,根据要求:

tsbertalan@hustlenbustle:~$ which mpicc
/usr/bin/mpicc
tsbertalan@hustlenbustle:~$ which mpirun
/usr/bin/mpirun

tsbertalan@perrin:~/svn/524hw4$ which mpicc
/usr/bin/mpicc
tsbertalan@perrin:~/svn/524hw4$ which mpirun
/usr/bin/mpirun
对于志贺斯来说,这里是一些能力倾向搜索和的结果。如果我需要搜索其他内容,请告诉我


在Open MPI下,以下命令应打印出版本:
mpirun-V
。如果它不打印
mpiexec(OpenRTE)1.x.x.
,则运行时间可能不匹配

但是,我正在为每个测试重新编译


也许
sudo aptitude重新安装一些东西可能会有所帮助?

在我的计算机上的一个版本的mpic.c中发现了这段代码(当我安装了一个新的程序包,它附带了mpi时,这给我带来了麻烦)。看起来你的电脑上有这样的东西,而另一台主机的版本是正确的

int MPI_Comm_rank( MPI_Comm comm, int *rank)
{
  *rank=0;
  return 0;
}

如您所见,rank总是设置为0(类似的size函数可能将变量设置为1)。

我也遇到了这个问题。问题是mpicc是OpenMPI(要看到这一点,只需运行mpicc-v),而mpirun是MPICH2(mpirun-v)。我只是通过卸载MPICH2解决了这个问题。

尝试将
world\u rank
world\u size
的定义移动到
MPI\u Init()
之前,它会改变什么吗?这几乎总是一个问题,即运行一个使用一个MPI编译的程序时,另一个MPI运行。第一台机器(hustlenbustle)是否也安装了mpich2?路径上的东西出现在哪里?特别是,哪个mpicc和哪个mpirun的结果是什么?在Open MPI下,以下命令应打印出版本:
mpirun-V
。如果它不打印
mpiexec(OpenRTE)1.x.x.
,则可能存在运行时间不匹配的问题。我对上述建议进行了回应。人力资源管理。即将尝试在hnb上重新安装某些内容。。。重新安装mpich2没有帮助。这并不能回答此问题。要评论或要求作者澄清,请在他们的帖子下方留下评论——你可以随时在自己的帖子上发表评论,一旦你有足够的评论,你就可以发表评论了。@matthias说实话,事实上,没有真正的问题。我的错;我会相应地编辑它。这似乎是我想问的问题的真正答案,在virtualbox中使用Linux Mint 16进行的测试证实libmich2 dev/openmpi bin组合是问题所在;不是libopenmpi dev/mpich2,它只是失败了。如果user34能够确认这是第一个组合,而不是第二个组合,我可以将其标记为可接受的答案。
tsbertalan@hustlenbustle:~$ mpirun -V
mpirun (Open MPI) 1.4.3

tsbertalan@perrin:~/svn/524hw4$ mpirun -V
mpirun (Open MPI) 1.4.1
int MPI_Comm_rank( MPI_Comm comm, int *rank)
{
  *rank=0;
  return 0;
}