1

I have a script defined like this:

#!/bin/sh

#SBATCH --nodes=1
#SBATCH --cpus-per-task=16
#SBATCH --mem 180000

./program1 --threads 16
./program2 --threads 16

I then submit my job with sbatch job.sh

The thing is that program1 uses all 16 cores/cpus, but program2 does only use 1 (both are supposedly multi-thread). If I however modify the script to be like:

#!/bin/sh

#SBATCH --nodes=1
#SBATCH --cpus-per-task=16
#SBATCH --mem 180000

./program1 --threads 16
srun --mpi=openmpi ./program2 --threads 16

then program2 does also use all 16 cores. Why is it necessary to add that "srun"?

As extra information, the implementation of program2 multithreading is done using std::async

Ivan
  • 1,801
  • 2
  • 23
  • 40
  • What happens, in your first script, if program2 appears before program1? – Jeff Holt Feb 19 '20 at 02:44
  • Exactly the same! @JeffHolt – Ivan Feb 19 '20 at 12:37
  • @Ivan By exactly the same, you meant program1 still uses 16 cores? when program2 is above program1? I can explain in detail if you clarify this point.^ – bozzmob Feb 19 '20 at 14:40
  • @bozzmob no matter what I do or the order in which programs are run, with the first script program1 will use 16 cores and program2 will use 1. If I add the srun piece, then no matter the order, both use 16 cores – Ivan Feb 20 '20 at 15:35

0 Answers0