39 lines
1.7 KiB
Markdown
39 lines
1.7 KiB
Markdown
# 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).
|