| 29 | namespace kernel { |
| 30 | template<typename T> |
| 31 | void csrmm_nt(Param out, const Param &values, const Param &rowIdx, |
| 32 | const Param &colIdx, const Param &rhs, const T alpha, |
| 33 | const T beta) { |
| 34 | constexpr int MAX_CSRMM_GROUPS = 4096; |
| 35 | // Using greedy indexing is causing performance issues on many platforms |
| 36 | // FIXME: Figure out why |
| 37 | constexpr bool use_greedy = false; |
| 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, 4> targs = { |
| 43 | TemplateTypename<T>(), |
| 44 | TemplateArg(use_alpha), |
| 45 | TemplateArg(use_beta), |
| 46 | TemplateArg(use_greedy), |
| 47 | }; |
| 48 | std::array<std::string, 7> options = { |
| 49 | DefineKeyValue(T, dtype_traits<T>::getName()), |
| 50 | DefineKeyValue(USE_ALPHA, use_alpha), |
| 51 | DefineKeyValue(USE_BETA, use_beta), |
| 52 | DefineKeyValue(USE_GREEDY, use_greedy), |
| 53 | DefineValue(THREADS_PER_GROUP), |
| 54 | DefineKeyValue(IS_CPLX, (iscplx<T>() ? 1 : 0)), |
| 55 | getTypeBuildDefinition<T>()}; |
| 56 | |
| 57 | // FIXME: Switch to perf (thread vs block) baesd kernel |
| 58 | auto csrmm_nt_func = |
| 59 | common::getKernel("csrmm_nt", {{csrmm_cl_src}}, targs, options); |
| 60 | |
| 61 | cl::NDRange local(THREADS_PER_GROUP, 1); |
| 62 | int M = rowIdx.info.dims[0] - 1; |
| 63 | int N = rhs.info.dims[0]; |
| 64 | |
| 65 | int groups_x = divup(N, local[0]); |
| 66 | int groups_y = divup(M, REPEAT); |
| 67 | groups_y = std::min(groups_y, MAX_CSRMM_GROUPS); |
| 68 | cl::NDRange global(local[0] * groups_x, local[1] * groups_y); |
| 69 | |
| 70 | cl::Buffer *counter = bufferAlloc(groups_x * sizeof(int)); |
| 71 | getQueue().enqueueFillBuffer(*counter, 0, 0, groups_x * sizeof(int)); |
| 72 | |
| 73 | csrmm_nt_func(cl::EnqueueArgs(getQueue(), global, local), *out.data, |
| 74 | *values.data, *rowIdx.data, *colIdx.data, M, N, *rhs.data, |
| 75 | rhs.info, alpha, beta, *counter); |
| 76 | bufferFree(counter); |
| 77 | } |
| 78 | } // namespace kernel |
| 79 | } // namespace opencl |
| 80 | } // namespace arrayfire |
no test coverage detected