-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExampleOpenCLKernels.cl
More file actions
69 lines (55 loc) · 1.63 KB
/
ExampleOpenCLKernels.cl
File metadata and controls
69 lines (55 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//Some basic kernel for testing purpose
__kernel void Add_Integers(__global int* ABC, __global int* B, __global int* C)
{
int num = get_global_id(0);
C[num] = ABC[num] + B[num];
}
__kernel void Sub_Integers(__global int* ABC, __global int* B, __global int* C)
{
int num = get_global_id(0);
((*(((C + num ))))) = *(ABC + num) - B[num];//This is valid
}
//This does more than multiply, which is probably not what one would expect
__kernel void Multiply_Integers(__global int* ABC, __global int* B, __global int* C, __local int* D, __private TotalLocal)
{
int num = get_global_id(0);
int loc = get_local_id(0);
ulong Total = 0;
int MaxLim = (num + 1) * TotalLocal;
for(int i = (MaxLim - TotalLocal); i < MaxLim; ++i)
{
D[i] = 0;// Setting 0 to all// Probably not needed
}
for(int i = (MaxLim - TotalLocal); i < MaxLim; ++i)
{
D[i] = D[i] + ABC[num] * B[num];
}
for(int i = (MaxLim - TotalLocal); i < MaxLim; ++i)
{
Total = Total + D[i];
//Total = TotalLocal;
}
C[num] = Total;
}
//This does more than multiply, which is probably not what one would expect
__kernel void Multiply_IntegersTestTwo(__global int* ABC, __global int* B, __global int* C, __local int* D, __private TotalLocal)
{
int num = get_global_id(0);
int loc = get_local_id(0);
ulong Total = 0;
int MaxLim = (num + 1) * TotalLocal;
for(int i = (MaxLim - TotalLocal); i < MaxLim; ++i)
{
D[i] = 0;// Setting 0 to all// Probably not needed
}
for(int i = (MaxLim - TotalLocal); i < MaxLim; ++i)
{
D[i] = D[i] + ABC[num] * B[num];
}
for(int i = (MaxLim - TotalLocal); i < MaxLim; ++i)
{
Total = Total + D[i];
//Total = TotalLocal;
}
C[num] = Total;
}