{"id":9233,"date":"2025-04-02T15:36:16","date_gmt":"2025-04-02T14:36:16","guid":{"rendered":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=9233"},"modified":"2026-02-23T16:26:39","modified_gmt":"2026-02-23T16:26:39","slug":"parallel-jobs-slurm","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/batch-slurm\/parallel-jobs-slurm\/","title":{"rendered":"Parallel Jobs (Slurm)"},"content":{"rendered":"<h2>Parallel batch job submission (Slurm)<\/h2>\n<p>For jobs that require 2-168 CPU cores &#8211; running on one AMD Genoa compute node. A jobscript template is shown below. Please also consult the <a href=\"\/csf3\/batch-slurm\/partitions\">Partitions<\/a> page for details on available compute resources.<\/p>\n<p><em><strong>Please also consult the <a href=\"\/csf3\/software\/applications\">software page<\/a> for the code \/ application you want to use, for advice on running that application<\/strong><\/em>.<\/p>\n<p>A parallel job script will run in the directory (folder) from which you submit the job.<\/p>\n<h3>MPI parallel apps<\/h3>\n<p>The jobscript takes the form:<\/p>\n<pre>\r\n#!\/bin\/bash --login\r\n#SBATCH -p multicore  # Partition is <strong>required<\/strong>. Runs on an <strong>AMD Genoa<\/strong> hardware.\r\n#SBATCH -n <em>numcores<\/em>   # (or --ntasks=) where <em>numcores<\/em> is between 2 and 168.\r\n#SBATCH -t 4-0        # Wallclock limit (days-hours). <strong>Required!<\/strong>\r\n                      # Max permitted is 7 days (7-0).\r\n\r\n# Load any required modulefiles. A purge is used to start with a clean environment.\r\nmodule purge\r\nmodule load <em>apps\/some\/example\/1.2.3<\/em>\r\n\r\n<strong>### MPI jobs ###<\/strong>\r\n# mpirun will run $SLURM_NTASKS (-n above) MPI processes\r\nmpirun <em>mpi-app.exe<\/em>\r\n<\/pre>\n<h3>OpenMP parallel apps<\/h3>\n<p>Here we request 1 &#8220;task&#8221; (process, or copy of your executable running) and multiple CPUs per task. <\/p>\n<p>On the CSF, this is functionally equivalent to the above jobscript, which simply uses <code>-n <em>numcores<\/em><\/code>, so you can use either. In fact, many of our jobscript examples in the <a href=\"\/csf3\/software\/applications\">software pages<\/a> use only <code>-n<\/code> to specify the number of cores. But this is because jobs in the <code>multicore<\/code> partition are single-node jobs. Slurm can distribute the <code>-n<\/code> cores across all of the compute nodes in a job, but in this case there is only ever one compute node.<\/p>\n<p>If you use the Slurm <code>srun<\/code> starter to run your executable inside the batch job (optional, and in most cases we don&#8217;t use this) then the distinction between <code>-n<\/code> and <code>-c<\/code> is important.<\/p>\n<pre>\r\n#!\/bin\/bash --login\r\n#SBATCH -p multicore  # Partition is <strong>required<\/strong>. Runs on an <strong>AMD Genoa<\/strong> hardware.\r\n#SBATCH -n 1          # (or --ntasks=) The default is 1 so this line can be omitted.\r\n#SBATCH -c <em>numcores<\/em>   # (or --cpus-per-task) where <em>numcores<\/em> is between 2 and 168\r\n#SBATCH -t 4-0        # Wallclock limit (days-hours). <strong>Required!<\/strong>\r\n                      # Max permitted is 7 days (7-0).\r\n\r\n# Load any required modulefiles. A purge is used to start with a clean environment.\r\nmodule purge\r\nmodule load <em>apps\/some\/example\/1.2.3<\/em>\r\n\r\n<strong>### OpenMP jobs ###<\/strong>\r\n# OpenMP code will use $SLURM_CPUS_PER_TASK cores (-c above)\r\nexport OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK\r\nomp-app.exe\r\n<\/pre>\n<h3>MPI+OpenMP mixed-mode apps<\/h3>\n<p>Here we run a small number of MPI processes, and each one of those will run OpenMP threads to do multi-core processing. This type of job is mostly run in the <a href=\"\/csf3\/hpc-pool\/jobs\">HPC Pool<\/a> because it is more suited to multi-node jobs. Remember that the <code>multicore<\/code> partition can only run single-node jobs.<\/p>\n<pre>\r\n#!\/bin\/bash --login\r\n#SBATCH -p multicore  # Partition is <strong>required<\/strong>. Runs on an <strong>AMD Genoa<\/strong> hardware.\r\n#SBATCH -n <em>numtasks<\/em>   # (or --ntasks=) Number of MPI processes (e.g., 4)\r\n#SBATCH -c <em>numcores<\/em>   # (or --cpus-per-task) Number of OpenMP threads per MPI process (e.g., 42)\r\n                      # This will use <em>numtasks<\/em> x <em>numcores<\/em> cores in total (e.g., 168)\r\n#SBATCH -t 4-0        # Wallclock limit (days-hours). <strong>Required!<\/strong>\r\n                      # Max permitted is 7 days (7-0).\r\n\r\n# Load any required modulefiles. A purge is used to start with a clean environment.\r\nmodule purge\r\nmodule load <em>apps\/some\/example\/1.2.3<\/em>\r\n\r\n<strong>### OpenMP ###<\/strong>\r\n# Each MPI process uses OpenMP to run on $SLURM_CPUS_PER_TASK cores (-c above)\r\nexport OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK\r\n\r\n<strong>### MPI ###<\/strong>\r\n# The MPI application is then started with $SLURM_NTASKS processes (copies of the app)\r\n# We inform MPI how many cores each MPI process should bind to so that OpenMP can use them.\r\nmpirun --map-by ppr:${SLURM_NTASKS}:node:pe=$OMP_NUM_THREADS mix-mode-app.exe\r\n<\/pre>\n<h2>Available Hardware and Resources<\/h2>\n<p>Please see the <a href=\"\/csf3\/batch-slurm\/partitions\">Partitions<\/a> page for details on available compute resources.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parallel batch job submission (Slurm) For jobs that require 2-168 CPU cores &#8211; running on one AMD Genoa compute node. A jobscript template is shown below. Please also consult the Partitions page for details on available compute resources. Please also consult the software page for the code \/ application you want to use, for advice on running that application. A parallel job script will run in the directory (folder) from which you submit the job&#8230; <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/batch-slurm\/parallel-jobs-slurm\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":9105,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-9233","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=9233"}],"version-history":[{"count":18,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9233\/revisions"}],"predecessor-version":[{"id":11924,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9233\/revisions\/11924"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9105"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=9233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}