| 26 | |
| 27 | template<typename T, bool batch_a> |
| 28 | void iir(Param y, Param c, Param a) { |
| 29 | // FIXME: This is a temporary fix. Ideally the local memory should be |
| 30 | // allocted outside |
| 31 | constexpr int MAX_A_SIZE = (1024 * sizeof(double)) / sizeof(T); |
| 32 | |
| 33 | std::array<TemplateArg, 2> targs = { |
| 34 | TemplateTypename<T>(), |
| 35 | TemplateArg(batch_a), |
| 36 | }; |
| 37 | std::array<std::string, 5> options = { |
| 38 | DefineKeyValue(T, dtype_traits<T>::getName()), DefineValue(MAX_A_SIZE), |
| 39 | DefineKeyValue(BATCH_A, batch_a), |
| 40 | DefineKeyValue(ZERO, scalar_to_option(scalar<T>(0))), |
| 41 | getTypeBuildDefinition<T>()}; |
| 42 | |
| 43 | auto iir = common::getKernel("iir_kernel", {{iir_cl_src}}, targs, options); |
| 44 | |
| 45 | const int groups_y = y.info.dims[1]; |
| 46 | const int groups_x = y.info.dims[2]; |
| 47 | |
| 48 | int threads = 256; |
| 49 | while (threads > (int)y.info.dims[0] && threads > 32) threads /= 2; |
| 50 | |
| 51 | cl::NDRange local(threads, 1); |
| 52 | cl::NDRange global(groups_x * local[0], |
| 53 | groups_y * y.info.dims[3] * local[1]); |
| 54 | |
| 55 | try { |
| 56 | iir(cl::EnqueueArgs(getQueue(), global, local), *y.data, y.info, |
| 57 | *c.data, c.info, *a.data, a.info, groups_y); |
| 58 | } catch (cl::Error& clerr) { |
| 59 | AF_ERROR("Size of a too big for this datatype", AF_ERR_SIZE); |
| 60 | } |
| 61 | CL_DEBUG_FINISH(getQueue()); |
| 62 | } |
| 63 | |
| 64 | } // namespace kernel |
| 65 | } // namespace opencl |
nothing calls this directly
no test coverage detected