annotate src/test/vectorAdd_kernel.cu @ 430:35b37fe8d3a7

Add size member in struct Meta
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 09 Oct 2017 17:46:42 +0900
parents b46398081fe4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /*
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 * Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 *
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 * Please refer to the NVIDIA end user license agreement (EULA) associated
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 * with this source code for terms and conditions that govern your use of
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 * this software. Any use, reproduction, disclosure, or distribution of
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 * this software and related documentation outside the terms of the EULA
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 * is strictly prohibited.
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 *
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 */
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 /* Vector addition: C = A + B.
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 *
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 * This sample is a very basic sample that implements element by element
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 * vector addition. It is the same as the sample illustrating Chapter 3
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 * of the programming guide with some additions like error checking.
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 *
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 */
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 // Device code
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 extern "C" __global__ void VecAdd_kernel(const float *A, const float *B, float *C, int N)
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 {
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 int i = blockDim.x * blockIdx.x + threadIdx.x;
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 if (i < N)
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 C[i] = A[i] + B[i];
b46398081fe4 add working example
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }