As we can see from this code, the convolution operations can be parallelized because the operation for a pixel coordinate is independent from the others. The loops with the counters i and j are for the pixel coordinates of the padded image, and ones with the counters k and l are for the convolution operations performed in the $\left(2S+1\right)\times\left(2S+1\right)$ neighborhood of all the pixel coordinates. Note that accessing the 2D data in a 1D array is a little bit tricky the access pattern of a 2D array denoted by a corresponds to one of a 1D array denoted by a where X is the width of the 2D data. Allocated one-dimensional (1D) arrays are used for the images and the filter, because using 1D arrays is convenient to allocate a memory space on a GPU. Note that padding of $S$ pixels for an input image is assumed. In the code, the argument h_f is an input image after padding is applied, paddedW and paddedH are the size of the padded image, h_g is a filter, S determines the sizes of the filer and padding, h_h is a filtered image, and W and H are the size of an input image. A convolution operation for the image can be represented by the following equation: Let's assume that $f\left(x,y\right)$ is an image where $\left(x, y\right)$ represent a pixel coordinate in the coordinate system shown on the left in Fig.1, and the width and height of the image are denoted by $W$ and $H$. In this version, only global memory of a GPU is used. If you are familiar with a convolution operation and CUDA, you can directory access the example code at github, in which accelerated image filtering is implemented by C++ and CUDA. I believe in that writing software is a powerful way to understand and demonstrate what one would like to realize. Since convolution is the important ingredient of many applications such as convolutional neural networks and image processing, I hope this article on CUDA would help you to know about convolution and its parallel implementation. ![]() This article shows the fundamentals of using CUDA for accelerating convolution operations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |