Julia

1 Overview | 2 Using | 2.1 Multicore | 2.2 MPI

Overview

  • Julia: The Julia Language: A fresh approach to technical computing.

Using

Use the module name julia to discover versions available and to load the language.

Multicore

Julia is developed to work within parallel computing environments within asynchronous tasks, multi-threading, distributing computing as well as on GPUs.

For getting started with Multi-Threading and using multicores, you need to explicitly inform Julia how many cores to use, for example:

[@blog1 testing]$ cat num_of_threads.jl println("Num of Threads: ", Threads.nthreads()) [@blog1 testing]$ salloc -A <your-project> -t 1:00:00 -c 8 [@m001 testing]$ julia num_of_threads.jl Num of Threads: 1 [@m001 testing]$ export JULIA_NUM_THREADS=8 [@m001 testing]$ julia num_of_threads.jl Num of Threads: 8 [@m001 testing]$ julia --threads 4 num_of_threads.jl Num of Threads: 4

Although you can define more threads than requested, from our observations your code will still only run on the number of actual cores requests:

[@m001 testing]$ export JULIA_NUM_THREADS=16 [@m001 testing]$ julia num_of_threads.jl Num of Threads: 16 # Only 8 cores will actually be used.

MPI

ARCC has performed some basic testing with the MPI package on Beartooth. The process we used to set up the environment was:

# 1: Load the julia module # 2: Start julia from the command-line: [@blog1 testing]$ julia julia> import Pkg; Pkg.add("MPI") julia> import Pkg; Pkg.add("MPIPreferences") # 3: Press Ctrl-D to exit. # 4: Load the openmpi module. # 5: From the command-line run the following, which should generate the indicated output: [@blog1 testing]$ julia --project -e 'using MPIPreferences; MPIPreferences.use_system_binary()' ┌ Info: MPI implementation identified │ libmpi = "libmpi" │ version_string = "Open MPI v4.1.4, package: Open MPI powerman@bmgt1 Distribution, ident: 4.1.4, repo rev: v4.1.4, May 26, 2022\0" │ impl = "OpenMPI" │ version = v"4.1.4" └ abi = "OpenMPI" ┌ Info: MPIPreferences changed │ binary = "system" │ libmpi = "libmpi" │ abi = "OpenMPI" └ mpiexec = "mpiexec" # 6: Copy the Hello World example: 01-hello.jl # 7: Create an interactive seesion: [@blog1 testing]$ salloc -A <your-project> -t 30:00 -N 2 --tasks-per-node=3 # 8: Run the source [@m001 testing]$ srun julia 01-hello.jl Hello world, I am 3 of 6 Hello world, I am 4 of 6 Hello world, I am 5 of 6 Hello world, I am 0 of 6 Hello world, I am 2 of 6 Hello world, I am 1 of 6

We have observed the following warning the first (and only) time running MPI related code:

Note: Every time your wish to run/test your MPI related Julia code you will need to module load the openmpi module alongside julia.