HP3 CUDA Programming

Parallel Programming on the GPU

Assignment 1 (b): Convolutions

Objective

This assignment will simply help you understand how the convolution operation can be used on data of various dimensionality.

Problem Statement

Convolution is an array operation where each output data element is the weighted sum of a collection of neighboring input elements. The weights used in the weighted sum are typically stored in an array called the convolution mask. This mask is applied across each element of the input to yield a convolved output. This is depicted in the following figure.
Fig 1. 1D Convolution [Kirk Hwu 2013]
Your task would be to implement three kernels each computing convolution mask operations over different forms of data.
  1. A 1D convolution mask which for each element of a 1D array computes the maximum of its 4 immediate neighbors.
  2. A 2D convolution mask which for each element of a 2D array computes the average value of its 8 adjacent neighbors
  3. A 3D convolution mask which for each element of a 3D array computes the sum of all the neighboring points in a cuboid of unit length keeping the element under consideration at the center.
NOTE: Your program should be generic enough to handle inputs of any dimension.