| 29 | namespace kernel { |
| 30 | template<typename T> |
| 31 | void cscmm_nn(Param out, const Param &values, const Param &colIdx, |
| 32 | const Param &rowIdx, const Param &rhs, const T alpha, |
| 33 | const T beta, bool is_conj) { |
| 34 | constexpr int threads = 256; |
| 35 | // TODO: Find a better way to tune these parameters |
| 36 | constexpr int rows_per_group = 8; |
| 37 | constexpr int cols_per_group = 8; |
| 38 | |
| 39 | const bool use_alpha = (alpha != scalar<T>(1.0)); |
| 40 | const bool use_beta = (beta != scalar<T>(0.0)); |
| 41 | |
| 42 | std::array<TemplateArg, 7> targs = { |
| 43 | TemplateTypename<T>(), TemplateArg(use_alpha), |
| 44 | TemplateArg(use_beta), TemplateArg(is_conj), |
| 45 | TemplateArg(rows_per_group), TemplateArg(cols_per_group), |
| 46 | TemplateArg(threads), |
| 47 | }; |
| 48 | std::array<std::string, 9> options = { |
| 49 | DefineKeyValue(T, dtype_traits<T>::getName()), |
| 50 | DefineKeyValue(USE_ALPHA, use_alpha), |
| 51 | DefineKeyValue(USE_BETA, use_beta), |
| 52 | DefineKeyValue(IS_CONJ, is_conj), |
| 53 | DefineKeyValue(THREADS, threads), |
| 54 | DefineKeyValue(ROWS_PER_GROUP, rows_per_group), |
| 55 | DefineKeyValue(COLS_PER_GROUP, cols_per_group), |
| 56 | DefineKeyValue(IS_CPLX, (iscplx<T>() ? 1 : 0)), |
| 57 | getTypeBuildDefinition<T>()}; |
| 58 | |
| 59 | auto cscmmNN = |
| 60 | common::getKernel("cscmm_nn", {{cscmm_cl_src}}, targs, options); |
| 61 | |
| 62 | cl::NDRange local(threads, 1); |
| 63 | int M = out.info.dims[0]; |
| 64 | int N = out.info.dims[1]; |
| 65 | int K = colIdx.info.dims[0] - 1; |
| 66 | |
| 67 | int groups_x = divup(M, rows_per_group); |
| 68 | int groups_y = divup(N, cols_per_group); |
| 69 | cl::NDRange global(local[0] * groups_x, local[1] * groups_y); |
| 70 | |
| 71 | cscmmNN(cl::EnqueueArgs(getQueue(), global, local), *out.data, *values.data, |
| 72 | *colIdx.data, *rowIdx.data, M, K, N, *rhs.data, rhs.info, alpha, |
| 73 | beta); |
| 74 | CL_DEBUG_FINISH(getQueue()); |
| 75 | } |
| 76 | } // namespace kernel |
| 77 | } // namespace opencl |
| 78 | } // namespace arrayfire |
no test coverage detected