Skip to content

Commit b147668

Browse files
authored
Merge pull request #65 from MonashDeepNeuron/dev
HPC Training Book v1.3.1 - Distributed computing challenges rework
2 parents f11c44a + c5efccf commit b147668

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
- [What is Distributed Computing](./chapter5/distributed-computing.md)
4848
- [Message Passing](./chapter5/message-passing.md)
4949
- [OpenMPI](./chapter5/openmpi.md)
50+
- [Challenges](./chapter5/challenges.md)
5051

5152
[Acknowledgements](./acknowledgements.md)

src/chapter5/challenges.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
1-
# Challenges
1+
# Distributed Computing Challenges
22

3-
🚧 Under Construction! 🏗️
3+
## Overview
44

5-
## Install MPI for the tasks
5+
- [Distributed Computing Challenges](#distributed-computing-challenges)
6+
- [Overview](#overview)
7+
- [Pre-Tasks](#pre-tasks)
8+
- [Task 1 - Multinode 'Hello, world!'](#task-1---multinode-hello-world)
9+
- [Task 2 - Ping Pong](#task-2---ping-pong)
10+
- [Task 3 - Multinode Sum](#task-3---multinode-sum)
11+
- [Task 4 - Multinode Mergesort](#task-4---multinode-mergesort)
612

7-
- ```~/vf38/HPC_Training/spack/share/spack/setup-env.sh``` #configure spack
8-
- ```spack load mpich``` #load MPICH through spack
9-
- ```module load gcc``` #load gcc
10-
- ```cp -r ~/vf38/HPC_Training/MPI_examples ~``` #copy tasks to your home directory
13+
## Pre-Tasks
1114

12-
## Task 1: Hello World
15+
For each task you will need to load MPICH using Spack from within your SLURM job script. There is a shared installation of Spack and MPICH within `vf38_scratch`. To load Spack and MPICH use the following to commands within you SLURM job script before any other command.
1316

14-
1. Go to folder ‘hello’
15-
2. Modify the files
16-
3. Compile mpi_hello_world.c using makefile
17-
4. Execute the file
17+
```sh
18+
. ~/vf38_scratch/spack/share/spack/setup-env.sh
19+
spack load mpich
20+
```
1821

19-
## Task 2: Ping Pong
22+
A template SLURM job file is given at the root of the distributed challenges directory. Copy this for each challenge into their respective sub-directories as every challenge will require running a SLURM job. If want to do some more experimenting, create multiple job scripts that use different amounts of nodes and test the execution time.
2023

21-
1. Go to ‘ping_pong’ folder
22-
2. Modify the files
23-
3. Compile the files
24-
4. Run (world size must be two for this file)
24+
You will also need to generate some input for the sum and mergesort challenges. This can be done by compiling and running the program in `generate.cpp`. Run the following commands to build an generate the inputs for your challenges.
2525

26-
Output should be similar to this. May be slightly different due to process scheduling
26+
```sh
27+
module load gcc/10.2.0
28+
g++ -std=c++20 -o bin/generate generate.cpp
29+
bin/generate 1000000000
30+
```
2731

28-
![Ping pong](imgs/ping_pong.png)
32+
> Note:
33+
>
34+
> - You do not have to worry about how to read the numbers from the file, this is handled for you already but it is recommended to look at the read function in `read.h` and understand what it is doing.
35+
> - The expected output of the 'sum' challenge is found in the generated `output.txt` file within the challenges directory.
36+
> The expected output of the 'mergesort' challenge is found in the generated `sorted.txt` file within the challenges directory however this will contain a lot of values so a check function is provided that compares a resorted version of your input to your sorted output.
37+
> The sum and mergesort programs you will develop take a number as input. This is the size of the input data that you are performing your programs on. This should be the same number as the one used with the generator program. In the template programs for this challenge they are maked as an pointer to data called `input`.
38+
> Given the above setup and configuration, the input data will contain ~8GB of data or ~8.0e9 bytes so make sure to allocate enough resources both in the programs an in the SLURM job scripts.
2939
30-
## Task 3: Monte Carlo
40+
## Task 1 - Multinode 'Hello, world!'
3141

32-
- Run “./calcPiSeq 100000000” # make sure you use gcc for compiling serial code
33-
- Modify calcPiMPI.c
34-
- Run calcPiMPI 100000000 with mpi and see the difference. You can change the number of processes. However, please be mindful that you are in login node!
35-
Hint: # <https://www.mpich.org/static/docs/v3.3/www3/MPI_Reduce.html>
42+
Your first task is to say 'Hello, world!' from different nodes on M3. This involves printing the nodes name, rank (ID) and the total number of nodes in the MPI environment.
3643

37-
## Task 4: Parallel computing task on compute nodes
44+
## Task 2 - Ping Pong
3845

39-
- Submit your parallelised Monte Carlo task on compute nodes with 8 tasks
46+
For this next task you will play a Ping-Pong game of sorts between two nodes. This will involve passing a count between the two nodes and incrementing the count for each send and receive. This should increment the count to 10 in the end.
4047

41-
## Task 5: Trapezoidal Rule Integration
48+
## Task 3 - Multinode Sum
4249

43-
- Run “./seq_trap 10000000000”
44-
- Modify calcPiMPI.c
45-
- Run seq_MPI 100000000000 with mpi and see the difference. You can change the number of processes. However, please be mindful that you are in login node!
50+
Your next task is to sum the numbers in the generated `input.txt` file together across ten nodes. This will involve summing 1,000,000,000 floats together. The rough expected output is contained in the `output.txt` file. Remember the input array is already given in the template file.
4651

47-
## Task 6: Bonus: Merge Sort
52+
## Task 4 - Multinode Mergesort
4853

49-
- This task is quite challenging to parallelise it yourself
50-
- Please refer to the answer and check if you can understand it <https://selkie-macalester.org/csinparallel/modules/MPIProgramming/build/html/mergeSort/mergeSort.html>
51-
52-
Additional resources: <https://selkie-macalester.org/csinparallel/modules/MPIProgramming/build/html/index.html>
54+
Your final task is to sort the numbers from the input file `unsorted.txt` using a distributed version of mergesort. This will involve ten nodes running their won mergesorts on chunks of the input data individually and then a final mergesort of the intermediate results. Remember the input array is already given in the template file.

0 commit comments

Comments
 (0)