Created
January 6, 2022 20:08
-
-
Save dtrudg/a38aaa2396774a5ed82a6d06949625e9 to your computer and use it in GitHub Desktop.
2022-01-06 SingularityCE Communit Call MPI Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mpi.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main (int argc, char **argv) { | |
int rc; | |
int size; | |
int myrank; | |
rc = MPI_Init (&argc, &argv); | |
if (rc != MPI_SUCCESS) { | |
fprintf (stderr, "MPI_Init() failed"); | |
return EXIT_FAILURE; | |
} | |
rc = MPI_Comm_size (MPI_COMM_WORLD, &size); | |
if (rc != MPI_SUCCESS) { | |
fprintf (stderr, "MPI_Comm_size() failed"); | |
goto exit_with_error; | |
} | |
rc = MPI_Comm_rank (MPI_COMM_WORLD, &myrank); | |
if (rc != MPI_SUCCESS) { | |
fprintf (stderr, "MPI_Comm_rank() failed"); | |
goto exit_with_error; | |
} | |
fprintf (stdout, "Hello, I am rank %d/%d\n", myrank, size); | |
MPI_Finalize(); | |
return EXIT_SUCCESS; | |
exit_with_error: | |
MPI_Finalize(); | |
return EXIT_FAILURE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bootstrap: docker | |
From: fedora | |
%files | |
mpitest /opt/mpitest | |
%runscript | |
/opt/mpitest | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bootstrap: docker | |
From: ubuntu:18.04 | |
%files | |
mpitest.c /opt | |
%environment | |
# Point to OMPI binaries, libraries, man pages | |
export OMPI_DIR=/opt/ompi | |
export PATH="$OMPI_DIR/bin:$PATH" | |
export LD_LIBRARY_PATH="$OMPI_DIR/lib:$LD_LIBRARY_PATH" | |
export MANPATH="$OMPI_DIR/share/man:$MANPATH" | |
%post | |
echo "Installing required packages..." | |
apt-get update && apt-get install -y wget git bash gcc gfortran g++ make file munge libmunge-dev libevent-dev libhwloc-dev zlib1g-dev | |
echo "Installing PMIx" | |
export PMIX_DIR=/opt/pmix | |
export PMIX_VERSION=3.2.2 | |
export PMIX_URL="https://github.com/openpmix/openpmix/releases/download/v$PMIX_VERSION/pmix-$PMIX_VERSION.tar.bz2" | |
mkdir -p /tmp/pmix | |
cd /tmp/pmix && wget -O pmix-$PMIX_VERSION.tar.bz2 $PMIX_URL && tar -xjf pmix-$PMIX_VERSION.tar.bz2 | |
cd pmix-$PMIX_VERSION && ./configure --with-munge --prefix=$PMIX_DIR && make -j48 install | |
unset PMIX_VERSION | |
unset PMIX_URL | |
echo "Installing Open MPI" | |
export OMPI_DIR=/opt/ompi | |
export OMPI_VERSION=4.1.1 | |
export OMPI_URL="https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-$OMPI_VERSION.tar.bz2" | |
mkdir -p /tmp/ompi | |
mkdir -p /opt | |
# Download | |
cd /tmp/ompi && wget -O openmpi-$OMPI_VERSION.tar.bz2 $OMPI_URL && tar -xjf openmpi-$OMPI_VERSION.tar.bz2 | |
# Compile and install | |
cd /tmp/ompi/openmpi-$OMPI_VERSION && ./configure --prefix=$OMPI_DIR --with-pmix=$PMIX_DIR && make -j48 install | |
# Set env variables so we can compile our application | |
export PATH=$OMPI_DIR/bin:$PATH | |
export LD_LIBRARY_PATH=$OMPI_DIR/lib:$LD_LIBRARY_PATH | |
echo "Compiling the MPI application..." | |
cd /opt && mpicc -o mpitest mpitest.c | |
%runscript | |
/opt/mpitest | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
singularity run -B /usr/lib64/openmpi,/usr/lib64/pmix,/usr/share/pmix,/usr/lib64/libhwloc.so.15,/usr/lib64/libevent_core-2.1.so.7,/usr/lib64/libevent_pthreads-2.1.so.7,/usr/lib64/libfabric.so.1,/usr/lib64/librdmacm.so.1,/usr/lib64/libucp.so.0,/usr/lib64/libpsm_infinipath.so.1,/usr/lib64/libpsm2.so.2,/usr/lib64/libefa.so.1,/usr/lib64/libosmcomp.so.5,/usr/lib64/libuct.so.0,/usr/lib64/libinfinipath.so.4,/usr/lib64/libnuma.so.1,/usr/lib64/libnl-3.so.200,/usr/lib64/libibverbs.so.1,/usr/lib64/libucm.so.0,/usr/lib64/libnl-route-3.so.200,/usr/lib64/libibumad.so.3,/usr/lib64/libucs.so.0,/usr/lib64/libpmix.so.2,/usr/lib64/libmunge.so.2 openmpi-bind.sif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment