YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Problem Set 2 - Intro to Parallel Programming

Get Embed Code
2 Languages

Showing Revision 4 created 05/24/2016 by Udacity Robot.

  1. In Problem Set #2 you will be implementing a parallel algorithm for blurring images.
  2. Here is an example of the effect we're talking about.
  3. Here's your original image and here's the image after we apply a blur effect to that original image.
  4. Blurring an image involves averaging a local neighborhood of pixels,
  5. and it is expressed naturally using a parallel stencil operation.
  6. Stencil operations come up all the time in all types of application domains.
  7. This is why we are going to focus in on stencil in this homework.
  8. Let's take a closer look at a simple example demonstrating the kind of local averaging that we are talking about here.
  9. Suppose we have the following pixel representation of an image,
  10. and we want to calculate the average intensity value for this pixel right here.
  11. What do we do?
  12. First we take the value of this pixel, and then we add this value to the value of all its neighbors.
  13. So 10 4 6 2 1 2 3 and 6, and once when we add up all these values then we take the average.
  14. Since we have 9 elements or 9 pixels here, then we multiply the sum by 1/9,
  15. and that is how you would calculate the average intensity value for a pixel in an image.
  16. If we do this operation for every pixel in the image,
  17. we will arrive at a blurred version of input image.
  18. However it turns out that performing an unweighted average of pixels can sometimes look really ugly,
  19. and we can achieve a better looking blur by computing a weighted average of these pixels.
  20. What I mean by weighted average is the following.
  21. Rather than multiplying 1/9 to each pixel value here, we will multiply each pixel value by a different weight.
  22. So w1 is different than w2. And w2 may be different than w3.
  23. And w3 may be different than w4.
  24. And that is the approach that we will take in Problem Set #2.
  25. Here is an image produced by weighted blur,
  26. and here is an image produced by unweighted blur,
  27. and as you can see that the weighted blur
  28. is much smoother than the unweighted blur counterpart.
  29. In this problem set we will give you a small 2D array that contains weight values between 0 and 1 as follows.
  30. But this is just an example.
  31. The actual weight values that we will use will look like this:
  32. the smooth shape of the weights, as you can see here,
  33. will produce the nice looking blur effect that we saw earlier.
  34. And also, here's a note.
  35. We will blur color images by blurring each color channel independently,
  36. and we will include a more detailed mathematical formula on blurring computations in the instructor comments.
  37. This is what you need to do for Problem Set #2.
  38. First, you will need to write the actual blur kernel.
  39. Second, you will need to actually write the kernel that separates the color image to its R, G, B channels.
  40. And third we will give you the opportunity to allocate memory on the device for the filter,
  41. so you will have an opportunity to code CUDA mem copies.
  42. And fourth, you will have to set the correct or the optimal grid and block size for this problem set.
  43. And, as you remember in Problem Set #1,
  44. the grid and the block size has a huge impact on your program's execution time.
  45. Set the size correctly and be careful.
  46. Lastly your submission will be evaluated based on correctness and speed.
  47. But we recommend that you focus on correctness first.
  48. Then after your blurring kernal is run correctly then we recommend that you try to make it run faster.
  49. And lastly we have supplied serial code that you can reference and compare your solution against.
  50. Good luck on writing Problem Set #2.
  51. If you have any questions, feel free to ask in the class forums.