Thread parallelism¶
Learning outcomes
- Understand how to schedule jobs with threaded parallelism
- Understand how code achieves threaded parallelism
- Observe or conclude the costs of threaded parallelism
For teachers
Teaching goals are:
- Schedule and run a job that needs more cores, with a calculation in their favorite language
- Learners have scheduled and run a job that needs more cores, with a calculation in their favorite language
- Learners understand when it is possible/impossible and/or useful/useless to run a job with multiple cores
Prior:
- What is parallel computing?
Feedback:
- When to use parallel computing?
- When not to use parallel computing?
Why thread parallelism is important¶
Type of parallelism | Number of cores | Number of nodes | Memory | Library |
---|---|---|---|---|
Single-threaded | 1 | 1 | As given by operating system | None |
Threaded/shared memory | Multiple | 1 | Shared by all cores | OpenMP |
Distributed | Multiple | Multiple | Distributed | OpenMPI |
What is thread parallelism?¶
Calculations that can use multiple cores with a shared memory.
Slurm script¶
This is the script that schedules a job with threaded parallelism.
The goal of the script is to submit a calculation that uses threaded parallelism, with a custom amount of cores.
How do I run it?
You do not, instead you will run the benchmark script below.
However, you can run it as such:
For example:
HPC cluster | Julia Slurm script | MATLAB Slurm script | R Slurm script |
---|---|---|---|
Alvis | . | . | . |
Bianca | . | . | . |
COSMOS | . | . | . |
Dardel | . | . | . |
Kebnekaise | . | . | . |
LUMI | . | . | . |
Pelle | . | . | . |
Rackham | . | . | do_r_2d_integration_on_rackham.sh |
Tetralith | . | . | . |
Calculation script¶
This is the code that performs a job with threaded parallelism.
The goal of the code is to have a fixed unit of work that can be done by a custom amount of cores.
This calculation script is called by the Slurm script, i.e. not directly by a user.
How do I run it?
You do not, instead you will run the benchmark script below.
However, when not on a login node, you can run it as such:
For example:
Language | Script with calculation |
---|---|
Julia | TODO |
MATLAB | TODO |
R | do_2d_integration.R |
Benchmark script¶
This is the script that starts a benchmark, by submitting multiple jobs to the Slurm queue.
The goal of the benchmark script is to do a fixed unit of work with increasingly more cores.
As the script itself only does light calculations, you can run it directly, as such:
For example:
HPC cluster | Julia benchmark script | MATLAB benchmark script | R benchmark script |
---|---|---|---|
Alvis | . | . | . |
Bianca | . | . | . |
COSMOS | . | . | . |
Dardel | . | . | . |
Kebnekaise | . | . | . |
LUMI | . | . | . |
Pelle | . | . | . |
Rackham | . | . | R on Rackham |
Tetralith | . | . | . |
Analysis script¶
The goal of the analysis script is to observe the relation between the number of cores and core runtime.