| 163 | |
| 164 | template<typename Tk, typename To, af_op_t op> |
| 165 | void finalBoundaryReduceDim(cl::Buffer *reduced_block_sizes, Param keys_out, |
| 166 | Param vals_out, const int n, const int numBlocks, |
| 167 | const int threads_x, const int dim, |
| 168 | std::vector<int> dim_ordering) { |
| 169 | ToNumStr<To> toNumStr; |
| 170 | std::vector<TemplateArg> tmpltArgs = { |
| 171 | TemplateTypename<To>(), |
| 172 | TemplateTypename<Tk>(), |
| 173 | TemplateArg(op), |
| 174 | TemplateArg(threads_x), |
| 175 | }; |
| 176 | std::vector<std::string> compileOpts = { |
| 177 | DefineKeyValue(Tk, dtype_traits<Tk>::getName()), |
| 178 | DefineKeyValue(Ti, dtype_traits<To>::getName()), |
| 179 | DefineKeyValue(To, dtype_traits<To>::getName()), |
| 180 | DefineKeyValue(T, "To"), |
| 181 | DefineKeyValue(DIMX, threads_x), |
| 182 | DefineKeyValue(DIM, dim), |
| 183 | DefineKeyValue(init, toNumStr(common::Binary<To, op>::init())), |
| 184 | DefineKeyFromStr(binOpName<op>()), |
| 185 | DefineKeyValue(CPLX, iscplx<To>()), |
| 186 | }; |
| 187 | compileOpts.emplace_back(getTypeBuildDefinition<To>()); |
| 188 | |
| 189 | auto finalBoundaryReduceDim = |
| 190 | common::getKernel("final_boundary_reduce_dim", |
| 191 | {{ops_cl_src, reduce_by_key_boundary_dim_cl_src}}, |
| 192 | tmpltArgs, compileOpts); |
| 193 | |
| 194 | cl::NDRange local(threads_x); |
| 195 | cl::NDRange global(threads_x * numBlocks, |
| 196 | vals_out.info.dims[dim_ordering[1]], |
| 197 | vals_out.info.dims[dim_ordering[2]] * |
| 198 | vals_out.info.dims[dim_ordering[3]]); |
| 199 | |
| 200 | finalBoundaryReduceDim( |
| 201 | cl::EnqueueArgs(getQueue(), global, local), *reduced_block_sizes, |
| 202 | *keys_out.data, keys_out.info, *vals_out.data, vals_out.info, n, |
| 203 | static_cast<int>(vals_out.info.dims[dim_ordering[2]])); |
| 204 | CL_DEBUG_FINISH(getQueue()); |
| 205 | } |
| 206 | |
| 207 | template<typename Tk, typename To> |
| 208 | void compact(cl::Buffer *reduced_block_sizes, Param keys_out, Param vals_out, |
nothing calls this directly
no test coverage detected