Pinned Memory Vector Add

GPU Teaching Kit – Accelerated Computing

Objective

The purpose of this lab is to introduce the student to the Pinned Memory APIs along with CUDA Streams by implementing vector addition. The student will implement pinned memory allocation and experience the usage of CUDA Streams by writing the CUDA Calls in the host code.

Prerequisites

Before starting this lab, make sure that:

Instructions

The lab is broken down into two parts. Part A covers cudaStreams while part B coverts Pinned memory on vectorAdd. To controll if you want to work on part A or part B, use the #define PINNED 1 in template.cu. By default we will cover the cudaStream lab.

Part A lab setup.

Edit the code in the code tab to perform the following:

Part B lab setup.

Instructions about where to place each part of the code is demarcated by the //@@ comment lines.

Local Setup Instructions

The most recent version of source code for this lab along with the build-scripts can be found on the Bitbucket repository. A description on how to use the CMake tool in along with how to build the labs for local development found in the README document in the root of the repository.

The executable generated as a result of compiling the lab can be run using the following command:

./PinnedMemoryStreamVectorAdd_Template -e <expected.raw> -i <intput1.raw>, \
  <input2.raw> -o <output.raw> -t vector

where <expected.raw> is the expected output, <input0.raw>,<input1.raw> is the input dataset, and <output.raw> is an optional path to store the results. The datasets can be generated using the dataset generator built as part of the compilation process.