期待される出力を取得するにはどうすればよいですか
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@hustlenbustle:~$ mpicc ranktest.c
tsbertalan@hustlenbustle:~$ mpirun -np 2 ./a.out
rank 0
size 1
rank 0
size 1
別のホストの場合:
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-default-hostfileと/etc/openmpi/openmpi-mca-params.confの両方に、両方のホストに関するコメントしか含まれていません。ここで何が違うのでしょうか?
に変更するMPI_Init(&argc, &argv)
か、あるいは、変更してint main()
も何も起こりません。
user3469194のおかげで本当の問題:
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
(さらにはるかに)
いくつかの提案への回答:(このgithubリポジトリ を参照してください。2012年12月1日にコミットします。)
MPI_Init()の前にworld_rankとworld_sizeの定義を移動してみてください、それは何かを変更しますか?
当然、これはあまりうまく機能しません:
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でコンパイルされたプログラムを別のMPirunで実行する際の問題です。最初のマシン(hustlenbustle)にもmpich2がインストールされていますか?物事は道のどこに現れますか?特に、との結果は何
which mpicc
ですかwhich 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
そして、シグルについては、hnbとperrinの適性検索の出力を次に示します。他に何か検索する必要があるかどうか教えてください。
Open MPIで、次のコマンドでバージョンを出力します
mpirun -V
。印刷されない場合mpiexec (OpenRTE) 1.x.x.
は、実行時間の不一致がある可能性があります。
tsbertalan@hustlenbustle:~$ mpirun -V
mpirun (Open MPI) 1.4.3
tsbertalan@perrin:~/svn/524hw4$ mpirun -V
mpirun (Open MPI) 1.4.1
ただし、テストごとに再コンパイルしています。
おそらくsudo aptitude reinstall SOMETHING
役立つかもしれませんか?