A Journey Through .
A DYNAMIC AND FAST LANGUAGE THIBAUT CUVELIER 17 NOVEMBER, 2016
1
Through . A DYNAMIC AND FAST LANGUAGE THIBAUT CUVELIER 17 - - PowerPoint PPT Presentation
A Journey Through . A DYNAMIC AND FAST LANGUAGE THIBAUT CUVELIER 17 NOVEMBER, 2016 1 What is ? A programming language For scientific computing first: running times are important! But still dynamic, modern and
A DYNAMIC AND FAST LANGUAGE THIBAUT CUVELIER 17 NOVEMBER, 2016
1
2
3
Data: http://julialang.org/benchmarks/
Comparison of run time between several languages and C
4
julia> Pkg.add(”IJulia”)
julia> using IJulia; notebook()
5
6
7
8
depending on its arguments
that may depend on the types of its arguments
9
argument, static for the others
10
11
then the method to call is too
12
13
14
with many extension packages available:
15
julia> Pkg.add(”PackageName”)
julia> import PackageName
julia> Pkg.rm(”PackageName”)
JuliaPlots, JuliaQuant, JuliaParallel, JuliaMaths…
16
17
matplotlib)
julia> Pkg.add(”Plots”) julia> Pkg.add(”GR”) julia> using Plots
18
julia> plot(1:5, sin(1:5))
julia> plot(sin, 1:.1:5)
19
julia> scatter(rand(1000))
julia> histogram(rand(1000), nbins=20)
20
AND MACROS!
24
max 𝑦 + 𝑧
0 ≤ 𝑦 ≤ +∞ 1 ≤ 𝑧 ≤ 20 m = Model() @variable(m, x >= 0) @variable(m, 1 <= y <= 20) @objective(m, Max, x + y) @constraint(m, 2 * x + y <= 8) solve(m)
programs into code
julia> Pkg.add(”JuMP”) julia> Pkg.add(”Cbc”) julia> using JuMP
25
https://github.com/JuliaOpt/JuMP.jl/blob/master/src/macros.jl#L743
26
27
df = DataFrame(N=1:3, colour=[“b”, “w”, “b”])
df[:colour] df[1, :]
28
select, filter, join, etc.
@from i in df begin @where i.N >= 2 @select {i.colour} @collect DataFrame end
29
30
MULTITHREADING MESSAGE PASSING ACCELERATORS
31
network
32
retrieve it on the main node r = @spawn 2 rand(2, 2) fetch(r)
33
nheads = @parallel (+) for i in 1:500 Int(rand(Bool)) end
34
before starting Julia
35
array = zeros(20) @Threads.threads for i in 1:20 array[i] = Threads.threadid() end
36
https://github.com/JuliaLang/julia/issues/19302 Similar to OpenMP offloading
37
http://arrayfire.com/download/
Pkg.add(“ArrayFire”)
using ArrayFire
38
setBackend(AF_BACKEND_OPENCL)
a_cpu = rand(Float32, 10, 10); a_gpu = AFArray(a_cpu); b_gpu = AFArray(rand(Float32, 10, 10));
c_gpu = a_gpu + b_gpu;
c_cpu = Array(c_gpu);
39
40
41