blob: ec7e8bf6389cbb594e7e26d37ba2adeee6891584 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// OpenCL Kernel Function for element by element vector addition
kernel void VectorAddGM(global const int* a, global const int* b, global int* c, int iNumElements) {
// get index into global data array
int iGID = get_global_id(0);
// bound check (equivalent to the limit on a 'for' loop for standard/serial C code
if (iGID >= iNumElements) {
return;
}
// add the vector elements
c[iGID] = a[iGID] + b[iGID];
}
kernel void Test(global const int* a, global const int* b, global int* c, int iNumElements) {
// get index into global data array
int iGID = get_global_id(0);
// bound check (equivalent to the limit on a 'for' loop for standard/serial C code
if (iGID >= iNumElements) {
return;
}
c[iGID] = iGID;
}
|