---
title: 'OpenMPI Library'
published: true
taxonomy:
category:
- docs
external_links:
process: true
title: false
no_follow: true
target: _blank
mode: active
---
[toc]
## Environment Settings{#environment}
### Software Version and System Requirements{#version}
Version| Module file Name | System A | System B/C | System G | Cloud System| Notes
--- | --- | --- | --- | --- | --- | ---
4.1.5 | openmpi/4.1.5_nvhpc-23.9 | - | -| + | - | Introduced in April 2024
4.1.5 | openmpi/4.1.5_nvhpc-23.5 | - | -| + | - | Introduced in August 2023
4.0.5 | openmpi/4.0.5_intel-2022.3 | + | + | - | + | Introduced in June 2023
4.0.5 | openmpi/4.0.5_gnu-8.5.0 | + | + | + | + | Introduced in November 2022
4.0.5 | openmpi/4.0.5_nvhpc-22.9 | - | -| + | - | Introduced in November 2022
4.0.5 | openmpi/4.0.5_nvhpc-22.5 | - | -| + | - | Introduced in November 2022
\+ : Available for all users
\- : Not available
<!--
OpenMPIは[NVIDIA HPC SDKコンパイラ](/compilers/nvidia)、[GNUコンパイラ](/compilers/gnu)で利用できます。
-->
<!--
コンパイラは、
[Intelコンパイラ](/compilers/intel) 、 [NVIDIA HPC SDKコンパイラ](/compilers/nvidia) 、 [GNUコンパイラ](/compilers/gnu) を利用できます。利用するコンパイラに合わせて、以下のようにmoduleコマンドを実行し、OpenMPIが利用できるように環境を設定します。
```nohighlight
(Intelコンパイラを利用する場合)
$ module switch PrgEnv(現在ロード中の環境) PrgEnvIntel
$ module load openmpi/4.1.4_intel-17.0
(PGIコンパイラを利用する場合)
$ module switch PrgEnv(現在ロード中の環境) PrgEnvNvidia
$ module load openmpi/4.1.4_nvidia-16.10
(GNUコンパイラを利用する場合)
$ module switch PrgEnv(現在ロード中の環境) PrgEnvGCC
$ module load openmpi/4.1.4_gnu-4.8
```
moduleコマンドの詳細は [Modules](/config/modules) をご覧ください。
-->
### Level of Thread Parallel Support{#threadsafe}
The thread parallel support level available in Open MPI is MPI_THREAD_MULTIPLE. MPI functions can be called from each thread with no restriction.
## How to Compile and Execute{#usage}
### How to Compile{#compile}
**Compile commands **
Language | Command | Operands
--------- | -------- | --------------------------
Fortran | mpifort | mpifort Option File Name
C | mpicc | mpicc Option File Name
C++ | mpic++ | mpic++ Option File Name
**Examples of Compiling**
```nohighlight
$ mpifort -O3 sample_mpi.f90
```
### How to Execute{#exec}
To execute the compiled MPI program, use **tssrun** command for interactive processing and **srun** for batch processing. For both interactive processing and batch processing, the number of parallelism is specified by the --rsc option argument p. Please refer to [sample](#sample) for details.
<!--
また、OpenMPなどのスレッド並列と組み合わせて実行する場合は、1ノードあたりに起動するプロセス数を --ntasks-per-node オプションで指定します。
-->
**Example (interactive processing)**
```nohighlight
$ tssrun --rsc p=2 ./a.out
```
## Sample{#sample}
### MPI program execution with interactive processing{#tss}
Please refer to the [Interactive Processing](/run/interactive) for details on the execution with interactive processing.
* **Execute in 8 parallels**
```nohighlight
$ tssrun --rsc p=8 ./a.out
```
* **Execute in combination with thread parallelism(MPI 4 parallel, OpenMP 8 parallel)**
```nohighlight
$ tssrun --rsc p=4:t=8:c=8 ./a.out
```
### MPI program execution in batch{#slurm}
Please refer to the [batch processing](/run/batch) for details on the batch execution.
* **Execute in 8 parallels**
```nohighlight
$ cat sample.sh
#!/bin/bash
#============ SBATCH Directives =======
#SBATCH -p gr19999b
#SBATCH -t 1:0:0
#SBATCH --rsc p=8
#SBATCH -o %x.%A.out
#============ Shell Script ============
srun ./a.out
$ sbatch sample.sh
```
* **Execute in combination with thread parallelism(MPI 4 parallel, OpenMP 8 parallel)**
```nohighlight
$ cat sample.sh
#!/bin/bash
#============ SBATCH Directives =======
#SBATCH -p gr19999b
#SBATCH -t 1:0:0
#SBATCH --rsc p=4:t=8:c=8:m=8G
#SBATCH -o %x.%A.out
#============ Shell Script ============
srun ./a.out
$ sbatch sample.sh
```
## Manual{#manual}
* [Open MPI v4.0 documentation](https://www.open-mpi.org/doc/v4.0/)
## Link{#link}
* [Open MPI: Open Source High Performance Computing](http://www.open-mpi.org/)