Julia

Julia

Julia [1] is a flexible dynamic language, appropriate for scientific and numerical computing, with performance comparable to traditional statically-typed languages. Julia provides ease and expressiveness for high-level numerical computing, in the same way as languages such as R, MATLAB, and Python, but also supports general programming. To achieve this, Julia builds upon the lineage of mathematical programming languages, but also borrows much from popular dynamic languages, including Lisp, Perl, Python, Lua, and Ruby.

Running Julia in HPC

Interactive Job

Request a node (rider).  For multithreading, use the flag -n (e.g. -n 4 for 4 threads)

srun --pty bash

Note: In Rider, Julia can run only in particular set of nodes (srun -C dodeca96gb --pty bash). Also, syntax may have been changed e.g. need to use include instead of require.

Load the module

module load julia

Run Julia (serial)

julia

julia> string(10*15)

"150"

julia> import Pkg

julia> Pkg.installed() # check the installed packages

Dict{String,VersionNumber} with 1 entry:

  "DistributedArrays" => v"0.6.5"

Pkg.status()

      Status `~/.julia/environments/v1.7/Project.toml`

  [2e9cd046] Gurobi v0.11.3

julia> exit()

Run Julia (multithreading)

julia -t 4

julia> Threads.nthreads()

4

Note: julia gets transitioned to shell mode by typing colon (;) after the prompt. For details, visit [2]. Press  "Ctrol + d" to exit

Batch Job

Example: WordCount

Copy the directory "examples" from /usr/local/doc/JULIA and cd to that directory

cp -r /usr/local/doc/JULIA/examples .

cd examples

Multithreaded Job:

Submit the Parallel job

sbatch job-multi.slurm

You will see the output at slurm-<jobID>.

Distributed Job:

Install DistributedArrays  package [2]

module laod juila/1.6.2 

julia

julia> import Pkg

julia> Pkg.add("DistributedArrays") 

Find the slurm script "job-distributed.slurm" and julia script "distributed.jl" at the examples directory that you copied and run the job.

sbatch job-distributed.slurm

MPI Job:

Installation instruction at MPI [3]

CUDA Job:

Build or pull Julia singularity container from NVIDIA NGC (https://ngc.nvidia.com/catalog/containers/hpc:julia) and follow the instructions to run the examples. 

Package Installation:

Check HPC Pkg installation Guide for details. CUDA package can also be installed [4].

References:

[1] Julia Home

[2] Distributed Arrays 

[3] MPI Implementation

[4] CUDA Package