MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / createSpMatDescr

Function createSpMatDescr

src/backend/cuda/cusparse.hpp:25–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template<typename T>
25cusparseStatus_t createSpMatDescr(
26 cusparseSpMatDescr_t *out, const arrayfire::common::SparseArray<T> &arr) {
27 auto &_ = arrayfire::cuda::getCusparsePlugin();
28 switch (arr.getStorage()) {
29 case AF_STORAGE_CSR: {
30 return _.cusparseCreateCsr(
31 out, arr.dims()[0], arr.dims()[1], arr.getNNZ(),
32 (void *)arr.getRowIdx().get(), (void *)arr.getColIdx().get(),
33 (void *)arr.getValues().get(), CUSPARSE_INDEX_32I,
34 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, getType<T>());
35 }
36#if CUSPARSE_VERSION >= 11300
37 case AF_STORAGE_CSC: {
38 return _.cusparseCreateCsc(
39 out, arr.dims()[0], arr.dims()[1], arr.getNNZ(),
40 (void *)arr.getColIdx().get(), (void *)arr.getRowIdx().get(),
41 (void *)arr.getValues().get(), CUSPARSE_INDEX_32I,
42 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, getType<T>());
43 }
44#else
45 case AF_STORAGE_CSC:
46 CUDA_NOT_SUPPORTED(
47 "Sparse not supported for CSC on this version of the CUDA "
48 "Toolkit");
49#endif
50 case AF_STORAGE_COO: {
51 return _.cusparseCreateCoo(
52 out, arr.dims()[0], arr.dims()[1], arr.getNNZ(),
53 (void *)arr.getColIdx().get(), (void *)arr.getRowIdx().get(),
54 (void *)arr.getValues().get(), CUSPARSE_INDEX_32I,
55 CUSPARSE_INDEX_BASE_ZERO, getType<T>());
56 }
57 }
58 return CUSPARSE_STATUS_SUCCESS;
59}
60
61} // namespace cuda
62} // namespace arrayfire

Callers

nothing calls this directly

Calls 4

getStorageMethod · 0.80
getNNZMethod · 0.80
dimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected