SlideShare a Scribd company logo
Towards new solutions for scientific computing: the case of Julia
Maurizio Tomasi Mosè Giordano
Nov 15 2018
Who are we?
Maurizio Tomasi (myself) Mosè Giordano
▶ Worked on the Planck mission (calibration,
simulations, data analysis…)
▶ Currently involved in other CMB experiments
▶ Worked on gravitational microlensing
▶ Author of several Julia packages
(github.com/giordano)
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Making Python more performant
Python is a fantastic language: easy and with a very rich library. (And AstroPy is awesome!)
However, its speed is not impressive at all!
In [1]: %time x = [i*i for i in range(100_000_000)]
CPU times: user 5.27 s, sys: 860 ms, total: 6.13 s
Wall time: 6.18 s
Several solutions have been developed: NumPy, PyPy, Numba, Cython… They can be extremely
performant in their own domains, but picking the right one requires careful consideration.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
The two-language problem
In order to make Python codes more performant, it is common to link them to C/C++/Fortran, using
tools like f2py, SWIG, Cython, and so on:
Main program
1st module
2nd module
3rd module
These codes are complex to implement and deploy:
▶ Need to master many languages
▶ Try to write a portable setup.py for projects using f2py!
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Meet Julia
▶ Relatively new language (first official release was 0.2, in Nov 2013)
▶ Julia 1.0 released on August, 9th 2018
▶ Released under the MIT license
▶ julialang.org
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
A taste of Julia
I’m going to play a screencast now. You can watch it again at the following URL:
asciinema.org/a/211906.
The following slides are left as a reference if you don’t have an internet connection. They are not the
same as the screencast, as they show some more features.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
A taste of Julia (1/5)
# One-liner definition of a function
f(x) = 3x + 1
# Floating-point
@time f(0.1) # 0.005716 seconds (15.63 k allocations: 872.499 KiB)
@time f(0.3) # 0.000002 seconds (5 allocations: 176 bytes)
# Integer
@time f(2) # 0.002888 seconds (2.00 k allocations: 117.656 KiB)
@time f(10) # 0.000001 seconds (4 allocations: 160 bytes)
# Rational
@time f(3//2) # 0.070596 seconds (209.83 k allocations: 10.785 MiB)
@time f(4//9) # 0.000005 seconds (6 allocations: 224 bytes)
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
A taste of Julia (2/5)
# Load default packages
using Printf
using Pkg
# Install a few new packages from Internet
for name in ["Cosmology", "Measurements", "Zygote#master", "PyCall"]
Pkg.add(name)
end
using Cosmology
c = cosmology(h=0.69, Neff=3.04, OmegaM=0.29, Tcmb=2.7255)
z = 0.1
@printf("Universe age at z=%.1f: %.1f Gyrn", z, age_gyr(c, z))
# Prints "Universe age at z=0.1: 12.5 Gyr"
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
A taste of Julia (3/5)
using Measurements # Define the ± binary operator
z = 0.1 ± 0.01
println(z)
# Prints "0.1 ± 0.01"
age = age_gyr(c, z)
println(age)
# Prints "12.465336269441773 ± 0.12305608850870296"
@printf("%.2f ± %.2f Gyrn", age.val, age.err)
# prints "12.47 ± 0.12 Gyr"
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
A taste of Julia (4/5)
# See https://arxiv.org/abs/1810.07951
using Zygote # Long time to compile…
g(x) = 2x + 1
println(g(1)) # Print 3
println(g'(1)) # Print 2 (derivative of g at x=1)
@code_llvm g'(1) # Surprise! "ret i64 2"
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
A taste of Julia (5/5)
using PyCall
@pyimport numpy.random as nr
x = nr.randn(5)
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
JuliaAstro on GitHub
Package Description
AstroImages.jl Visualization of astronomical images (by MG)
AstroLib.jl Astronomical and astrophysical routines (by MG)
AstroTime.jl Astronomical time keeping
Cosmology.jl Library of cosmological functions
DustExtinction.jl Models for the interstellar extinction due to dust
ERFA.jl Wrapper to liberfa
EarthOrientation.jl Earth orientation parameters from IERS tables
FITSIO.jl Flexible Image Transport System (FITS) file support
LombScargle.jl Compute Lomb-Scargle periodogram (by MG)
SPICE.jl Julia wrapper for NASA NAIF’s SPICE toolkit
SkyCoords.jl Support for astronomical coordinate systems
UnitfulAstro.jl An extension of Unitful.jl for astronomers
WCS.jl Astronomical World Coordinate Systems library
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Simulating cosmological experiments with Julia
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Data science with Julia
The good The bad
▶ Very fast execution for codes with lots of
calculations
▶ Powerful features (many numerical types,
metaprogramming, missing values…)
▶ Ability to call C, Fortran, Python, R
▶ Package management is rock solid
(reproducible builds, like Rust’s cargo)
▶ Native support for parallel computing (no GIL
here!)
▶ Profiling tools immediately available (e.g.,
--track-allocation)
▶ Slow execution if every function is called just
once
▶ Not as many packages as other languages
(Python, C++, …)
▶ Plotting is promising (PyPlot.jl, Plots.jl,
UnicodePlots.jl, Makie.jl, …), but still lacking
▶ Avoid global variables as the plague! They
make the compiler highly inefficient
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
When to use Julia
Julia is interesting if:
▶ You are going to implement a code that will do lots of calculations and is going to spend much
time in doing it, and you will write this code from scratch.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
When to use Julia
Julia is interesting if:
▶ You are going to implement a code that will do lots of calculations and is going to spend much
time in doing it, and you will write this code from scratch.
▶ You have an existing large, monolithic code and want to turn it into something to be used
interactively, without sacrificing speed.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
When to use Julia
Julia is interesting if:
▶ You are going to implement a code that will do lots of calculations and is going to spend much
time in doing it, and you will write this code from scratch.
▶ You have an existing large, monolithic code and want to turn it into something to be used
interactively, without sacrificing speed.
▶ You plan to use Julia’s homoiconicity to do something really innovative, like Zygote.jl!
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
More information
▶ Julia compiler: julialang.org
▶ Julia user’s manual: docs.julialang.org/en/v1
▶ Package list available at juliaobserver.com
▶ User’s and developers’ forums: discourse.julialang.org
▶ Very good blogpost about Numba, Cython, and Julia:
www.stochasticlifestyle.com/why-numba-and-cython-are-not-substitutes-for-julia
▶ JuliaAstro: github.com/JuliaAstro
▶ These slides and additional material: bitbucket.org/Maurizio_Tomasi/adass2018-julia
▶ For questions, feel free to ask me or write me an email: maurizio.tomasi@unimi.it
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Backup slides
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Calculations with NumPy arrays
Consider this code, where all the parameters for f are NumPy arrays:
def f(r, x1, x2, x3, x4):
r = x1 - x2 + x3 - x4
This code is executed by NumPy as if it were
tmp = x1 - x2
tmp += x3
r = tmp - x4
thus three for loops are ran.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Performance of NumPy codes
2 3 4 5 6 7 8
Number of terms in the expression
1
2
3
4
5
6
7
8
9
Besttime(100runs)[ms]
Python 3.6.6 + NumPy 1.15.1
Source codes available at github.com/ziotom78/python-julia-c-.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Calculations with C++ vectors
In C++, the code needs to be written in this way:
for(size_t i = 0; i < r.size(); ++i) {
r[i] = x1[i] - x2[i] + x3[i] - x4[i];
}
We need to write the for loop explicitly, but there is only **one* of them.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Performance of NumPy/C++ codes
2 3 4 5 6 7 8
Number of terms in the expression
1
2
3
4
5
6
7
8
9
Besttime(100runs)[ms]
Python 3.6.6 + NumPy 1.15.1
G++ 7.3.0, flags -O3 -march -msse3
Source codes available at github.com/ziotom78/python-julia-c-.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Performance of Julia programs
# 4 terms
f(r, x1, x2, x3, x4) = @. r = x1 - x2 + x3 - x4
g(r, x1, x2, x3, x4) = @. r = x1 - x2 + x3
h(r, x1, x2, x3, x4) = @. r = x1 - x2
# Etc.
The @. macro fuses all the operations on loops. Thus, f above is equivalent to
function f(r, x1, x2, x3, x4)
for i in eachindex(r)
r[i] = x1[i] - x2[i] + x3[i] - x4[i]
end
end
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Performance of NumPy, C++, and Julia codes
2 3 4 5 6 7 8
Number of terms in the expression
1
2
3
4
5
6
7
8
9
Besttime(100runs)[ms]
Python 3.6.6 + NumPy 1.15.1
G++ 7.3.0, flags -O3 -march -msse3
Julia 1.0.2
Source codes available at github.com/ziotom78/python-julia-c-.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Using SIMD instructions in Julia
C++ was given an unfair advantage, as it was allowed to use SIMD instructions (-msse3). Moreover, it
did not check array boundaries (Julia does automatically).
In Julia, we can use the @inbounds and @simd macro to make Julia code equivalent to C++:
function f(r, x1, x2, x3, x4)
@inbounds @simd for i in eachindex(r)
r[i] = x1[i] - x2[i] + x3[i] - x4[i]
end
end
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Performance of NumPy, C++, and Julia codes
2 3 4 5 6 7 8
Number of terms in the expression
1
2
3
4
5
6
7
8
9
Besttime(100runs)[ms]
Python 3.6.6 + NumPy 1.15.1
G++ 7.3.0, flags -O3 -march -msse3
Julia 1.0.2
Source codes available at github.com/ziotom78/python-julia-c-.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
Performance of NumPy, C++, and Julia codes
2 3 4 5 6 7 8
Number of terms in the expression
1
2
3
4
5
6
7
8
9
Besttime(100runs)[ms]
Python 3.6.6 + NumPy 1.15.1
G++ 7.3.0, flags -O3 -march -msse3
Julia 1.0.2
Julia 1.0.2, with @inbounds @simd
Source codes available at github.com/ziotom78/python-julia-c-.
Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)

More Related Content

What's hot

Lecture17 xing fei-fei
Lecture17 xing fei-feiLecture17 xing fei-fei
Lecture17 xing fei-fei
Tianlu Wang
 
EuroSciPy 2019 - GANs: Theory and Applications
EuroSciPy 2019 - GANs: Theory and ApplicationsEuroSciPy 2019 - GANs: Theory and Applications
EuroSciPy 2019 - GANs: Theory and Applications
Emanuele Ghelfi
 
H2O & Tensorflow - Fabrizio
H2O & Tensorflow - Fabrizio H2O & Tensorflow - Fabrizio
H2O & Tensorflow - Fabrizio
Sri Ambati
 
Learning to discover monte carlo algorithm on spin ice manifold
Learning to discover monte carlo algorithm on spin ice manifoldLearning to discover monte carlo algorithm on spin ice manifold
Learning to discover monte carlo algorithm on spin ice manifold
Kai-Wen Zhao
 
Data-driven hypothesis generation using deep neural nets
Data-driven hypothesis generation using deep neural netsData-driven hypothesis generation using deep neural nets
Data-driven hypothesis generation using deep neural nets
Balázs Kégl
 
IMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEY
IMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEYIMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEY
IMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEY
ijcsit
 
Big Data + Big Sim: Query Processing over Unstructured CFD Models
Big Data + Big Sim: Query Processing over Unstructured CFD ModelsBig Data + Big Sim: Query Processing over Unstructured CFD Models
Big Data + Big Sim: Query Processing over Unstructured CFD Models
University of Washington
 
Deep Water - Bringing Tensorflow, Caffe, Mxnet to H2O
Deep Water - Bringing Tensorflow, Caffe, Mxnet to H2ODeep Water - Bringing Tensorflow, Caffe, Mxnet to H2O
Deep Water - Bringing Tensorflow, Caffe, Mxnet to H2O
Sri Ambati
 
GAN in medical imaging
GAN in medical imagingGAN in medical imaging
GAN in medical imaging
Cheng-Bin Jin
 
Tim connecting-the-dots
Tim connecting-the-dotsTim connecting-the-dots
Tim connecting-the-dots
Timothy Head
 
Probabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering NetworksProbabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering Networks
Tomaso Aste
 

What's hot (11)

Lecture17 xing fei-fei
Lecture17 xing fei-feiLecture17 xing fei-fei
Lecture17 xing fei-fei
 
EuroSciPy 2019 - GANs: Theory and Applications
EuroSciPy 2019 - GANs: Theory and ApplicationsEuroSciPy 2019 - GANs: Theory and Applications
EuroSciPy 2019 - GANs: Theory and Applications
 
H2O & Tensorflow - Fabrizio
H2O & Tensorflow - Fabrizio H2O & Tensorflow - Fabrizio
H2O & Tensorflow - Fabrizio
 
Learning to discover monte carlo algorithm on spin ice manifold
Learning to discover monte carlo algorithm on spin ice manifoldLearning to discover monte carlo algorithm on spin ice manifold
Learning to discover monte carlo algorithm on spin ice manifold
 
Data-driven hypothesis generation using deep neural nets
Data-driven hypothesis generation using deep neural netsData-driven hypothesis generation using deep neural nets
Data-driven hypothesis generation using deep neural nets
 
IMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEY
IMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEYIMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEY
IMAGE GENERATION WITH GANS-BASED TECHNIQUES: A SURVEY
 
Big Data + Big Sim: Query Processing over Unstructured CFD Models
Big Data + Big Sim: Query Processing over Unstructured CFD ModelsBig Data + Big Sim: Query Processing over Unstructured CFD Models
Big Data + Big Sim: Query Processing over Unstructured CFD Models
 
Deep Water - Bringing Tensorflow, Caffe, Mxnet to H2O
Deep Water - Bringing Tensorflow, Caffe, Mxnet to H2ODeep Water - Bringing Tensorflow, Caffe, Mxnet to H2O
Deep Water - Bringing Tensorflow, Caffe, Mxnet to H2O
 
GAN in medical imaging
GAN in medical imagingGAN in medical imaging
GAN in medical imaging
 
Tim connecting-the-dots
Tim connecting-the-dotsTim connecting-the-dots
Tim connecting-the-dots
 
Probabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering NetworksProbabilistic Modelling with Information Filtering Networks
Probabilistic Modelling with Information Filtering Networks
 

Similar to Towards new solutions for scientific computing: the case of Julia

DL-Foil:Class Expression Learning Revisited
DL-Foil:Class Expression Learning RevisitedDL-Foil:Class Expression Learning Revisited
DL-Foil:Class Expression Learning Revisited
Giuseppe Rizzo
 
Python and Sage
Python and SagePython and Sage
How it works- Data Science
How it works- Data ScienceHow it works- Data Science
How it works- Data Science
Edureka!
 
Invent Episode 3: Tech Talk on Parallel Future
Invent Episode 3: Tech Talk on Parallel FutureInvent Episode 3: Tech Talk on Parallel Future
Invent Episode 3: Tech Talk on Parallel Future
M. Atif Qureshi
 
Introducción práctica al análisis de datos hasta la inteligencia artificial
Introducción práctica al análisis de datos hasta la inteligencia artificialIntroducción práctica al análisis de datos hasta la inteligencia artificial
Introducción práctica al análisis de datos hasta la inteligencia artificial
fcoalberto
 
Recommendation Systems in banking and Financial Services
Recommendation Systems in banking and Financial ServicesRecommendation Systems in banking and Financial Services
Recommendation Systems in banking and Financial Services
Andrea Gigli
 
Big Data & Machine Learning - TDC2013 São Paulo - 12/0713
Big Data & Machine Learning - TDC2013 São Paulo - 12/0713Big Data & Machine Learning - TDC2013 São Paulo - 12/0713
Big Data & Machine Learning - TDC2013 São Paulo - 12/0713
Mathieu DESPRIEE
 
Big Data & Machine Learning - TDC2013 Sao Paulo
Big Data & Machine Learning - TDC2013 Sao PauloBig Data & Machine Learning - TDC2013 Sao Paulo
Big Data & Machine Learning - TDC2013 Sao Paulo
OCTO Technology
 
From Lab to Factory: Or how to turn data into value
From Lab to Factory: Or how to turn data into valueFrom Lab to Factory: Or how to turn data into value
From Lab to Factory: Or how to turn data into value
Peadar Coyle
 
An Evaluation of Models for Runtime Approximation in Link Discovery
An Evaluation of Models for Runtime Approximation in Link DiscoveryAn Evaluation of Models for Runtime Approximation in Link Discovery
An Evaluation of Models for Runtime Approximation in Link Discovery
Holistic Benchmarking of Big Linked Data
 
Interact your wearable and an iot device
Interact your wearable and an iot deviceInteract your wearable and an iot device
Interact your wearable and an iot device
Jeff Prestes
 
Planning for power systems
Planning for power systemsPlanning for power systems
Planning for power systems
Olivier Teytaud
 
Intelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIntelligent Ruby + Machine Learning
Intelligent Ruby + Machine Learning
Ilya Grigorik
 
Kaggle Days Brussels - Alberto Danese
Kaggle Days Brussels - Alberto DaneseKaggle Days Brussels - Alberto Danese
Kaggle Days Brussels - Alberto Danese
Alberto Danese
 
Congress on Evolutionary Computation (CEC 2016) - Plenary Talk
Congress on Evolutionary Computation (CEC 2016) - Plenary TalkCongress on Evolutionary Computation (CEC 2016) - Plenary Talk
Congress on Evolutionary Computation (CEC 2016) - Plenary Talk
Graham Kendall
 
Federated Non-Traditional Practical Work for Engineering Education
Federated Non-Traditional Practical Work for Engineering EducationFederated Non-Traditional Practical Work for Engineering Education
Federated Non-Traditional Practical Work for Engineering Education
Timothy Drysdale
 
AIAA Future of Fluids 2018 Balaji
AIAA Future of Fluids 2018 BalajiAIAA Future of Fluids 2018 Balaji
AIAA Future of Fluids 2018 Balaji
Qiqi Wang
 
2014 pycon-talk
2014 pycon-talk2014 pycon-talk
2014 pycon-talk
c.titus.brown
 
Continual Learning: why, how, and when
Continual Learning: why, how, and whenContinual Learning: why, how, and when
Continual Learning: why, how, and when
Gabriele Graffieti
 
Introduction to LLMs
Introduction to LLMsIntroduction to LLMs
Introduction to LLMs
Loic Merckel
 

Similar to Towards new solutions for scientific computing: the case of Julia (20)

DL-Foil:Class Expression Learning Revisited
DL-Foil:Class Expression Learning RevisitedDL-Foil:Class Expression Learning Revisited
DL-Foil:Class Expression Learning Revisited
 
Python and Sage
Python and SagePython and Sage
Python and Sage
 
How it works- Data Science
How it works- Data ScienceHow it works- Data Science
How it works- Data Science
 
Invent Episode 3: Tech Talk on Parallel Future
Invent Episode 3: Tech Talk on Parallel FutureInvent Episode 3: Tech Talk on Parallel Future
Invent Episode 3: Tech Talk on Parallel Future
 
Introducción práctica al análisis de datos hasta la inteligencia artificial
Introducción práctica al análisis de datos hasta la inteligencia artificialIntroducción práctica al análisis de datos hasta la inteligencia artificial
Introducción práctica al análisis de datos hasta la inteligencia artificial
 
Recommendation Systems in banking and Financial Services
Recommendation Systems in banking and Financial ServicesRecommendation Systems in banking and Financial Services
Recommendation Systems in banking and Financial Services
 
Big Data & Machine Learning - TDC2013 São Paulo - 12/0713
Big Data & Machine Learning - TDC2013 São Paulo - 12/0713Big Data & Machine Learning - TDC2013 São Paulo - 12/0713
Big Data & Machine Learning - TDC2013 São Paulo - 12/0713
 
Big Data & Machine Learning - TDC2013 Sao Paulo
Big Data & Machine Learning - TDC2013 Sao PauloBig Data & Machine Learning - TDC2013 Sao Paulo
Big Data & Machine Learning - TDC2013 Sao Paulo
 
From Lab to Factory: Or how to turn data into value
From Lab to Factory: Or how to turn data into valueFrom Lab to Factory: Or how to turn data into value
From Lab to Factory: Or how to turn data into value
 
An Evaluation of Models for Runtime Approximation in Link Discovery
An Evaluation of Models for Runtime Approximation in Link DiscoveryAn Evaluation of Models for Runtime Approximation in Link Discovery
An Evaluation of Models for Runtime Approximation in Link Discovery
 
Interact your wearable and an iot device
Interact your wearable and an iot deviceInteract your wearable and an iot device
Interact your wearable and an iot device
 
Planning for power systems
Planning for power systemsPlanning for power systems
Planning for power systems
 
Intelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIntelligent Ruby + Machine Learning
Intelligent Ruby + Machine Learning
 
Kaggle Days Brussels - Alberto Danese
Kaggle Days Brussels - Alberto DaneseKaggle Days Brussels - Alberto Danese
Kaggle Days Brussels - Alberto Danese
 
Congress on Evolutionary Computation (CEC 2016) - Plenary Talk
Congress on Evolutionary Computation (CEC 2016) - Plenary TalkCongress on Evolutionary Computation (CEC 2016) - Plenary Talk
Congress on Evolutionary Computation (CEC 2016) - Plenary Talk
 
Federated Non-Traditional Practical Work for Engineering Education
Federated Non-Traditional Practical Work for Engineering EducationFederated Non-Traditional Practical Work for Engineering Education
Federated Non-Traditional Practical Work for Engineering Education
 
AIAA Future of Fluids 2018 Balaji
AIAA Future of Fluids 2018 BalajiAIAA Future of Fluids 2018 Balaji
AIAA Future of Fluids 2018 Balaji
 
2014 pycon-talk
2014 pycon-talk2014 pycon-talk
2014 pycon-talk
 
Continual Learning: why, how, and when
Continual Learning: why, how, and whenContinual Learning: why, how, and when
Continual Learning: why, how, and when
 
Introduction to LLMs
Introduction to LLMsIntroduction to LLMs
Introduction to LLMs
 

Recently uploaded

2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates
UAE Ppt
 
Prsentation for VIVA Welike project 1semester.pptx
Prsentation for VIVA Welike project 1semester.pptxPrsentation for VIVA Welike project 1semester.pptx
Prsentation for VIVA Welike project 1semester.pptx
prafulpawar29
 
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
OECD Directorate for Financial and Enterprise Affairs
 
Genesis chapter 3 Isaiah Scudder.pptx
Genesis    chapter 3 Isaiah Scudder.pptxGenesis    chapter 3 Isaiah Scudder.pptx
Genesis chapter 3 Isaiah Scudder.pptx
FamilyWorshipCenterD
 
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Proposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP IncProposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP Inc
Raheem Muhammad
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPEACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
Charmi13
 
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
gfysze
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
kainatfatyma9
 
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
SkillCertProExams
 
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdfWhy Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Ben Linders
 
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdfBRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
Robin Haunschild
 
Legislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptxLegislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptx
Charmi13
 
Gamify it until you make it Improving Agile Development and Operations with ...
Gamify it until you make it  Improving Agile Development and Operations with ...Gamify it until you make it  Improving Agile Development and Operations with ...
Gamify it until you make it Improving Agile Development and Operations with ...
Ben Linders
 
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
kekzed
 
IEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdfIEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdf
Claudio Gallicchio
 
Disaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other usesDisaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other uses
RIDHIMAGARG21
 

Recently uploaded (19)

2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates
 
Prsentation for VIVA Welike project 1semester.pptx
Prsentation for VIVA Welike project 1semester.pptxPrsentation for VIVA Welike project 1semester.pptx
Prsentation for VIVA Welike project 1semester.pptx
 
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
 
Genesis chapter 3 Isaiah Scudder.pptx
Genesis    chapter 3 Isaiah Scudder.pptxGenesis    chapter 3 Isaiah Scudder.pptx
Genesis chapter 3 Isaiah Scudder.pptx
 
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
 
Proposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP IncProposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP Inc
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
 
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPEACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
 
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
 
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
 
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
 
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdfWhy Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
 
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdfBRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
 
Legislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptxLegislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptx
 
Gamify it until you make it Improving Agile Development and Operations with ...
Gamify it until you make it  Improving Agile Development and Operations with ...Gamify it until you make it  Improving Agile Development and Operations with ...
Gamify it until you make it Improving Agile Development and Operations with ...
 
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
 
IEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdfIEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdf
 
Disaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other usesDisaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other uses
 

Towards new solutions for scientific computing: the case of Julia

  • 1. Towards new solutions for scientific computing: the case of Julia Maurizio Tomasi Mosè Giordano Nov 15 2018
  • 2. Who are we? Maurizio Tomasi (myself) Mosè Giordano ▶ Worked on the Planck mission (calibration, simulations, data analysis…) ▶ Currently involved in other CMB experiments ▶ Worked on gravitational microlensing ▶ Author of several Julia packages (github.com/giordano) Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 3. Making Python more performant Python is a fantastic language: easy and with a very rich library. (And AstroPy is awesome!) However, its speed is not impressive at all! In [1]: %time x = [i*i for i in range(100_000_000)] CPU times: user 5.27 s, sys: 860 ms, total: 6.13 s Wall time: 6.18 s Several solutions have been developed: NumPy, PyPy, Numba, Cython… They can be extremely performant in their own domains, but picking the right one requires careful consideration. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 4. The two-language problem In order to make Python codes more performant, it is common to link them to C/C++/Fortran, using tools like f2py, SWIG, Cython, and so on: Main program 1st module 2nd module 3rd module These codes are complex to implement and deploy: ▶ Need to master many languages ▶ Try to write a portable setup.py for projects using f2py! Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 5. Meet Julia ▶ Relatively new language (first official release was 0.2, in Nov 2013) ▶ Julia 1.0 released on August, 9th 2018 ▶ Released under the MIT license ▶ julialang.org Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 6. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 7. A taste of Julia I’m going to play a screencast now. You can watch it again at the following URL: asciinema.org/a/211906. The following slides are left as a reference if you don’t have an internet connection. They are not the same as the screencast, as they show some more features. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 8. A taste of Julia (1/5) # One-liner definition of a function f(x) = 3x + 1 # Floating-point @time f(0.1) # 0.005716 seconds (15.63 k allocations: 872.499 KiB) @time f(0.3) # 0.000002 seconds (5 allocations: 176 bytes) # Integer @time f(2) # 0.002888 seconds (2.00 k allocations: 117.656 KiB) @time f(10) # 0.000001 seconds (4 allocations: 160 bytes) # Rational @time f(3//2) # 0.070596 seconds (209.83 k allocations: 10.785 MiB) @time f(4//9) # 0.000005 seconds (6 allocations: 224 bytes) Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 9. A taste of Julia (2/5) # Load default packages using Printf using Pkg # Install a few new packages from Internet for name in ["Cosmology", "Measurements", "Zygote#master", "PyCall"] Pkg.add(name) end using Cosmology c = cosmology(h=0.69, Neff=3.04, OmegaM=0.29, Tcmb=2.7255) z = 0.1 @printf("Universe age at z=%.1f: %.1f Gyrn", z, age_gyr(c, z)) # Prints "Universe age at z=0.1: 12.5 Gyr" Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 10. A taste of Julia (3/5) using Measurements # Define the ± binary operator z = 0.1 ± 0.01 println(z) # Prints "0.1 ± 0.01" age = age_gyr(c, z) println(age) # Prints "12.465336269441773 ± 0.12305608850870296" @printf("%.2f ± %.2f Gyrn", age.val, age.err) # prints "12.47 ± 0.12 Gyr" Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 11. A taste of Julia (4/5) # See https://arxiv.org/abs/1810.07951 using Zygote # Long time to compile… g(x) = 2x + 1 println(g(1)) # Print 3 println(g'(1)) # Print 2 (derivative of g at x=1) @code_llvm g'(1) # Surprise! "ret i64 2" Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 12. A taste of Julia (5/5) using PyCall @pyimport numpy.random as nr x = nr.randn(5) Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 13. JuliaAstro on GitHub Package Description AstroImages.jl Visualization of astronomical images (by MG) AstroLib.jl Astronomical and astrophysical routines (by MG) AstroTime.jl Astronomical time keeping Cosmology.jl Library of cosmological functions DustExtinction.jl Models for the interstellar extinction due to dust ERFA.jl Wrapper to liberfa EarthOrientation.jl Earth orientation parameters from IERS tables FITSIO.jl Flexible Image Transport System (FITS) file support LombScargle.jl Compute Lomb-Scargle periodogram (by MG) SPICE.jl Julia wrapper for NASA NAIF’s SPICE toolkit SkyCoords.jl Support for astronomical coordinate systems UnitfulAstro.jl An extension of Unitful.jl for astronomers WCS.jl Astronomical World Coordinate Systems library Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 14. Simulating cosmological experiments with Julia Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 15. Data science with Julia The good The bad ▶ Very fast execution for codes with lots of calculations ▶ Powerful features (many numerical types, metaprogramming, missing values…) ▶ Ability to call C, Fortran, Python, R ▶ Package management is rock solid (reproducible builds, like Rust’s cargo) ▶ Native support for parallel computing (no GIL here!) ▶ Profiling tools immediately available (e.g., --track-allocation) ▶ Slow execution if every function is called just once ▶ Not as many packages as other languages (Python, C++, …) ▶ Plotting is promising (PyPlot.jl, Plots.jl, UnicodePlots.jl, Makie.jl, …), but still lacking ▶ Avoid global variables as the plague! They make the compiler highly inefficient Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 16. When to use Julia Julia is interesting if: ▶ You are going to implement a code that will do lots of calculations and is going to spend much time in doing it, and you will write this code from scratch. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 17. When to use Julia Julia is interesting if: ▶ You are going to implement a code that will do lots of calculations and is going to spend much time in doing it, and you will write this code from scratch. ▶ You have an existing large, monolithic code and want to turn it into something to be used interactively, without sacrificing speed. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 18. When to use Julia Julia is interesting if: ▶ You are going to implement a code that will do lots of calculations and is going to spend much time in doing it, and you will write this code from scratch. ▶ You have an existing large, monolithic code and want to turn it into something to be used interactively, without sacrificing speed. ▶ You plan to use Julia’s homoiconicity to do something really innovative, like Zygote.jl! Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 19. More information ▶ Julia compiler: julialang.org ▶ Julia user’s manual: docs.julialang.org/en/v1 ▶ Package list available at juliaobserver.com ▶ User’s and developers’ forums: discourse.julialang.org ▶ Very good blogpost about Numba, Cython, and Julia: www.stochasticlifestyle.com/why-numba-and-cython-are-not-substitutes-for-julia ▶ JuliaAstro: github.com/JuliaAstro ▶ These slides and additional material: bitbucket.org/Maurizio_Tomasi/adass2018-julia ▶ For questions, feel free to ask me or write me an email: maurizio.tomasi@unimi.it Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 20. Backup slides Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 21. Calculations with NumPy arrays Consider this code, where all the parameters for f are NumPy arrays: def f(r, x1, x2, x3, x4): r = x1 - x2 + x3 - x4 This code is executed by NumPy as if it were tmp = x1 - x2 tmp += x3 r = tmp - x4 thus three for loops are ran. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 22. Performance of NumPy codes 2 3 4 5 6 7 8 Number of terms in the expression 1 2 3 4 5 6 7 8 9 Besttime(100runs)[ms] Python 3.6.6 + NumPy 1.15.1 Source codes available at github.com/ziotom78/python-julia-c-. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 23. Calculations with C++ vectors In C++, the code needs to be written in this way: for(size_t i = 0; i < r.size(); ++i) { r[i] = x1[i] - x2[i] + x3[i] - x4[i]; } We need to write the for loop explicitly, but there is only **one* of them. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 24. Performance of NumPy/C++ codes 2 3 4 5 6 7 8 Number of terms in the expression 1 2 3 4 5 6 7 8 9 Besttime(100runs)[ms] Python 3.6.6 + NumPy 1.15.1 G++ 7.3.0, flags -O3 -march -msse3 Source codes available at github.com/ziotom78/python-julia-c-. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 25. Performance of Julia programs # 4 terms f(r, x1, x2, x3, x4) = @. r = x1 - x2 + x3 - x4 g(r, x1, x2, x3, x4) = @. r = x1 - x2 + x3 h(r, x1, x2, x3, x4) = @. r = x1 - x2 # Etc. The @. macro fuses all the operations on loops. Thus, f above is equivalent to function f(r, x1, x2, x3, x4) for i in eachindex(r) r[i] = x1[i] - x2[i] + x3[i] - x4[i] end end Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 26. Performance of NumPy, C++, and Julia codes 2 3 4 5 6 7 8 Number of terms in the expression 1 2 3 4 5 6 7 8 9 Besttime(100runs)[ms] Python 3.6.6 + NumPy 1.15.1 G++ 7.3.0, flags -O3 -march -msse3 Julia 1.0.2 Source codes available at github.com/ziotom78/python-julia-c-. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 27. Using SIMD instructions in Julia C++ was given an unfair advantage, as it was allowed to use SIMD instructions (-msse3). Moreover, it did not check array boundaries (Julia does automatically). In Julia, we can use the @inbounds and @simd macro to make Julia code equivalent to C++: function f(r, x1, x2, x3, x4) @inbounds @simd for i in eachindex(r) r[i] = x1[i] - x2[i] + x3[i] - x4[i] end end Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 28. Performance of NumPy, C++, and Julia codes 2 3 4 5 6 7 8 Number of terms in the expression 1 2 3 4 5 6 7 8 9 Besttime(100runs)[ms] Python 3.6.6 + NumPy 1.15.1 G++ 7.3.0, flags -O3 -march -msse3 Julia 1.0.2 Source codes available at github.com/ziotom78/python-julia-c-. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)
  • 29. Performance of NumPy, C++, and Julia codes 2 3 4 5 6 7 8 Number of terms in the expression 1 2 3 4 5 6 7 8 9 Besttime(100runs)[ms] Python 3.6.6 + NumPy 1.15.1 G++ 7.3.0, flags -O3 -march -msse3 Julia 1.0.2 Julia 1.0.2, with @inbounds @simd Source codes available at github.com/ziotom78/python-julia-c-. Towards new solutions for scientific computing: the case of Julia (Maurizio Tomasi, Mosè Giordano) ADASS 2018 (Nov 15 2018)