Parallel Computing with Threads.@threads in HPC is slow?

Hello everyone,
Thank you so much for your consideration.
For this issue, I found a solution.
It is already available in the Julia documentation: Multi-processing and Distributed Computing · The Julia Language
For example, to run FOR LOOP in parallel, I will not use @thread, instead, now, I am using the Distributed package in Julia by using 50 processors in HPC, here is a Julia example:

# ====The file name is MyHPC.jl
using Distributed
@everywhere using SharedArrays
n = 1000
A = SharedArray{Float64}(n)
@sync @distributed for i = 1:n
    A[i] = 100
end

And here is my slurm job’s submission:

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=55
#SBATCH --partition=general
module load julia
julia -p 50 MyHPC.jl

Best regards,

1 Like