Computer Science 296
Parallel Programming
Due October
16, midnight.
In this assignment you are to implement a parallel version of the median filter image processing algorithm. The basic idea is to compute a new value for a given pixel based on the neighboring pixel values. The neighboring pixels are called the window over which the filter is applied. A simple filter is the 3x3 mean filter, that sets the value to the average of the square of 9 pixels centered on the pixel for which the new value is computed. A C version of the serial program for computing the mean filter (3x3) is available at ~alvy/public_parprog/meanfilter. Please copy these files to your own directory.
You can compile and execute the program as follows:
% make
% ./meanfilter
This program reads in a bitmap image stored in the file img.bmp and produces a new file called img-new.bmp (yes the file names are hard coded, you can change that). There are two bitmap images for you to work with, one is small (Portrait.bmp) and the other is a little larger (GreenSeaTurtle.bmp).
You assignment is to write a CUDA program to implement a 3x3 median filter. The median filter sets a pixel value to the median value of the neighboring 9 pixels.
You can run your program on any system with nVidia graphics cards that support CUDA. The CS department has one machine, called Picasso that already has CUDA installed. To use it you need to add /usr/cuda/bin to your path. Cuda Programming Guide is here.
CUDA programs are compiled using nVidia’s compiler nvcc. This modified compiler understands CUDA specific additions in your program. To see how this works, there is a simple vector addition program (from the programming guide) in ~alvy/public_parprog/vecAdd/. The file vecadd.cu is a simple vector addition program that you can compile by running nvcc vecadd.cu this will produce the file a.out. Execute a.out (e.g., ./a.out) to see the output of one element in the vector (note, you must be on Picasso or some other machine with CUDA installed).
Each file submitted needs to contain your name and email address.
What to submit:
1. Source code for the CUDA version of the median filter program (well commented).
2. Binary for parallel version of program (that you know executes correctly on Picasso).
3. README with documentation on how to compile and run your programs and explanation of general approach to parallelize the algorithm.
How to submit:
On any Computer Science linux or solaris machine (e.g., linux.cs.duke.edu, login.cs.duke.edu), run the program submit_cps296.3 prog2 <file1> <file2>…
I recommend that you submit a single file that is a tar gzipped file. (note: depending on which tar you use, this can be one command)
% tar –cvf medianfilter.tar <prog_directory>
% gzip medianfilter.tar
% submit_cps296.3 prog3 medianfilter.tar.gz