summaryrefslogtreecommitdiff
path: root/kernels/compiler_workgroup_reduce.cl
blob: 69dcea8eb454ca432e55994405bfe189d680ba1e (plain)
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
/*
 * Workgroup any all functions
 */
kernel void compiler_workgroup_any(global int *src, global int *dst) {
  int val = src[get_global_id(0)];
  int predicate = work_group_any(val);
  dst[get_global_id(0)] = predicate;
}
kernel void compiler_workgroup_all(global int *src, global int *dst) {
  int val = src[get_global_id(0)];
  int predicate = work_group_all(val);
  dst[get_global_id(0)] = predicate;
}

/*
 * Workgroup reduce add functions
 */
kernel void compiler_workgroup_reduce_add_char(global char *src, global char *dst) {
  char val = src[get_global_id(0)];
  char sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_uchar(global uchar *src, global uchar *dst) {
  uchar val = src[get_global_id(0)];
  uchar sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_short(global short *src, global short *dst) {
  short val = src[get_global_id(0)];
  short sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_ushort(global ushort *src, global ushort *dst) {
  ushort val = src[get_global_id(0)];
  ushort sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_int(global int *src, global int *dst) {
  int val = src[get_global_id(0)];
  int sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_uint(global uint *src, global uint *dst) {
  uint val = src[get_global_id(0)];
  uint sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_long(global long *src, global long *dst) {
  long val = src[get_global_id(0)];
  long sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_ulong(global ulong *src, global ulong *dst) {
  ulong val = src[get_global_id(0)];
  ulong sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_add_float(global float *src, global float *dst) {
  float val = src[get_global_id(0)];
  float sum = work_group_reduce_add(val);
  dst[get_global_id(0)] = sum;
}

/*
 * Workgroup reduce max functions
 */
kernel void compiler_workgroup_reduce_max_int(global int *src, global int *dst) {
  int val = src[get_global_id(0)];
  int sum = work_group_reduce_max(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_max_uint(global uint *src, global uint *dst) {
  uint val = src[get_global_id(0)];
  uint sum = work_group_reduce_max(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_max_long(global long *src, global long *dst) {
  long val = src[get_global_id(0)];
  long sum = work_group_reduce_max(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_max_ulong(global ulong *src, global ulong *dst) {
  ulong val = src[get_global_id(0)];
  ulong sum = work_group_reduce_max(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_max_float(global float *src, global float *dst) {
  float val = src[get_global_id(0)];
  float sum = work_group_reduce_max(val);
  dst[get_global_id(0)] = sum;
}

/*
 * Workgroup reduce min functions
 */
kernel void compiler_workgroup_reduce_min_int(global int *src, global int *dst) {
  int val = src[get_global_id(0)];
  int sum = work_group_reduce_min(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_min_uint(global uint *src, global uint *dst) {
  uint val = src[get_global_id(0)];
  uint sum = work_group_reduce_min(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_min_long(global long *src, global long *dst) {
  long val = src[get_global_id(0)];
  long sum = work_group_reduce_min(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_min_ulong(global ulong *src, global ulong *dst) {
  ulong val = src[get_global_id(0)];
  ulong sum = work_group_reduce_min(val);
  dst[get_global_id(0)] = sum;
}

kernel void compiler_workgroup_reduce_min_float(global float *src, global float *dst) {
  float val = src[get_global_id(0)];
  float sum = work_group_reduce_min(val);
  dst[get_global_id(0)] = sum;
}