Top Banner
The Julia Language Seminar Talk Francisco Vidal Meca Languages for Scientific Computing Aachen, January 16, 2014
23

The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

May 25, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

The Julia LanguageSeminar Talk

Francisco Vidal Meca

Languages for Scientific Computing Aachen, January 16, 2014

Page 2: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Why Julia?

Many languages, each one a trade-offMultipurpose language:

scientific computingmachine learningdata mininglarge-scale linear algebradistributed and parallel computing

"In short, because we are greedy. (We) want to have it all." [1]

The Julia Language 3

Page 3: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Julia and Scientific Computing

Julia is "A fresh approach to technical computing"

High level and highperformanceEasy syntaxParallelism & CloudcomputingGraphsFree and Open sourceDeveloped in the MITVersion 1.0 releasedFebruary 2012

The Julia Language 4

Page 4: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

About Julia

Multi-paradigmHomoiconicDynamicEasy integration with C/FortranMultiple-dispatchJust-in-time(JIT) LLVM-based compilerFree and open source

Core under MIT licenseLibraries under GPL, LGPL, BSDEnvironment under GPL

Numerical accuracy

The Julia Language 6

Page 5: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Parallelism and Cloud computing

Key factor in Julia’s designBuilding blocks fordistributed computationMultiple worker processes

LocalRemote

Different from otherenvironments such as MPI

Built on remote referencesand remote callsSimplified with macros,e.g., @paralell

Examplefunction TicToc(N)

tic();nh = @parallel (+) for i=1:N

int(randbool())end;s=toc();println("Num. Heads: $nh ")println("in $s seconds")

end

The Julia Language 7

Page 6: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Mathematical functions

Extensive Math function library

Integrates C and Fortran librariesLinear AlgebraRandom number generationSignal processingString processing

The Julia Language 8

Page 7: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Integration

Calling external functions in C/FortranNeed to be Shared LibraryCalled directly with ccal

Exampleccal((:function,"library") ,RetType,InputTypes,Inputs)

julia> t = ccall( (:clock, "libc"), Int32, ())2292761

julia> t2292761

The Julia Language 9

Page 8: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Performance

101

102

100

10-1

104

103

MatlabGo RMathematicaPythonFortran OctaveJavaScriptJulia

benchmark

fib

mandel

pi_sum

rand_mat_mul

rand_mat_stat

printfd

quicksort

parse_int

Figure: Benchmark times [1] relative to C 1.

1Smaller is better, C performance = 1.0

The Julia Language 10

Page 9: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Plotting with Julia

Not in the core Julia System

Add-on package "Winston"

Julia and GNUplot

inset

−1

−0.5

0

0.5

1

0 1 2 3 4 5 6

−1

−0.5

0

0.5

1

0 1 2 3 4 5 6

Figure: Error bars and plotcomposition.

The Julia Language 11

Page 10: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

title!

−1

−0.5

0

0.5

1

Θi

0 2 4 6 8Σx2i

a points

b points

slope

0

20

40

60

80

100

0 20 40 60 80 100

title

x label

−1

−1/2

0

1/2

1

right

10 100 1000top

−1

−0.5

0

0.5

1

left

3 4 5 6 7 8 9bottom

The Julia Language 12

Page 11: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Developer community

External packagesBuilt in package managerIJulia

Browser-based graphicalnotebook interfaceIPython and JuliacommunityE.g.: Prof. Edelman’snotes for the ParallelComputing class

Active communityMailing listGitHubYoutube channel“JuliaLanguage”StackOverflowUsers meetup (today inSan Francisco Bay Area). . .

The Julia Language 13

Page 12: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Conclusion

Multi-purpose languageHigh level and easy syntaxHigh performanceGraphsParallelism & CloudcomputingIntegrationFree and Open Source

UsesBigFloats, Combinatorics,StatisticsLAPACK for Linear algebraSuiteSparse for SparsefactorizationsProvides BLAS functionswrappersSignal processing, FFTfunctions from FFTW

The Julia Language 15

Page 13: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Conclusion

Multi-purpose languageHigh level and easy syntaxHigh performanceGraphsParallelism & CloudcomputingIntegrationFree and Open Source

Example

function mandel(z)c = zmaxiter = 80for n = 1:maxiter

if abs(z) > 2return n-1

endz = z^2 + c

endreturn maxiter

end

The Julia Language 15

Page 14: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Conclusion

Multi-purpose languageHigh level and easy syntaxHigh performanceGraphsParallelism & CloudcomputingIntegrationFree and Open Source

101

102

100

10-1

104

103

MatlabGo RMathematicaPythonFortran OctaveJavaScriptJulia

benchmark

fib

mandel

pi_sum

rand_mat_mul

rand_mat_stat

printfd

quicksort

parse_int

The Julia Language 15

Page 15: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Conclusion

Multi-purpose languageHigh level and easy syntaxHigh performanceGraphsParallelism & CloudcomputingIntegrationFree and Open Source

The Julia Language 15

Page 16: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Conclusion

Multi-purpose languageHigh level and easy syntaxHigh performanceGraphsParallelism & CloudcomputingIntegrationFree and Open Source

Example

dzeros(100,100,10)dones(100,100,10)drand(100,100,10)dfill(x, 100,100,10)

The Julia Language 15

Page 17: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Conclusion

Multi-purpose languageHigh level and easy syntaxHigh performanceGraphsParallelism & CloudcomputingIntegrationFree and Open Source

Easy integration withCFortranShellPipes

The Julia Language 15

Page 18: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

So. . . what is Julia?

“Julia has the performance of a statically compiled languagewhile providing the interactive, dynamic experience andproductivity that scientists have come to expect....Julia is a game changer for high performance computing." [4]

Try Julia! Online Julia + tutorialhttp://forio.com/julia/repl/

The Julia Language 16

Page 19: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

References

Leah HansonShah, V.; Edelman, A.; Karpinski, S.; Bezanson, J.; Kepner, JThe Julia Language (Last accessed on Jan 2014)http://julialang.org

Leah HansonLearn Julia in Y minutes (Last accessed on Nov 2013)http://learnxinyminutes.com/docs/julia/

Douglas EadlineParallel Julia (Last accessed on Dec 2013)HPC - ADMIN Magazine http://www.admin-magazine.com/HPC/Articles/Parallel-Julia-Jumping-Right-In

Shah, V.; Edelman, A.; Karpinski, S.; Bezanson, J.; Kepner, JNovel algebras for advanced analytics in JuliaHigh Performance Extreme Computing Conference (HPEC), 2013

The Julia Language 17

Page 20: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Demo and examples

See how Julia works:1 @parallel example and number of processors2 Alternating harmonic series approximation3 Plots

Feel free to ask!

The Julia Language 18

Page 21: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Performance (2)

Figure: Benchmark times [1] relative to C.

The Julia Language 19

Page 22: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

IJulia

Figure: IJulia Screenshot

The Julia Language 20

Page 23: The Julia Language - RWTH Aachen Universityhpac.rwth-aachen.de/teaching/sem-lsc-13/Julia.pdf · “Julia has the performance of a statically compiled language while providing the

Debugging in Julia

Debugging is possible in JuliaNot integrated (yet) into the core language

Only guidelines to debug Julia’s C code in the FAQ section 2

Found some documentation about it in GitHubJulia Debugging Procedures using GDB 3

Prototype interactive debugger “Debug” as external package 4

2http://docs.julialang.org/en/latest/manual/faq3https://gist.github.com/staticfloat/61884184https://github.com/toivoh/Debug.jl

The Julia Language 21