Lab: Parallelized Image Restoration

CSC 213 - Operating Systems and Parallel Algorithms - Weinman



Summary:
You will devise a synchronization strategy for a parallel multi-threaded implementation of an algorithm for cleaning up noisy images.
Assigned:
Tuesday 30 October
Due:
This assignment will be due in two parts.
Part A
5:15 PM Monday 10 November
Parts B,C
11:30 PM Monday 17 November
Objectives:
 
Reading:
A Brief Introduction to Iterated Conditional Modes (ICM), which provides background on the algorithm we'll be using.

Preliminaries

Exercises

Part A: Algorithm design

Now you will devise a parallel implementation of the ICM algorithm. With sufficient processing power, each iteration could take constant time, rather than time proportional to the size of the image.
Assume that your algorithm will run as threads on a shared memory multiprocessor (e.g., a MathLAN workstation). There are several ways to partition the problem into a parallel implementation (the example in pinvert.c, which is likely similar to your prior parMtxMultiply, is one partitioning), but your parallel implementation must meet requirements: Write a design paper that addresses the following: Hint: One nice solution to this problem extends the barrier pattern so that it is reusable. In other words, the barrier can be used within a loop. The key is to create, in addition to a turnstile that ensures all threads rendezvous at the beginning of a section of code, another turnstile that syncs them at the end of the looped code. This prevents one thread from "lapping" another by getting ahead one iteration. While the first "in" turnstile is only unlocked once all threads have arrived (by incrementing and testing a variable), the second "out" turnstile is only unlocked when all threads have completed (by decrementing and testing the same variable.)

Part B: Implementation

Begin the multi-threaded version (using POSIX threads) of your parallel algorithm by copying the original icm.c
cp icm.c picm.c
modifying the existing functions, and introducing any new functions necessary. Cite and attribute the source of your new file. As you proceed, clearly separate which portions are exclusively yours, which are faithful to the original, and which you have modified.
Compile the picm program using the Makefile (which should already have a line for it).
make picm
Like icm, your program picm should accept the filenames of an input and an output image. It should also take as a command-line parameter the number of threads to create.
Preserve the wall clock timer that measures only algorithm time (disk I/O dominates the overall time).
The parallel and single-thread versions should produce the same results on all images. To assert this, the command diff(1) will tell you whether two files are the same. If you want to create an image that shows you the difference between two images (rather than just whether there is a difference), you can use the handy program compare(1)
compare image1.pbm image1.pbm differences.png
which will overlay the differences in red pixels in output images differences.png on top of a matted version of image1.pbm. For a simple binary output, use differences.pbm, which will be black where pixels differ and white where they're the same.

Part C: Performance evaluation

Revise your design from part A to include any changes you made and any other feedback.
Integrate your revised design with an evaluation that presents the behavior of your algorithm, including the following elements.
Setup
Note the experimental setup, including the number of cores on your machine, image size, algorithm parameters, etc.
Experiment
Record the times used by both the single- and multi-threaded programs (with 1, 2, 3, and 4 threads) for one of the noisy palisade images.
Results
Present the timing results in a nicely formatted table.

What to turn in

Part A
A single PDF of your algorithm design.
Parts B and C
 

Acknowledgments

Janet Davis contributed notable improvements to the text. The public domain Palisade image is by the Pearson Scott Foresman company. The Dilbert image is Copyright 2008 Scott Adams, Inc.
Copyright © 2012, 2014 Jerod Weinman.
ccbyncsa.png
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.