Summary and Schedule
This is a lesson on “Efficient Computing with Julia”.
Synopsis
The Julia programming language is getting more and more popular as a language for data analysis, modelling and optimization problems. It promises the ease of Python or R with a run-time efficiency closer to C or Fortran. Julia also is a more modern language with a packaging ecosystem that makes packages easier to install and maintain. A programmer that is familiar with Python, R or Matlab should have little problem getting up to speed with the basics of Julia. However, to really obtain the promised near native run-time efficiency is a different skill altogether.
This workshop aims to get research software engineers (experienced in another programming language) from their first steps in Julia to become aware of all the major techniques and pitfalls when it comes to writing performant Julia.
We will work hands-on with real-world examples to explore concepts in the Julia language, focussing on differences with other languages. After the first day, you will be familiar with the basic constructs of the language, some popular libraries, and its package manager, including unit testing and documentation.
The second day we will dive deeper in making Julia code fast to run. We’ll see how to benchmark and profile code, and find out what is fast and slow. This means getting to grips with Julia’s type system and its compilation strategy. We will close the day with parallel programming and using the GPU to make our code even faster.
Syllabus
- Basics of Julia: build a model of our solar system
- operations, control flow, functions
-
Unitful
quantities,Dataframes
and plotting withMakie
- types and dispatch
- arrays and broadcasting
- Package development: solving Cubic equations
- working with the REPL, and
Pkg
- best practices with
BestieTemplate
- testing with
Test
, documentation withDocumenter
- working with the REPL, and
- Faster code: a logistic population model
-
BenchmarkTools
andProfileView
(flame graphs) - Optimisation techniques
- The type system in more depth
- Type stability
- Parallel programming:
Threads
and GPU programming (with Julia fractals)
-
Who
This workshop is aimed at scientists and research engineers who are already familiar with another language like Python, Matlab or R. The basics of Julia will be introduced, but it is essential that participants are familiar with programming concepts and are comfortable working with a programming editor and command-line interfaces.
Participants should bring a decent laptop (no chrome book) with the latest version of Julia installed and working (instructions will be provided after registration).
Setup Instructions | Download files required for the lesson | |
Duration: 00h 00m | 1. Getting Started |
Why should I use Julia? How do I get started with Julia? ::: |
Duration: 00h 50m | 2. Introduction to Julia |
How do I write elementary programs in Julia? What are the differences with Python/MATLAB/R? ::: |
Duration: 01h 00m | 3. Types and Dispatch |
How does Julia deal with types? Can I do Object Oriented Programming? People keep talking about multiple dispatch. What makes it so special? ::: |
Duration: 01h 10m | 4. Simulating the Solar System |
How can I work with physical units? How do I quickly visualize some data? How is dispatch used in practice? ::: |
Duration: 01h 20m | 5. Packages and environments |
How do I work with environments? What are these Project.toml and Manifest.toml files?How do I install more dependencies? ::: |
Duration: 01h 30m | 6. Package development |
How do I generate a new Julia package that follows best
practices? What is the best workflow for developing a Julia package? How can I prevent having to recompile every time I make a change? ::: |
Duration: 01h 40m | 7. Best practices |
How do I setup unit testing? What about documentation? Are there good Github Actions available for CI/CD? I like autoformatters for my code, what is the best one for Julia? How can I make all this a bit easier? ::: |
Duration: 01h 50m | 8. Type Stability |
What is type stability? Why is type stability so important for performance? What is the origin of type unstable code? How can I prevent it? ::: |
Duration: 02h 00m | 9. Reducing allocations on the Logistic Map |
How can I reduce the number of allocations? ::: |
Duration: 02h 10m | 10. Value types: game of life |
How can I use dispatch to implement different versions of a
function? How can I optimise against memory allocations of small arrays? ::: |
Duration: 02h 20m | 11. Threads, ASync and Tasks |
How do we distribute work across threads? ::: |
Duration: 02h 30m | 12. GPU Programming |
Can I have some Cuda please? ::: |
Duration: 02h 40m | 13. Recap and Recommended libraries |
Is there a recommended set of standard libraries? What is the equivalent of SciPy in Julia. ::: |
Duration: 02h 50m | 14. Appendix: Iterators and type stability |
I tried to be smart, but now my code is slow. What happened? ::: |
Duration: 03h 00m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
Setup
This workshop is always taught using the latest release version of Julia. We use VS Code as our main environment. Depending on your experience, setting up your environment should take around 30min - 1h. We encourage you to also spend 1-2h exploring the Julia Manual.
Equipment
You need a decent laptop with priviliges to install software. Julia is a compiled language and compiling can be demanding on your CPU. Specifically, something like a Chromebook or similar will definitely not do.
Install Dependencies
Prepare the courses package environment. Create a directory that you will work in:
Press ]
to enter package mode:
JULIA
(@v1.11) pkg> activate .
(EfficientJulia) pkg> add GLMakie DataFrames BenchmarkTools GeometryBasics IterTools Revise Unitful StaticArrays Images FileIO
This may take a while (which is why you need to do it in advance).
VS Code
Install VS Code. VS Code is the de-facto standard IDE for Julia. Within VS Code, install the Julia language plugin. Press the puzzle-piece icon in the toolbar and search for Julia, the top result should be the official extension.
Prepare
If you have time, explore the Julia Manual. This is not mandatory, but you will learn a lot more in the workshop if you are prepared. Skim through from “Getting Started” until (including) “Methods”, and spend one or two hours trying out things that you find interesting, while enjoying a nice cup of your favourite hot beverage.