Parallel job submission with SLURM

From ScientificComputing
Jump to: navigation, search

< Submit a job

Home

Submit a GPU job >


Shared memory job (OpenMP)


Shared memory computing.png

In shared-memory parallel computing, multiple processors (or "threads") perform tasks independently but share a common global memory. If a processor modified an array in the memory, all other processors can see this update as well

  • A serial code can be parallelized by marking code sections, which should be run in parallel, with openMP directives.
  • An openMP code can run on a single compute node and use up to maximum number of processors in that compute node, e.g., 128 or 192 processors.
  • To compile an openMP code:
$ module load stack/2024-06
$ gcc -o hello_omp -fopenmp hello_omp.c
  • To run an openMP code, define number of processors(threads) in $OMP_NUM_THREADS and force the program to run on a single node (-c), where all of the cores share their memory:
$ export OMP_NUM_THREADS=8
$ sbatch -c 8 --wrap="./hello_omp"

Distributed memory job (MPI)


Distributed memory computing.png

In distributed-memory parallel computing, multiple processors (or "cores") perform tasks independently while each processor possesses its own private memory resource. If a processor modify an array in its memory, this processor has to communicate to other processors so that the others see this update.

  • Cores should be requested with the sbatch option -n (--ntasks)
  • Massage Passing Interface (MPI) library implements distributed memory parallel computing which can be programmed in C, C++ and Fortran
  • An MPI program can run on a single compute node as well as on multiple compute nodes
  • To compile an MPI code, use MPI wrappers, e.g., mpicc for C code, mpif90 for Fortran code
$ module load stack/2024-06 gcc/12.2.0 openmpi/4.1.6
$ mpicc -o mpi_hello_world mpi_hello_world.c
  • To run an MPI program, launch the program with "mpirun"
$ module load stack/2024-06 gcc/12.2.0 openmpi/4.1.6
$ sbatch -n 240 --wrap="srun ./mpi_hello_world"

Examples

Further readings

Helper


< Submit a job

Home

Submit a GPU job >