Tutorials ========= .. Note:: Before going through the examples, read and follow the instructions in the `Getting Started <../getting_started>`__ page. Get cluster info ----------------------------------- Get the list of available partitions: .. code-block:: bash sinfo -s Get the list of nodes in a partition: .. code-block:: bash sinfo --Node --partition levante Get info about a specific node: .. code-block:: bash scontrol show node e1wn1 Build and run an MPI program ----------------------------- Start an interactive shell section: .. code-block:: bash srun --mpi=pmix --ntasks=4 --nodes=1 --partition=levante --pty bash Clone this MPI example project: .. code-block:: bash git clone https://github.com/mpitutorial/mpitutorial cd mpitutorial/tutorials/mpi-hello-world/code Load the OpenMPI environment module: .. code-block:: bash 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): .. code-block:: bash 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: .. code-block:: bash 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: .. code-block:: bash :linenos: #!/bin/bash #SBATCH --job-name=mpi_test # Name of the job #SBATCH --partition=levante # Slurm partition as show by sinfo #SBATCH --time=00:05:00 # Maximum job walltime (default = 24h) #SBATCH --nodes=4 # Minimum number of nodes (default = 1) #SBATCH --ntasks-per-node=2 # Number of task per node (default = 1) #SBATCH --ntasks=8 # Total number of tasks = nodes * ntasks-per-node (default = 1) #SBATCH --cpus-per-task=1 # Number of logical cores per task (default = 1) #SBATCH --hint=nomultithread # Prevent multithreading and only use physical cores #SBATCH --mem-per-cpu=1GB # Real memory per allocated CPU (default = 1024MB) # This is where the .out and .err files will be saved #SBATCH --chdir=$HOME/mpitutorial/tutorials/mpi-hello-world/code #SBATCH --error=mpi_test_%j.err # Error file #SBATCH --output=mpi_test_%j.out # Stdout file # Print the hostname of the rank 0 process hostname # Print the current working directory pwd cd $HOME/mpitutorial/tutorials/mpi-hello-world/code/ srun --mpi=pmix mpi_hello_world sleep 120 Submit the batch job: .. code-block:: bash sbatch ./mpi_test.batch Monitor your jobs ------------------- Check the queue and take note of the ``JOBID``: .. code-block:: bash squeue -u $USER export JOBID= ... Get info about the job: .. code-block:: bash scontrol show job $JOBID sacct -j $JOBID --format JobID,JobName,State,Start,End,Elapsed seff $JOBID Cancel a job: .. code-block:: bash scancel -u $USER $JOBID Cancel all your jobs: .. code-block:: bash scancel -u $USER