updated readmes for exercises
This commit is contained in:
parent
86e99bb814
commit
af567b80b0
|
@ -30,7 +30,8 @@ In `plot.py`, we have given code that will load all of the timing data in `timin
|
||||||
|
|
||||||
**TASK**: Add code to plot of the execution duration vs. the number of threads
|
**TASK**: Add code to plot of the execution duration vs. the number of threads
|
||||||
|
|
||||||
Open a PR with your plotting code and post your plots in the conversation, don't upload binaries to the Git remote!
|
**TASK**: Open a Pull Request with your plotting code and post your plots in the
|
||||||
|
conversation. Don't upload binaries to the Git remote!
|
||||||
|
|
||||||
**OPTIONAL TASK**: Add code to calculate and plot the speed-up time compared
|
**OPTIONAL TASK**: Add code to calculate and plot the speed-up time compared
|
||||||
to single-threaded execution. Include your code and plot in the PR.
|
to single-threaded execution. Include your code and plot in the PR.
|
||||||
|
|
38
exercises/exerciseC/README.md
Normal file
38
exercises/exerciseC/README.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Exercise C: blending processes and threads
|
||||||
|
|
||||||
|
Objective: investigate how the number of processes and threads impacts the
|
||||||
|
speed-up time of a computation.
|
||||||
|
|
||||||
|
## First
|
||||||
|
|
||||||
|
For each of the 19 images in the folder `images/`, the `process_images.py`:
|
||||||
|
(1) decomposes the image using a singular-value decomposition (SVD), (2) removes the
|
||||||
|
largest singular value and (3) returns the reconstructed image. The script also measures
|
||||||
|
the time for the computation and saves the result in `timings/`.
|
||||||
|
|
||||||
|
You can change the number of processes and threads on a set of images by calling the function
|
||||||
|
as follows:
|
||||||
|
```python process_images.py 3 2 images/*```
|
||||||
|
The code above will use 3 processes and 2 threads to analyse everything in the folder `images/`.
|
||||||
|
|
||||||
|
**TASKS**:
|
||||||
|
0. Familiarize yourself with the code in `process_images.py`. Where is the number of
|
||||||
|
threads set in the code? Why is it set there? Where is the number of processes set
|
||||||
|
in the code?
|
||||||
|
1. Hypothesize what would be a good number of processes and threads for this exercise.
|
||||||
|
2. Try a couple combinations of processes and threads, look at the saved timings, and see if
|
||||||
|
the results match your expectations.
|
||||||
|
|
||||||
|
## Second
|
||||||
|
|
||||||
|
This folder also includes a bash script called `run_with_all_configurations.sh`.
|
||||||
|
|
||||||
|
**TASKS**:
|
||||||
|
0. Open the bash script. What does it do?
|
||||||
|
1. Execute the bash script in the terminal:
|
||||||
|
`bash run_with_all_configurations.sh`
|
||||||
|
Observe what's printed to screen. Does it match your expectations?
|
||||||
|
2. Open `plot.py` and see what it does. Run the script and view the results. Do they
|
||||||
|
match your expectations?
|
||||||
|
3. Add the image as a comment to the Pull Request you opened in Exercise A (or make a
|
||||||
|
new Pull Request if you need one).
|
|
@ -45,7 +45,7 @@ if __name__ == '__main__':
|
||||||
# we need to set the variable before numpy is imported!
|
# we need to set the variable before numpy is imported!
|
||||||
os.environ['OMP_NUM_THREADS'] = str(n_threads)
|
os.environ['OMP_NUM_THREADS'] = str(n_threads)
|
||||||
|
|
||||||
# We delay the import of numpy because we want to set OMP_NUM_THREADS.
|
# We delay the import of numpy because we have to set OMP_NUM_THREADS before import.
|
||||||
# We delay the import of PIL in case it uses numpy internally.
|
# We delay the import of PIL in case it uses numpy internally.
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
Loading…
Reference in a new issue