View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Be the first to rate this file! 9 Downloads (last 30 days) File Size: 11.2 KB File ID: #29648 Version: 1.0



Dirk-Jan Kroon (view profile)


Example, Matlab R2010B Cuda CONV2 on GPU using Cuda kernels

| Watch this File

File Information

GPUCONV2 Two dimensional convolution on the GPU using Cuda.

   C = GPUCONV2(A, B) performs the 2-D convolution of matrices A and B.
   If [ma,na] = size(A), [mb,nb] = size(B), and [mc,nc] = size(C), then
   mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).

   C = GPUCONV2(A, B, SHAPE) returns a subsection of the 2-D
   convolution with size specified by SHAPE:
     'full' - (default) returns the full 2-D convolution,
     'same' - returns the central part of the convolution
               that is the same size as A.
     'valid' - returns only those parts of the convolution
               that are computed without the zero-padded edges.
               size(C) = max([ma-max(0,mb-1),na-max(0,nb-1)],0).

   This function depends on two Cuda kernel files and which needs to be compiled
   to .ptx files using the nvcc compiler.

   See also CONV2, NVCC

    Load an image
    Create a Gaussian filtering kernel
   H = fspecial('gaussian',[20 20],3);
    Perform the convolution on the CPU
   J = conv2(I,H);
    Perform the convolution on the GPU
   Jcuda = gpuconv2(I,H);
    Show the results
   imshow(J,[]); title('CPU filtering');
   imshow(Jcuda,[]); title('GPU filtering');
   imshow(Jcuda-J,[]); title('Difference');

Required Products Parallel Computing Toolbox
MATLAB release MATLAB 7.11 (R2010b)
Other requirements Nvidia Cuda Driver
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us