-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathocl_reduction.hpp
More file actions
38 lines (30 loc) · 999 Bytes
/
ocl_reduction.hpp
File metadata and controls
38 lines (30 loc) · 999 Bytes
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
#ifndef __CL_REDUCTION_HDR
#define __CL_REDUCTION_HDR
#include "ocl_common.hpp"
template <typename T>
T CloverChunk::reduceValue
(reduce_info_vec_t& red_kernels,
const cl::Buffer& results_buf)
{
// enqueue the kernels in order
for (size_t ii = 0; ii < red_kernels.size(); ii++)
{
red_kernels.at(ii).kernel.setArg(0, results_buf);
CloverChunk::enqueueKernel(red_kernels.at(ii).kernel,
__LINE__, __FILE__,
cl::NullRange,
red_kernels.at(ii).global_size,
red_kernels.at(ii).local_size);
}
T result;
// make sure final reduction has finished
queue.finish();
// copy back the result and return
queue.enqueueReadBuffer(results_buf,
CL_TRUE,
0,
sizeof(T),
&result);
return result;
}
#endif