User Tools

Site Tools


slurm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
slurm [2025/06/30 10:57] amcguireslurm [2025/06/30 17:59] (current) amcguire
Line 93: Line 93:
  
 <code> <code>
-(base) amcguire@fe01:~$ cat mpi-hello.c +amcguire@fe01:~$ cat mpi-hello.c 
 #include <mpi.h> #include <mpi.h>
 #include <unistd.h> #include <unistd.h>
Line 120: Line 120:
     MPI_Finalize();     MPI_Finalize();
 } }
 +amcguire@fe01:~$ cat hello-job.sh
 +#!/bin/bash
 +#SBATCH -J mpi-hello            # Job name
 +#SBATCH -n 2                    # Number of processes
 +#SBATCH -t 0:10:00              # Max wall time
 +#SBATCH -o hello-job.out        # Output file name
  
-(base) amcguire@fe01:~$ mpicc -o mpi-hello mpi-hello.c +# Disable the Infiniband transport for OpenMPI (not present on all clusters) 
-(base) amcguire@fe01:~$ ls -l mpi-hello+#export OMPI_MCA_btl="^openib" 
 + 
 +# Run the job (assumes the batch script is submitted from the same directory) 
 +mpirun -np 2 ./mpi-hello 
 + 
 +amcguire@fe01:~$ mpicc -o mpi-hello mpi-hello.c 
 +amcguire@fe01:~$ ls -l mpi-hello
 -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:~$ sbatch -w p001,p002 -p peanut-cpu hello-job.sh+amcguire@fe01:~$ sbatch -w p001,p002 -p peanut-cpu hello-job.sh
 Submitted batch job 1196702 Submitted batch job 1196702
-(base) amcguire@fe01:~$ cat hello-job.out +amcguire@fe01:~$ cat hello-job.out 
 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
 </code> </code>
  
-For convenience, you may download the files used here. 
-<file> 
-#include <mpi.h> 
-#include <unistd.h> 
-#include <stdio.h> 
- 
-int main(int argc, char **argv) { 
-    // Initialize MPI 
-    MPI_Init(&argc, &argv); 
- 
-    // Get the number of processes in the global communicator 
-    int count; 
-    MPI_Comm_size(MPI_COMM_WORLD, &count); 
- 
-    // Get the rank of the current process 
-    int rank; 
-    MPI_Comm_rank(MPI_COMM_WORLD, &rank); 
- 
-    // Get the current hostname 
-    char hostname[1024]; 
-    gethostname(hostname, sizeof(hostname)); 
- 
-    // Print a hello world message for this rank 
-    printf("Hello from process %d of %d on host %s\n", rank, count, hostname); 
- 
-    // Finalize the MPI environment before exiting 
-    MPI_Finalize(); 
-} 
-</file> 
 === Exclusive access to a node === === Exclusive access to a node ===
 You will need to add the ''%%--exclusive%%'' options to your script or command line options. This option will ensure that when your job runs it is the only job running on that particular node. You will need to add the ''%%--exclusive%%'' options to your script or command line options. This option will ensure that when your job runs it is the only job running on that particular node.
/var/lib/dokuwiki/data/attic/slurm.1751299054.txt.gz · Last modified: 2025/06/30 10:57 by amcguire

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki