LoginSignup
1
1

More than 5 years have passed since last update.

Open MPI > サンプルプログラムのコンパイル > 成功 x2 + 失敗 x1

Last updated at Posted at 2018-02-21
動作環境
CentOS 6.8 (64bit)
on VMWare workstation
for WRF3.9, WPS3.9
  Open MPI v2.1.1
  gcc version 4.9.2 (とgfortran; devtoolset-3使用)
 NetCDF v4.4.1.1, NetCDF (Fortran API) v4.4.4

関連

openmpi > ./configure ... > "/lib/cpp" fails sanity check > g++コマンドがない

OpenMPIの動作確認

成功

OpenMPIをインストールした環境でMPIのコードを実行しようとした。

https://github.com/open-mpi/ompi/blob/master/examples/ring_c.c
は実行できた。

$ mpic++ ring_c.c 
$ ./a.out 
Process 0 sending 10 to 0, tag 201 (1 processes in ring)
Process 0 sent to 0
Process 0 decremented value: 9
Process 0 decremented value: 8
Process 0 decremented value: 7
Process 0 decremented value: 6
Process 0 decremented value: 5
Process 0 decremented value: 4
Process 0 decremented value: 3
Process 0 decremented value: 2
Process 0 decremented value: 1
Process 0 decremented value: 0
Process 0 exiting

失敗1 > 成功

OpenMPIのCentOSへのインストールから実行まで
のhello.cppはコンパイルの段階で以下のようになった。

$ mpic++ hello.cpp 
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:10:34: error: ‘rank’ was not declared in this scope
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
                                  ^
hello.cpp:11:34: error: ‘size’ was not declared in this scope
   MPI_Comm_size(MPI_COMM_WORLD, &size);
                                  ^

(追記 2018/02/22)
記事元に修正が入りました。
修正後のコードはビルドおよび実行できました。

$ mpic++ hello.cpp
$ ./a.out 
rank = 0
size = 1

失敗2

MPIの環境構築や基本コマンドのまとめ
のsample.cは以下のようになった。

$ mpic++ sample.c 
sample.c: In function ‘int main(int, char**)’:
sample.c:12:44: error: cannot convert ‘char**’ to ‘char*for argument ‘1’ to ‘int MPI_Get_processor_name(char*, int*)’
   MPI_Get_processor_name(name, &name_length);   // ホスト名の取得 
                                            ^

備考

とりあえずring_c.c は実行できる状態なので、作業を進める。

2年前にセットアップした時は何でチェックをしたかは記載漏れしている。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1