Attention

Following the recent operating system upgrade, software listings and module load commands now reflect the upgraded system. Some examples and notices are still being updated and may contain outdated guidance.

OpenMPI

Guidance last updated: 14 October 2026

The OpenMPI Project is an open source Message Passing Interface implementation that is developed and maintained by a consortium of academic, research, and industry partners. OpenMPI is therefore able to combine the expertise, technologies, and resources from all across the High Performance Computing community in order to build the best MPI library available. OpenMPI offers advantages for system and software vendors, application developers and computer science researchers.

Versions

After connecting to Stanage (see Establishing a SSH connection), start an interactive session with the following command:

srun --pty bash -i

You can load a specific version using one of the following:

module load OpenMPI/5.0.10-GCC-15.2.0
module load OpenMPI/5.0.8-GCC-14.3.0
module load OpenMPI/5.0.3-GCC-13.3.0
module load OpenMPI/4.1.6-GCC-13.2.0
module load OpenMPI/4.1.5-GCC-12.3.0
module load OpenMPI/4.1.4-GCC-12.2.0
module load OpenMPI/4.1.4-GCC-12.2.0-custom

See matching foss toolchains

The examples below use OpenMPI/5.0.10-GCC-15.2.0, which also loads GCC 15.2.0. Compile and run your program using the same OpenMPI module.

See the OpenMPI release notes for changes between versions.

Example

Consider the following source code hello.c:

#include <mpi.h>
#include <stdio.h>

int main(int argc, char** argv) {
    // Initialize the MPI environment
    MPI_Init(&argc, &argv);

    // Get the number of processes
    int world_size;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

    // Get the rank of the process
    int world_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    // Get the name of the processor
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(processor_name, &name_len);

    // Print off a hello world message
    printf("Hello world from processor %s, rank %d out of %d processors\n",
           processor_name, world_rank, world_size);

    // Finalize the MPI environment.
    MPI_Finalize();
}

MPI_COMM_WORLD includes all ranks in the job; MPI_Comm_size returns their number.

Compile your source code by using the following command:

module load OpenMPI/5.0.10-GCC-15.2.0
mpicc hello.c -o hello

Note

mpicc wraps the C compiler with the MPI headers and libraries. For C++ source, use mpicxx or mpiCC.

Interactive job submission

You can run your job interactively (from a login node):

srun --ntasks=1 --cpus-per-task=1 --mem=512M --time=00:05:00 ./hello

Your output would be something like:

Hello world from processor node003.pri.stanage.alces.network, rank 0 out of 1 processors

This is an expected behaviour since by default interactive jobs get allocated one single-CPU-core task running on one node. You can request an interactive job with multiple concurrent single-CPU-core tasks (4 in this example) by using this command (from a login node):

srun --nodes=1 --ntasks=4 --cpus-per-task=1 --mem=2G --time=00:05:00 ./hello

Your output would be something like:

Hello world from processor node003.pri.stanage.alces.network, rank 3 out of 4 processors
Hello world from processor node003.pri.stanage.alces.network, rank 1 out of 4 processors
Hello world from processor node003.pri.stanage.alces.network, rank 0 out of 4 processors
Hello world from processor node003.pri.stanage.alces.network, rank 2 out of 4 processors

Please note that requesting multiple cores in an interactive node depends on the availability. During peak times, it is unlikely that you can successfully request a large number of CPU cores interactively. Therefore, it is usually sensible to run MPI workloads as batch jobs.

Non-interactive job submission

The following example batch submission scripts run the compiled hello program with four MPI ranks. Submit from the directory containing hello.

Save as test.sh:

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --cpus-per-task=1
#SBATCH --mem=2G
#SBATCH --time=00:05:00

set -e
export SLURM_EXPORT_ENV=ALL
module load OpenMPI/5.0.10-GCC-15.2.0

srun --export=ALL ./hello

Submit your script with:

sbatch test.sh

Each rank prints its hostname and rank number. With multiple nodes, the output includes both hostnames; the order of messages may vary.

The module selects Slurm’s PMIx launch support, so no additional MPI environment settings are needed. Keep --export=ALL so the job step inherits the module environment.

Installation notes

This section is primarily for administrators. EasyBuild hooks enable Slurm and PMIx support and configure the module to use LibFabric (OFI) with its PSM2 provider for Omni-Path communication. The latest module sets:

  • SLURM_MPI_TYPE=pmix

  • OMPI_MCA_pml=cm

  • OMPI_MCA_mtl=ofi

  • OMPI_MCA_mtl_ofi_provider_include=psm2

  • OMPI_MCA_btl=^ofi

The OFI BTL is excluded to avoid allocating additional Omni-Path HFI contexts alongside the OFI MTL. The latest module does not force PMIX_MCA_psec=native; that setting is retained in the current hook for OpenMPI 4.1.4 compatibility.

OpenMPI was installed using Easybuild, build details can be found in $EBROOTOPENMPI/easybuild with a given module loaded.

Direct dependencies for latest version of OpenMPI