7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenMPIを使う in Julia 1.0

Last updated at Posted at 2018-08-29

最新版OpenMPIのインストール on Ubuntu 16.04

[20180908:追記]
gfortranをインストールする。これを忘れるとMPI.jlのビルドでfortran関連のエラーが出る。

Shell
$ sudo apt-get install gfortran

[20180908:追記ここまで]

Ubuntu 16.04に以下のコマンド

Shell
$ sudo apt install openmpi-doc openmpi-bin openmpi-dev

でOpenMPIをインストールした後に、Julia 1.0でMPI.jlのビルド中に以下のエラーが出た。

Error: Symbol 'mpi_no_op' at (1) has no IMPLICIT type

ここを参考にすると、どうやらapt installで入るOpenMPI(v1.8.x)が古いことが原因のようである。よってOpenMPIの公式サイトからソース(openmpi-3.1.2.tar.gz)をダウンロードしてインストールする。以下にその手順を示す。

Shell
# OpenMPIの最新版インストール
$ ./configure --prefix=/usr/local/openmpi-3.1.2 --enable-mpi-cxx --enable-mpi-cxx-seek  CC=gcc CXX=g++
$ make -j 4 all 2>&1 | tee make.log
$ sudo make -j 4 install 2>&1 | tee install.log

# .bashrcに追記
$ vi .bashrc
MPIROOT=/usr/local/openmpi-3.1.2
export PATH=$MPIROOT/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MPIROOT/lib
export MANPATH=$MANPATH:$MPIROOT/share/man

# テスト
$ mpiexec -np 4 echo Hello

MPI.jlのインストール on Julia 1.0

JuliaのREPLでMPI.jlをaddしたあとに、以下のhello_mpi.jlでテストを実行する。

hello_mpi.jl
using MPI

function main()
    # initialize
    MPI.Init()

    # establish the MPI communicator and obtain rank
    comm = MPI.COMM_WORLD
    rank = MPI.Comm_rank(comm)

    # wait not to be mixed
    sleep(rank*0.1)
    println("Hello! I am rank $(rank).")

    # finalize
    MPI.Finalize()
end

main()

コマンドは以下の通り。

Shell
$ mpiexec -np 4 julia hello_mpi.jl

各プロセスから応答が確認できれば完了である。お疲れ様でした。

7
6
0

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
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?