compiler and communityJiahao Chen
MIT Computer Science and Artificial Intelligence Laboratory julialang.org
Alan EdelmanJeff Bezanson Stefan Karpinski Viral B. Shah
433 code contributors as of 2014-06-30
The faces of Julia
as of 2014-06-30
The world of181 package-only developers
252 contributors to julia repo3,906 stargazers321 watchers
What’s the big deal about Julia ?
Julia isn’t designed for performance using all means necessary.
“FFTW (FFTs) and BLAS libraries (matrix multiplication) take ~100,000 lines [of code] to solve problems that can be implemented in ~15 lines of (slow) code… It usually
isn’t worth it to get the last factor of two in speed” !
- Steven Johnson, author of FFTW (emphases his)
What’s the big deal about Julia ?
Julia isn’t designed for performance using all means necessary. Instead, performance comes from designing a language that is easy for both humans and compilers to understand. !Multimethods (multiple dispatch) is one of the key mechanisms.
Object-oriented programming with classes
What can I do with/to a thing?
Object-oriented programming with classes
What can I do with/to a thing?
Object-oriented programming with classes
What can I do with/to a thing?
top uppay fare
lose
buy
Object-oriented programming with classes
What can I do with/to a thing?
top uppay fare
lose
buy
top uppay fare
lose
buy
Object-oriented programming with classes
What can I do with/to a thing?
top uppay fare
lose
buy
top uppay fare
lose
buy
Object-oriented programming with classes
What can I do with/to a thing?
top uppay fare
lose
buy
top uppay fare
lose
buy
pay farelose
buy
methods objects
Object-oriented programming with classes
What can I do with/to a thing?
top uppay fare
lose
buy
top uppay fare
lose
buy
pay farelose
buy
methods objects
Object-oriented programming with classes
What can I do with/to a thing?
top uppay fare
lose
buy
top uppay fare
lose
buy
pay farelose
buy
class-based OO !classes are more fundamental than methods
generic function
objectsmethods
rechargeable subway pass
single-use subway ticket
is a subtype of
subway ticket
top up
pay fare
lose
buy
abstract object
Multi-methods with type hierarchy
generic function
objectsmethods
rechargeable subway pass
single-use subway ticket
is a subtype of
subway ticket
top up
pay farelose
buy
abstract object
Multi-methods with type hierarchy
Multi-methods for linear algebra
What can I do with/to a thing?
find eigenvalues and eigenvectors
find singular values
find singular values and vectors
find eigenvalues
generic function
objectsmethods
general matrix
symmetric tridiagonal matrix
bidiagonal matrix
Methods can take advantage of special matrix structures
eigvals
eigfact
svdvals
svdfact
Matrix
SymTridiagonal
Bidiagonal
So how does this help us with linear algebra?
Multi-method dispatch on special matrix types
So how does this help us with linear algebra?
Multi-method dispatch on special matrix types
So how does this help us with linear algebra?
Multi-method dispatch on special matrix types
stev!{T<:BlasFloat} calls sgestvdgestvcgestvzgestv
and handles workspace memory allocation
What’s the big deal about Julia ?
Julia isn’t designed for performance using all means necessary. Instead, performance comes from designing a language that is easy for both humans and compilers to understand. !!
from the programmer’s point of view: !- dynamic language semantics: faster to prototype code - dynamic types: compiler does not hinder experimentation - multiple dispatch allows both methods for general
functionality and methods for specialized performance - low-cost software abstractions allow code to retain
structure of mathematical abstractions - metaprogramming (with macros) allows code generation:
takes software experimentation to the next level with less lines of actual code
- flexible syntax, Unicode operators, great community…
Pure-‐Julia FFT performance
2 4 8 16 32 64 128
256
512
1024
2048
4096
8192
16384
32768
65536
131072
262144
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
11000
12000
13000
14000
spee
d (m
flops
)
intel-mkl-dfti in-placeintel-mkl-dfti out-of-placefftw3 out-of-placefftw3 in-placefftw3-no-simd out-of-placefftw3-no-simd in-placedfftpackemayerjuliabloodworthcrosscwplibesrfft
double-precision complex, 1d transformspowers of two
already comparable to FFTPACK ![ actually was even a bit better; some recent inlining regressions in Julia snapshots ]
Steven Johnson, 2014-06 Presented at NAIS Codegen workshop
from the compiler’s point of view: !- dynamic semantics with static analysis: when possible,
offload runtime checks to JIT compile stage - multiple dispatch requires function signatures that expose
type information - rich type system allows for detailed type inference - inlining passes reduce abstraction cost - automatic code specialization generates many performant
methods - macros allow further fine-grained tradeoffs between
performance and correctness, e.g. @inbounds, @simd,…
Top Related