This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
rise:ejemplos:mpi_hello [2020/07/01 01:08] fmorac created |
rise:ejemplos:mpi_hello [2020/07/01 01:20] (current) fmorac [SLURM] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Hello World, MPI & SLURM ===== | ||
| + | Esta guía provee un hello world para MPI y como correrlo usando SLURM. | ||
| + | ==== MPI ==== | ||
| + | * Código fuente de hello world: | ||
| <code c++ hello.cpp> | <code c++ hello.cpp> | ||
| #include < | #include < | ||
| Line 26: | Line 30: | ||
| MPI_Finalize(); | MPI_Finalize(); | ||
| } | } | ||
| - | |||
| </ | </ | ||
| - | < | + | * Makefile para compilar el hello world |
| + | < | ||
| all: hello-world | all: hello-world | ||
| hello-world: | hello-world: | ||
| source $$MODULESHOME/ | source $$MODULESHOME/ | ||
| - | |||
| - | run: hello-world | ||
| - | sbatch mpi.sh | ||
| clean: | clean: | ||
| rm -v hello-world | rm -v hello-world | ||
| + | </ | ||
| + | |||
| + | ==== SLURM ==== | ||
| + | Existen diversas maneras para ejecutar trabajos en SLURM, en este caso se dan dos alternativas: | ||
| + | |||
| + | === srun === | ||
| + | El siguiente comando ejecuta el hello world en la partición tara-2N-1H (-p tara-2N-1H) utilizando 2 nodos (-N 2): | ||
| + | <code bash> | ||
| + | srun -N 2 -p tara-2N-1H hello-world | ||
| + | </ | ||
| + | |||
| + | |||
| + | === sbatch === | ||
| + | Para correr el hello world usando **sbatch** es necesario crear el siguiente archivo: | ||
| + | <code bash hello-world.sbatch> | ||
| + | #!/bin/bash | ||
| + | # | ||
| + | #SBATCH --job-name=mpi-hello-world | ||
| + | #SBATCH --nodes=2 | ||
| + | #SBATCH --ntasks=1 | ||
| + | #SBATCH --time=1:00 | ||
| + | #SBATCH --partition=tara-2N-1H | ||
| + | #SBATCH --output=mpi-hello-world.txt | ||
| + | module load mpi/openmpi | ||
| + | export OMP_NUM_THREADS=2 | ||
| + | mpirun hello-world | ||
| + | </ | ||
| + | Para ejecutar el script de **sbatch** se utiliza: | ||
| + | <code bash> | ||
| + | sbatch hello-world.sbatch | ||
| </ | </ | ||