Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Parallel Computing Challenges Section #47

Merged
merged 5 commits into from
May 1, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions src/chapter4/challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,57 @@

## Task 1 - Parallise `for` Loop

Goal: To to create an array `[0,1,2...19]`
Goal: To to create an array `[0,1,2...100000]`

1. Git clone [HPC-Training-Challenges](https://github.com/MonashDeepNeuron/HPC-Training-Challenges)
2. Go to the directory “challenges/parallel-computing”. Compile array.c and execute it. Check the run time of the serial code
3. Add `#pragma<>`
4. Compile the code again
5. Run parallel code and check the improved run time
2. Go to the directory “challenges/parallel-computing” and open `array.c` file
k493r0 marked this conversation as resolved.
Show resolved Hide resolved
3. Implement the code to create an array `[0,1,2...100000]` without parallelisation
4. Measure the run time of the code
5. Use `#pragma<>` and potentially other clauses to parallelise the code
6. Compile the code again and check the run time and observe the result

## Task 2 - Run task 1 on HPC cluster

1. Check the available partitions with `show_cluster`
2. Modify `RunHello.sh `
3. `sbatch RunHello.sh`
4. `cat slurm<>.out` and check the run time
1. Log into M3
2. Check the available partitions with `show_cluster`
3. Modify `RunHello.sh` to you can run `array.c` on HPC cluster
4. Submit the job to M3
5. Check the slurm output file

>You can also use [strudel web](https://beta.desktop.cvl.org.au/login) to run the script without sbatch

## Task 3 - Reduction Clause

Goal: To find the sum of the array elements

1. Compile `reduction.c` and execute it. Check the run time
2. Add `#pragma<>`
3. Compile `reduction.c` again
4. Run parallel code and check the improved run time. Make sure you got the same result as the serial code
1. Implement the code in `reduction.c` to find the sum of the array elements without parallelisation
2. Measure the run time of the code
k493r0 marked this conversation as resolved.
Show resolved Hide resolved
3. Add `#pragma<>` and potentially other clauses to parallelise the code
4. Compile and run `reduction.c` again
5. Check the run time and observe the result

>`module load gcc` to use newer version of gcc if you have error with something like `-std=c99`

## Task 4 - Private clause

The goal of this task is to square each value in array and find the sum of them
1. Compile private.c and execute it. Check the run time. `#include` the default library `<math.h>` and link it
2. Add `#pragma<>`
3. Compile `private.c` again
4. Run parallel code and check the improved run time

1. Implement the code in `private.c` to square each value in array and find the sum of them without parallelisation
k493r0 marked this conversation as resolved.
Show resolved Hide resolved
2. Measure the run time of the code. (You may need to link the math library with `-lm`)
3. Add `#pragma<>` and potentially other clauses to parallelise the code
4. Compile `private.c` again and check the run time and observe the result

## Task 5 - Calculate Pi using "Monte Carlo Algorithm"

Goal: To estimate the value of pi from simulation

- No instructions on this task. Use what you have learnt in previous tasks to run a parallel code!
- You should get a result close to pi(3.1415…….)
1. Implement Monte Carlo in `MonteCarlo.c` without parallelisation
2. Measure the run time of the code
3. Parallelise the code
4. Compile and run `MonteCarlo.c` again
5. Check the run time and observe the result

> You should get a result close to pi(3.1415…….)

Short explanation of Monte Carlo algorithm:

Expand All @@ -55,9 +64,9 @@ Short explanation of Monte Carlo algorithm:

## Bonus - Laplace equation to calculate the temperature of a square plane

- Modify `laplace2d.c`
- Use Makefile to compile the code
- Make the program as fast as you can
1. Modify `laplace2d.c` and implement the laplace algorithm
2. Use Makefile to compile the code
3. Make the program as fast as you can

Brief Algorithm of Laplace equation:
![](imgs/Pasted%20image%2020230326142826.png)