slurm
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| slurm [2025/06/30 10:57] – amcguire | slurm [2025/06/30 17:59] (current) – amcguire | ||
|---|---|---|---|
| Line 93: | Line 93: | ||
| < | < | ||
| - | (base) | + | amcguire@fe01: |
| #include < | #include < | ||
| #include < | #include < | ||
| Line 120: | Line 120: | ||
| MPI_Finalize(); | MPI_Finalize(); | ||
| } | } | ||
| + | amcguire@fe01: | ||
| + | #!/bin/bash | ||
| + | #SBATCH -J mpi-hello | ||
| + | #SBATCH -n 2 # Number of processes | ||
| + | #SBATCH -t 0: | ||
| + | #SBATCH -o hello-job.out | ||
| - | (base) amcguire@fe01: | + | # Disable the Infiniband transport for OpenMPI |
| - | (base) | + | #export OMPI_MCA_btl=" |
| + | |||
| + | # Run the job (assumes the batch script is submitted from the same directory) | ||
| + | mpirun -np 2 ./ | ||
| + | |||
| + | amcguire@fe01: | ||
| + | amcguire@fe01: | ||
| -rwxrwx--- 1 amcguire amcguire 16992 Jun 30 10:49 mpi-hello | -rwxrwx--- 1 amcguire amcguire 16992 Jun 30 10:49 mpi-hello | ||
| - | (base) | + | amcguire@fe01: |
| Submitted batch job 1196702 | Submitted batch job 1196702 | ||
| - | (base) | + | amcguire@fe01: |
| Hello from process 0 of 2 on host p001 | Hello from process 0 of 2 on host p001 | ||
| Hello from process 1 of 2 on host p002 | Hello from process 1 of 2 on host p002 | ||
| </ | </ | ||
| - | For convenience, | ||
| - | < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | int main(int argc, char **argv) { | ||
| - | // Initialize MPI | ||
| - | MPI_Init(& | ||
| - | |||
| - | // Get the number of processes in the global communicator | ||
| - | int count; | ||
| - | MPI_Comm_size(MPI_COMM_WORLD, | ||
| - | |||
| - | // Get the rank of the current process | ||
| - | int rank; | ||
| - | MPI_Comm_rank(MPI_COMM_WORLD, | ||
| - | |||
| - | // Get the current hostname | ||
| - | char hostname[1024]; | ||
| - | gethostname(hostname, | ||
| - | |||
| - | // Print a hello world message for this rank | ||
| - | printf(" | ||
| - | |||
| - | // Finalize the MPI environment before exiting | ||
| - | MPI_Finalize(); | ||
| - | } | ||
| - | </ | ||
| === Exclusive access to a node === | === Exclusive access to a node === | ||
| You will need to add the '' | You will need to add the '' | ||
/var/lib/dokuwiki/data/attic/slurm.1751299054.txt.gz · Last modified: 2025/06/30 10:57 by amcguire