Have a Question?
Julia
To run Julia on ARC, you can execute the following
module load julia
julia
This will launch an interactive terminal for executing your julia codes
Running parallel jobs using the Julia Distributed Package
Julia comes with built-in parallel programming support. These can be utilized to achieve a significant speed-up. This example presents a simple use case of the Distributed package. The Julia script below illustrates the basics of using spawnat and fetch:
using Distributed
# launch worker processes
num_cores = parse(Int, ENV["SLURM_CPUS_PER_TASK"])
addprocs(num_cores)
println("Number of cores: ", nprocs())
println("Number of workers: ", nworkers())
# each worker gets its id, process id and hostname
for i in workers()
id, pid, host = fetch(@spawnat i (myid(), getpid(), gethostname()))
println(id, " " , pid, " ", host)
end
# remove the workers
for i in workers()
rmprocs(i)
end
The script can be run through a batch script which requests 7 CPU-cores per task and you will get the following output
Number of cores: 8
Number of workers: 7
2 115494 compute-22
3 115495 compute-22
4 115496 compute-22
5 115497 compute-22
6 115499 compute-22
7 115500 compute-22
8 115501 compute-22
Distributed package in Julia has a lot more application. You may also consider looking at distributed arrays and multithreading on the Julia website. More information about package management can be found at the Julia package website.