2024-heraklion-parallel-python/exercises/exerciseC
2024-08-30 09:24:04 +03:00
..
images upload smaller images 2024-08-29 23:54:01 +02:00
plot.py update exerciseC 2024-08-29 23:17:47 +02:00
process_images.py update exerciseC 2024-08-29 23:17:47 +02:00
README.md updated readmes for exercises 2024-08-29 19:00:45 +03:00
run_with_all_configurations.sh exC: make script executable 2024-08-30 09:24:04 +03:00

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).