| 164 | |
| 165 | template<typename T> |
| 166 | void csr2coo(Param ovalues, Param orowIdx, Param ocolIdx, const Param ivalues, |
| 167 | const Param irowIdx, const Param icolIdx, Param index) { |
| 168 | std::vector<TemplateArg> tmpltArgs = { |
| 169 | TemplateTypename<T>(), |
| 170 | }; |
| 171 | std::vector<std::string> compileOpts = { |
| 172 | DefineKeyValue(T, dtype_traits<T>::getName()), |
| 173 | }; |
| 174 | compileOpts.emplace_back(getTypeBuildDefinition<T>()); |
| 175 | |
| 176 | auto csr2coo = common::getKernel("csr2Coo", {{csr2coo_cl_src}}, tmpltArgs, |
| 177 | compileOpts); |
| 178 | |
| 179 | const int MAX_GROUPS = 4096; |
| 180 | int M = irowIdx.info.dims[0] - 1; |
| 181 | // FIXME: This needs to be based non nonzeros per row |
| 182 | int threads = 64; |
| 183 | |
| 184 | cl::Buffer *scratch = bufferAlloc(orowIdx.info.dims[0] * sizeof(int)); |
| 185 | |
| 186 | cl::NDRange local(threads, 1); |
| 187 | int groups_x = std::min((int)(divup(M, local[0])), MAX_GROUPS); |
| 188 | cl::NDRange global(local[0] * groups_x, 1); |
| 189 | |
| 190 | csr2coo(cl::EnqueueArgs(getQueue(), global, local), *scratch, *ocolIdx.data, |
| 191 | *irowIdx.data, *icolIdx.data, M); |
| 192 | |
| 193 | // Now we need to sort this into column major |
| 194 | kernel::sort0ByKeyIterative<int, int>(ocolIdx, index, true); |
| 195 | |
| 196 | // Now use index to sort values and rows |
| 197 | kernel::swapIndex<T>(ovalues, orowIdx, ivalues, scratch, index); |
| 198 | |
| 199 | CL_DEBUG_FINISH(getQueue()); |
| 200 | |
| 201 | bufferFree(scratch); |
| 202 | } |
| 203 | |
| 204 | template<typename T> |
| 205 | void coo2csr(Param ovalues, Param orowIdx, Param ocolIdx, const Param ivalues, |
nothing calls this directly
no test coverage detected