# How do I submit an MPI/OpenMP job in a slurm cluster?

**URL:** <https://ask.cyberinfrastructure.org/t/how-do-i-submit-an-mpi-openmp-job-in-a-slurm-cluster/78>\
**Category:** Q&A\
**Tags:** slurm, mpi, scripting, scheduler, researcher\
**Created:** [March 16, 2018, 1:19am UTC](https://ask.cyberinfrastructure.org/t/how-do-i-submit-an-mpi-openmp-job-in-a-slurm-cluster/78 "2018-03-16T01:19:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![toreliza](https://ask.cyberinfrastructure.org/user_avatar/ask.cyberinfrastructure.org/toreliza/32/157_2.png) [@toreliza](https://ask.cyberinfrastructure.org/u/toreliza)\
**Post date:** [March 16, 2018, 1:19am UTC](https://ask.cyberinfrastructure.org/t/how-do-i-submit-an-mpi-openmp-job-in-a-slurm-cluster/78/1 "2018-03-16T01:19:01Z")

</div>

How do I submit an MPI/OpenMP job in a slurm cluster? Are there any tricks to ensure that processors and memory get assigned the way that I am intending?

---

<div class="post-metadata">

**Author:** ![payerle](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/p/90ced4/32.png) [@payerle](https://ask.cyberinfrastructure.org/u/payerle)\
**Post date:** [April 18, 2018, 1:18pm UTC](https://ask.cyberinfrastructure.org/t/how-do-i-submit-an-mpi-openmp-job-in-a-slurm-cluster/78/2 "2018-04-18T13:18:40Z")

</div>

You should supply the following options to sbatch (typically, as shown here  
as part of the job script):

```
#!/bin/sh
#SBATCH --cpus-per-task=4
#SBATCH --ntasks=6
...

```

The “–cpus-per-task=4” can be be abbreviated “-c 4” and the “–ntasks=6” can  
be abbreviated “-n 6”.

The specifies that you wish to run 6 MPI “tasks”, with each task getting 4  
CPU cores. This way every OpenMP thread will get its own CPU core. It will  
also ensure that all four cores for each MPI task are allocated on the same node  
(e.g. you won’t get 10 cores on each of 2 nodes and 4 cores on a third node).

You will need to add other sbatch options (walltime, memory, etc) as usual.
