297
|
1 /*
|
|
2 * Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
|
|
3 *
|
|
4 * Please refer to the NVIDIA end user license agreement (EULA) associated
|
|
5 * with this source code for terms and conditions that govern your use of
|
|
6 * this software. Any use, reproduction, disclosure, or distribution of
|
|
7 * this software and related documentation outside the terms of the EULA
|
|
8 * is strictly prohibited.
|
|
9 *
|
|
10 */
|
|
11
|
|
12 /* Vector addition: C = A + B.
|
|
13 *
|
|
14 * This sample is a very basic sample that implements element by element
|
|
15 * vector addition. It is the same as the sample illustrating Chapter 3
|
|
16 * of the programming guide with some additions like error checking.
|
|
17 *
|
|
18 */
|
|
19
|
|
20 // Device code
|
|
21 extern "C" __global__ void VecAdd_kernel(const float *A, const float *B, float *C, int N)
|
|
22 {
|
|
23 int i = blockDim.x * blockIdx.x + threadIdx.x;
|
|
24
|
|
25 if (i < N)
|
|
26 C[i] = A[i] + B[i];
|
|
27 }
|