Tutorials
Note
Before going through the examples, read and follow the instructions in the Getting Started page.
Get cluster info
Get the list of available partitions:
sinfo -s
Get the list of nodes in a partition:
sinfo --Node --partition levante
Get info about a specific node:
scontrol show node e1wn1
Build and run an MPI program
Start an interactive shell section:
srun --mpi=pmix --ntasks=4 --nodes=1 --partition=levante --pty bash
Clone this MPI example project:
git clone https://github.com/mpitutorial/mpitutorial
cd mpitutorial/tutorials/mpi-hello-world/code
Load the OpenMPI environment module:
module load openmpi
which mpicc
Build the binary for the mpi_hello_world.c script (the --showme option only shows the include files for debug purposes):
mpicc -o mpi_hello_world mpi_hello_world.c --showme
mpicc -o mpi_hello_world mpi_hello_world.c
exit
From the Magellano shell, run the MPI program interactively:
srun --mpi=pmix --ntasks=4 --nodes=1 --partition=levante ./mpi_hello_world
Submit a batch job
Copy the following script to a mpi_test.batch file in your home directory:
1#!/bin/bash
2
3#SBATCH --job-name=mpi_test # Name of the job
4
5#SBATCH --partition=levante # Slurm partition as show by sinfo
6#SBATCH --time=00:05:00 # Maximum job walltime (default = 24h)
7
8#SBATCH --nodes=4 # Minimum number of nodes (default = 1)
9#SBATCH --ntasks-per-node=2 # Number of task per node (default = 1)
10#SBATCH --ntasks=8 # Total number of tasks = nodes * ntasks-per-node (default = 1)
11#SBATCH --cpus-per-task=1 # Number of logical cores per task (default = 1)
12#SBATCH --hint=nomultithread # Prevent multithreading and only use physical cores
13#SBATCH --mem-per-cpu=1GB # Real memory per allocated CPU (default = 1024MB)
14
15# This is where the .out and .err files will be saved
16#SBATCH --chdir=$HOME/mpitutorial/tutorials/mpi-hello-world/code
17#SBATCH --error=mpi_test_%j.err # Error file
18#SBATCH --output=mpi_test_%j.out # Stdout file
19
20# Print the hostname of the rank 0 process
21hostname
22
23# Print the current working directory
24pwd
25
26cd $HOME/mpitutorial/tutorials/mpi-hello-world/code/
27srun --mpi=pmix mpi_hello_world
28
29sleep 120
Submit the batch job:
sbatch ./mpi_test.batch
Monitor your jobs
Check the queue and take note of the JOBID:
squeue -u $USER
export JOBID= ...
Get info about the job:
scontrol show job $JOBID
sacct -j $JOBID --format JobID,JobName,State,Start,End,Elapsed
seff $JOBID
Cancel a job:
scancel -u $USER $JOBID
Cancel all your jobs:
scancel -u $USER