How do I call the function inner from outer, such that each call to inner runs on a different node? That is, for ij = 1, it runs on node 1 using all of its 16 cores, for ij = 2, it runs on node 2 using all of its 16 cores, and so on?
using Distributed
addprocs(32)
println("Number of processes: ", nprocs())
println("Number of workers: ", nworkers())
@everywhere function inner(a,ij)
sleep(5);
println("Inside inner")
return a*ij;
end
function outer(a,N)
tt0 = time()
g(x) = ij -> inner(x, ij);
arrsum = sum(pmap(g(a), (1:N)));
tt1 = time()
println("outer time = $(tt1-tt0)")
return arrsum
end
println("outer = ",outer(1,5))
I am using this slurm submission script
#!/bin/bash
#SBATCH -J m_node
#SBATCH -t 0-04:00:00
#SBATCH --nodes 2
#SBATCH --ntasks-per-node 1
#SBATCH --cpus-per-task=16
srun /home/userdir/julia-1.10.4/bin/julia /home/userdir/Work/julia_mnode.jl
This is not giving me the desired behaviour. Instead, each call to inner is using only 1 core, spread out over the 2 nodes.