Programming/Julia

From HPC
Jump to: navigation , search

Programming Details

Julia is a high-level, high-performance dynamic programming language for numerical computing. It provides a sophisticated compiler, distributed parallel execution, numerical accuracy, and an extensive mathematical function library. Julia’s Base library, largely written in Julia itself, also integrates mature, best-of-breed open source C and Fortran libraries for linear algebra, random number generation, signal processing, and string processing. In addition, the Julia developer community is contributing a number of external packages through Julia’s built-in package manager at a rapid pace. IJulia, a collaboration between the Jupyter and Julia communities, provides a powerful browser-based graphical notebook interface to Julia.

Julia’s LLVM-based just-in-time (JIT) compiler combined with the language’s design allow it to approach and often match the performance of C.


Programming example


#!/usr/bin/env julia
# function to calculate the volume of a sphere

function sphere_vol(r)
    return 4/3*pi*r^3
end

vol = sphere_vol(3)
@printf "volume = %0.3f\n" vol

Modules Available

The following modules are available:

  • module add julia/0.6.1


Interactive Mode

The program is interpreted by the julia runtime program, so compilation does not apply here.


[username@login01 src]$ interactive
salloc: Granted job allocation 1134106
Job ID 1134106 connecting to c076, please wait...

[username@c0761 ~]$ module add julia/1.0.0
[username@c0761 ~]$ julia

[pysdlb@c076]$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.0 (2018-08-08)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>
julia>exit() 

[pysdlb@c076]$

Batch Mode


#!/bin/bash

#SBATCH -J openmp-single-node
#SBATCH -N 1
#SBATCH --ntasks-per-node 1
#SBATCH -D /home/pysdlb/CODE_SAMPLES/julia
#SBATCH -o %N.%j.%a.out
#SBATCH -e %N.%j.%a.err
#SBATCH -p compute
#SBATCH --exclusive

echo $SLURM_JOB_NODELIST

module purge
module add julia/1.0.0

export I_MPI_DEBUG=5
export I_MPI_FABRICS=shm:tmi
export I_MPI_FALLBACK=no

julia sphereCal.jl


[user@login01 julia]$ sbatch single_node.job
Submitted batch job 546610
[user@login01 julia]$ cat c023.546610.4294967294.out
c023
volume = 113.097


Libraries

To show the libraries included type ( within julia ) the command : Pkg.status()


julia> Pkg.status()
No packages installed.

julia> Pkg.add("Distributions")
INFO: Cloning cache of Distributions from git://github.com/JuliaStats/Distributions.jl.git
INFO: Cloning cache of NumericExtensions from git://github.com/lindahua/NumericExtensions.jl.git
INFO: Cloning cache of Stats from git://github.com/JuliaStats/Stats.jl.git
INFO: Installing Distributions v0.2.7
INFO: Installing NumericExtensions v0.2.17
INFO: Installing Stats v0.2.6
INFO: REQUIRE updated.

julia> Pkg.status()
Required packages:
 - Distributions                 0.2.7
Additional packages:
 - NumericExtensions             0.2.17
 - Stats                         0.2.6


Installing Additional Libraries

If you need an additional library installed that would be used by more than just yourself, contact the Viper team on help@hull.ac.uk with the details of the library and the version of julia you require it for.


Further Information

Navigation