Vector addition using CUDA

The problem that we are trying to solve is vector addition. As we are aware, vector addition is a data parallel operation. Our dataset consists of three arrays: A, B, and C. The same operation is performed on each element:

Cx = Ax + Bx

Each addition is independent of each other, but the same operation is applied by all CUDA threads. To get started, configure your environment according to the following steps:

  1. Prepare your GPU application. This code will be placed in 01_cuda_introduction/01_vector_addition.
  2. Compile your application with the nvcc compiler with the following command:
$nvcc -o vector_addition vector_addition.cu

The preceding code is sequential code. We will convert this code so that it can run on ...

Get Learn CUDA Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.