2024-heraklion-parallel-python/Exercise2a/README.md

45 lines
1.5 KiB
Markdown
Raw Normal View History

2024-08-29 11:19:39 +02:00
# Exercise 2b
Execute numpy code with multiple threads.
```NOTE``` Remember to use `htop` in your terminal to track what the CPUs are doing.
## First
Use the script `heavy_computation.py` with different numbers of threads.
`OMP_NUM_THREADS` can be used to override the number of threads used:
```
OMP_NUM_THREADS=7 python heavy_computation.py
```
The script will save the timing results into a `timings/` folder as `.txt` files.
> What happens if `OMP_NUM_THREADS` is not set? How many threads are there? Why?
## Second
Plot the timing results from the first part, we wrote the IO for you in `timing_plot.py`.
1. Plot a graph of execution duration vs. the number of threads
2. Plot the execution speedup with respect to running a single-threaded process
Open a PR with your plotting code and post your plots in the conversation, don't upload binaries to the Git remote!
> What does the result tell us about the optimum number of threads? Why?
> Does it take the same time as your colleagues to run? Why?
## Extra
Investigate the runtime variability. Systematically run multiple instances with the same number of threads by modifying `heavy_computation.py`.
### Extra extra
How is the runtime affected when the problem becomes bigger? Is the optimum number of threads always the same?
How is the runtime affected when the memory is almost full? You can fill it up by creating a separate (unused) large numpy array.
How about running on battery vs having your laptop plugged in?