title: What does the --ntasks or -n tasks does in SLURM?
body: <p>I was using <a href="http://slurm.schedmd.com/" rel="noreferrer">SLURM</a> to use some computing cluster and it had the <code>-ntasks</code> or <code>-n</code>. I have obviously read the documentation for it (<a href="http://slurm.schedmd.com/sbatch.html" rel="noreferrer">http://slurm.schedmd.com/sbatch.html</a>):</p>
  
  <blockquote>
    <p>sbatch does not launch tasks, it requests an allocation of resources
    and submits a batch script. This option advises the Slurm controller
    that job steps run within the allocation will launch a maximum of
    number tasks and to provide for sufficient resources. The default is
    one task per node, but note that the --cpus-per-task option will
    change this default.</p>
  </blockquote>
  
  <p>the specific part I do not understand what it means is:</p>
  
  <blockquote>
    <p>run within the allocation will launch a maximum of number tasks and to
    provide for sufficient resources.</p>
  </blockquote>
  
  <p>I have a few questions:</p>
  
  <ol>
  <li>I guess my first question is what does the word "task" mean and the difference is with the word "job" in the SLURM context. I usually think of a job as the running the bash script under sbatch as in <code>sbatch my_batch_job.sh</code>. Not sure what task means.</li>
  <li>If I equate the word task with job then I thought it would have ran the same identical bash script multiple times according to the argument to <code>-n, --ntasks=&lt;number&gt;</code>. However, I obviously tested it out in the cluster, ran a <code>echo hello</code> with <code>--ntask=9</code> and I expected sbatch would echo hello 9 times to stdout (which is collected in <code>slurm-job_id.out</code>, but to my surprise, there was a single execution of my echo hello script Then what does this command even do? It seems it does nothing or at least I can't see whats suppose to be doing.</li>
  </ol>
  
  <hr>
  
  <p>I do know the <code>-a, --array=&lt;indexes&gt;</code> option exists for multiple jobs. That is a different topic. I simply want to know what <code>--ntasks</code> is suppose to do, ideally with an example so that I can test it out in the cluster.</p>