-
Notifications
You must be signed in to change notification settings - Fork 0
/
incremental_tile_list.cl
175 lines (144 loc) · 3.88 KB
/
incremental_tile_list.cl
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#define OPERATOR_EQUAL 0
#define OPERATOR_GT 1
#define OPERATOR_LT 2
#define OPERATOR_GTE 3
#define OPERATOR_LTE 4
#define LOGICAL_AND 0
#define LOGICAL_OR 1
#define TRUE 1
#define FALSE 0
__kernel void init(
__global int* tiles,
int2 tilesDim
) {
int gx = get_global_id(0);
int gy = get_global_id(1);
if (gx > tilesDim.x-1 || gy > tilesDim.y-1)
return;
tiles[gy*tilesDim.x + gx] = FALSE;
}
__kernel void init_incremental(
__global int* tiles,
int2 tilesDim,
int iteration
) {
int gx = get_global_id(0);
int gy = get_global_id(1);
if (gx > tilesDim.x-1 || gy > tilesDim.y-1)
return;
tiles[gy*tilesDim.x + gx] = iteration;
}
__kernel void flag(
__global int* in,
__global int* out,
int length,
int operator,
int operand
)
{
int gx = get_global_id(0);
if (gx > length-1)
return;
int flag = FALSE;
switch(operator) {
case OPERATOR_EQUAL: if (in[gx] == operand) flag = TRUE; break;
case OPERATOR_GT: if (in[gx] > operand) flag = TRUE; break;
case OPERATOR_LT: if (in[gx] < operand) flag = TRUE; break;
case OPERATOR_GTE: if (in[gx] >= operand) flag = TRUE; break;
case OPERATOR_LTE: if (in[gx] <= operand) flag = TRUE; break;
}
out[gx] = flag;
}
__kernel void flag_logical(
__global int* in1,
__global int* in2,
__global int* out,
int length,
int operator1,
int operator2,
int operand1,
int operand2,
int logical
)
{
int gx = get_global_id(0);
if (gx > length-1)
return;
int flag1 = FALSE;
int flag2 = FALSE;
switch(operator1) {
case OPERATOR_EQUAL: if (in1[gx] == operand1) flag1 = TRUE; break;
case OPERATOR_GT: if (in1[gx] > operand1) flag1 = TRUE; break;
case OPERATOR_LT: if (in1[gx] < operand1) flag1 = TRUE; break;
case OPERATOR_GTE: if (in1[gx] >= operand1) flag1 = TRUE; break;
case OPERATOR_LTE: if (in1[gx] <= operand1) flag1 = TRUE; break;
}
switch(operator2) {
case OPERATOR_EQUAL: if (in2[gx] == operand2) flag2 = TRUE; break;
case OPERATOR_GT: if (in2[gx] > operand2) flag2 = TRUE; break;
case OPERATOR_LT: if (in2[gx] < operand2) flag2 = TRUE; break;
case OPERATOR_GTE: if (in2[gx] >= operand2) flag2 = TRUE; break;
case OPERATOR_LTE: if (in2[gx] <= operand2) flag2 = TRUE; break;
}
switch(logical) {
case LOGICAL_AND: flag1 = flag1 && flag2; break;
case LOGICAL_OR : flag1 = flag1 || flag2; break;
}
out[gx] = flag1;
}
__kernel void increment_logical(
__global int* in1,
__global int* in2,
__global int* out,
int length,
int operator1,
int operator2,
int operand1,
int operand2,
int logical,
int iteration
)
{
int gx = get_global_id(0);
if (gx > length-1)
return;
int flag1 = FALSE;
int flag2 = FALSE;
switch(operator1) {
case OPERATOR_EQUAL: if (in1[gx] == operand1) flag1 = TRUE; break;
case OPERATOR_GT: if (in1[gx] > operand1) flag1 = TRUE; break;
case OPERATOR_LT: if (in1[gx] < operand1) flag1 = TRUE; break;
case OPERATOR_GTE: if (in1[gx] >= operand1) flag1 = TRUE; break;
case OPERATOR_LTE: if (in1[gx] <= operand1) flag1 = TRUE; break;
}
switch(operator2) {
case OPERATOR_EQUAL: if (in2[gx] == operand2) flag2 = TRUE; break;
case OPERATOR_GT: if (in2[gx] > operand2) flag2 = TRUE; break;
case OPERATOR_LT: if (in2[gx] < operand2) flag2 = TRUE; break;
case OPERATOR_GTE: if (in2[gx] >= operand2) flag2 = TRUE; break;
case OPERATOR_LTE: if (in2[gx] <= operand2) flag2 = TRUE; break;
}
switch(logical) {
case LOGICAL_AND: flag1 = flag1 && flag2; break;
case LOGICAL_OR : flag1 = flag1 || flag2; break;
}
if (flag1)
out[gx] = iteration;
}
__kernel void filter(
__global int* input,
int2 dim,
int iteration,
__global int* output
) {
int gx = get_global_id(0);
int gy = get_global_id(1);
int2 gxy = (int2) (gx, gy);
int bxy = (gy/TILEH)*TILESW + gx/TILEW;
int out;
if (input[bxy] == iteration)
out = 0xFF0000FF;
else
out = 0xFF000000;
output[gy*dim[0] + gx] = out;
}