[slurm-users] ntasks and cpus-per-task

Loris Bennett loris.bennett at fu-berlin.de
Thu Feb 22 01:50:34 MST 2018

Hi Chris,

Christopher Samuel <chris at csamuel.org> writes:

> On 22/02/18 18:49, Miguel Gutiérrez Páez wrote:
>> What's the real meaning of ntasks? Has cpus-per-task and ntasks the
>> same meaning in sbatch and srun?
> --ntasks is for parallel distributed jobs, where you can run lots of
> independent processes that collaborate using some form of communication
> between the processes (usually MPI for HPC).
> So inside your batch script you would use "srun" to start up the tasks.
> However, unless you code is written to make use of that interface then
> it's not really going to help you, and so for any multithreaded
> application you need to use --cpus-per-task instead.

[snip (11 lines)]

But does it make any difference for a multithreaded program if I have

  #SBATCH --ntasks=4
  #SBATCH --nodes=1-1

rather than

  #SBATCH --ntasks=1
  #SBATCH --cpus-per-task=4

Up to now I have only thought of --cpus-per-task in connection with
hybrid MPI/OpenMP jobs, which we don't actually have.  Thus I tend to
tell users to think always in terms of tasks, regardless of whether
these are MPI processes or just threads.

One downside of my approach is that if the user forgets to specify
--nodes and --ntasks is greater than 1, non-MPI jobs can be assigned to
multiple nodes.



Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin         Email loris.bennett at fu-berlin.de

More information about the slurm-users mailing list