ぶろぐめんどくさい

技術系の記事と漫画レビューが入り混じった混沌

OpenMPIをGitHubからインストールする手順(for winBash, Ubuntu)

OpenMPIの最新版をインストールしたい。 tarなんちゃらをwgetするんじゃなくってGitHubからソースを引っ張ってきてインストールしたい。

環境は以下の通り。

環境 : Bash on Ubuntu on Windows

要はUbuntuと変わらない。

OpenMPIのリポジトリこちら。

https://github.com/open-mpi/ompi

インストールの詳細はルートディレクトリにあるファイルINSTALLに記述されている。

以下は、簡単なインストール手順。

  1. git clone https://github.com/open-mpi/ompi # ソースのダウンロード
  2. cd ompi #ディレクトリ移動 1../autogen.pl # configure生成
  3. ./configure --prefix=$HOME/usr# Makefile生成
    • (prefixを指定しない->usr/localに)
    • $HOME/usrを指定した理由 qiita.com
    • (flexがない->sudo apt-get install flex)
  4. make all install # インストー

サンプルを使って実行できるか試してみよう。

  1. cd exsample
  2. mpicc ring_c.c # コンパイル
  3. mpirun -np 4 ./a.out # 実行
mpirun -np 4 ./a.out
Process 0 sending 10 to 1, tag 201 (4 processes in ring)
Process 0 sent to 1
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
Process 2 exiting
Process 3 exiting
Process 1 exiting

わーい!やったー!すごーい! このプログラムは『send a trivial message around in a ring 』するんだって! すごーい! ちなみにhello_cはエラーが出てコンパイルできなかったよ!なんでー? oshmem_*のコンパイルにはshmem.hが必要なんだってー!すごーい!

ちなみにMPIのバージョンは1.6.5。 バージョン確認にはompi_infoを使うよ。