From 7df34441b6a59092ffbfbc549a525cac961017b2 Mon Sep 17 00:00:00 2001 From: jsandham Date: Wed, 17 Apr 2024 23:41:51 +0000 Subject: [PATCH 1/8] Reorganizing hipsparse header --- .../include/conversion/hipsparse_bsr2csr.h | 105 + .../include/conversion/hipsparse_coo2csr.h | 56 + .../include/conversion/hipsparse_coosort.h | 109 + .../hipsparse_create_identity_permutation.h | 56 + .../include/conversion/hipsparse_csc2dense.h | 86 + .../include/conversion/hipsparse_cscsort.h | 78 + .../include/conversion/hipsparse_csr2bsr.h | 126 + .../include/conversion/hipsparse_csr2coo.h | 55 + .../include/conversion/hipsparse_csr2csc.h | 211 + .../conversion/hipsparse_csr2csr_compress.h | 101 + .../include/conversion/hipsparse_csr2csru.h | 93 + .../include/conversion/hipsparse_csr2dense.h | 86 + .../include/conversion/hipsparse_csr2gebsr.h | 200 + .../include/conversion/hipsparse_csr2hyb.h | 100 + .../include/conversion/hipsparse_csrsort.h | 78 + .../include/conversion/hipsparse_csru2csr.h | 151 + .../include/conversion/hipsparse_dense2csc.h | 92 + .../include/conversion/hipsparse_dense2csr.h | 90 + .../include/conversion/hipsparse_gebsr2csr.h | 109 + .../conversion/hipsparse_gebsr2gebsc.h | 177 + .../conversion/hipsparse_gebsr2gebsr.h | 229 + .../include/conversion/hipsparse_hyb2csr.h | 79 + library/include/conversion/hipsparse_nnz.h | 86 + .../conversion/hipsparse_nnz_compress.h | 85 + .../conversion/hipsparse_prune_csr2csr.h | 218 + .../hipsparse_prune_csr2csr_by_percentage.h | 229 + .../conversion/hipsparse_prune_dense2csr.h | 190 + .../hipsparse_prune_dense2csr_by_percentage.h | 279 + library/include/extra/hipsparse_csrgeam.h | 423 + library/include/extra/hipsparse_csrgemm.h | 530 + library/include/generic/hipsparse_axpby.h | 140 + .../include/generic/hipsparse_dense2sparse.h | 102 + library/include/generic/hipsparse_gather.h | 121 + library/include/generic/hipsparse_rot.h | 137 + library/include/generic/hipsparse_scatter.h | 124 + library/include/generic/hipsparse_sddmm.h | 168 + .../include/generic/hipsparse_sparse2dense.h | 78 + library/include/generic/hipsparse_spgemm.h | 301 + .../include/generic/hipsparse_spgemm_reuse.h | 428 + library/include/generic/hipsparse_spmm.h | 258 + library/include/generic/hipsparse_spmv.h | 246 + library/include/generic/hipsparse_spsm.h | 187 + library/include/generic/hipsparse_spsv.h | 169 + library/include/generic/hipsparse_spvv.h | 177 + library/include/hipsparse.h | 14147 +--------------- library/include/hipsparse_auxiliary.h | 589 + library/include/hipsparse_generic_auxiliary.h | 953 ++ library/include/hipsparse_generic_types.h | 539 + library/include/hipsparse_types.h | 417 + library/include/level1/hipsparse_axpyi.h | 147 + library/include/level1/hipsparse_dotci.h | 77 + library/include/level1/hipsparse_doti.h | 141 + library/include/level1/hipsparse_gthr.h | 135 + library/include/level1/hipsparse_gthrz.h | 91 + library/include/level1/hipsparse_roti.h | 136 + library/include/level1/hipsparse_sctr.h | 137 + library/include/level2/hipsparse_bsrmv.h | 229 + library/include/level2/hipsparse_bsrsv.h | 551 + library/include/level2/hipsparse_bsrxmv.h | 152 + library/include/level2/hipsparse_csrmv.h | 226 + library/include/level2/hipsparse_csrsv.h | 483 + library/include/level2/hipsparse_gemvi.h | 171 + library/include/level2/hipsparse_hybmv.h | 179 + library/include/level3/hipsparse_bsrmm.h | 241 + library/include/level3/hipsparse_bsrsm.h | 556 + library/include/level3/hipsparse_csrmm.h | 366 + library/include/level3/hipsparse_csrsm.h | 541 + library/include/level3/hipsparse_gemmi.h | 137 + library/include/precond/hipsparse_bsric0.h | 283 + library/include/precond/hipsparse_bsrilu0.h | 339 + library/include/precond/hipsparse_csric0.h | 316 + library/include/precond/hipsparse_csrilu0.h | 366 + .../hipsparse_gpsv_interleaved_batch.h | 160 + library/include/precond/hipsparse_gtsv.h | 142 + .../hipsparse_gtsv_interleaved_batch.h | 142 + .../include/precond/hipsparse_gtsv_nopivot.h | 142 + .../precond/hipsparse_gtsv_strided_batch.h | 142 + library/include/reorder/hipsparse_csrcolor.h | 102 + 78 files changed, 16575 insertions(+), 14043 deletions(-) create mode 100644 library/include/conversion/hipsparse_bsr2csr.h create mode 100644 library/include/conversion/hipsparse_coo2csr.h create mode 100644 library/include/conversion/hipsparse_coosort.h create mode 100644 library/include/conversion/hipsparse_create_identity_permutation.h create mode 100644 library/include/conversion/hipsparse_csc2dense.h create mode 100644 library/include/conversion/hipsparse_cscsort.h create mode 100644 library/include/conversion/hipsparse_csr2bsr.h create mode 100644 library/include/conversion/hipsparse_csr2coo.h create mode 100644 library/include/conversion/hipsparse_csr2csc.h create mode 100644 library/include/conversion/hipsparse_csr2csr_compress.h create mode 100644 library/include/conversion/hipsparse_csr2csru.h create mode 100644 library/include/conversion/hipsparse_csr2dense.h create mode 100644 library/include/conversion/hipsparse_csr2gebsr.h create mode 100644 library/include/conversion/hipsparse_csr2hyb.h create mode 100644 library/include/conversion/hipsparse_csrsort.h create mode 100644 library/include/conversion/hipsparse_csru2csr.h create mode 100644 library/include/conversion/hipsparse_dense2csc.h create mode 100644 library/include/conversion/hipsparse_dense2csr.h create mode 100644 library/include/conversion/hipsparse_gebsr2csr.h create mode 100644 library/include/conversion/hipsparse_gebsr2gebsc.h create mode 100644 library/include/conversion/hipsparse_gebsr2gebsr.h create mode 100644 library/include/conversion/hipsparse_hyb2csr.h create mode 100644 library/include/conversion/hipsparse_nnz.h create mode 100644 library/include/conversion/hipsparse_nnz_compress.h create mode 100644 library/include/conversion/hipsparse_prune_csr2csr.h create mode 100644 library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h create mode 100644 library/include/conversion/hipsparse_prune_dense2csr.h create mode 100644 library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h create mode 100644 library/include/extra/hipsparse_csrgeam.h create mode 100644 library/include/extra/hipsparse_csrgemm.h create mode 100644 library/include/generic/hipsparse_axpby.h create mode 100644 library/include/generic/hipsparse_dense2sparse.h create mode 100644 library/include/generic/hipsparse_gather.h create mode 100644 library/include/generic/hipsparse_rot.h create mode 100644 library/include/generic/hipsparse_scatter.h create mode 100644 library/include/generic/hipsparse_sddmm.h create mode 100644 library/include/generic/hipsparse_sparse2dense.h create mode 100644 library/include/generic/hipsparse_spgemm.h create mode 100644 library/include/generic/hipsparse_spgemm_reuse.h create mode 100644 library/include/generic/hipsparse_spmm.h create mode 100644 library/include/generic/hipsparse_spmv.h create mode 100644 library/include/generic/hipsparse_spsm.h create mode 100644 library/include/generic/hipsparse_spsv.h create mode 100644 library/include/generic/hipsparse_spvv.h create mode 100644 library/include/hipsparse_auxiliary.h create mode 100644 library/include/hipsparse_generic_auxiliary.h create mode 100644 library/include/hipsparse_generic_types.h create mode 100644 library/include/hipsparse_types.h create mode 100644 library/include/level1/hipsparse_axpyi.h create mode 100644 library/include/level1/hipsparse_dotci.h create mode 100644 library/include/level1/hipsparse_doti.h create mode 100644 library/include/level1/hipsparse_gthr.h create mode 100644 library/include/level1/hipsparse_gthrz.h create mode 100644 library/include/level1/hipsparse_roti.h create mode 100644 library/include/level1/hipsparse_sctr.h create mode 100644 library/include/level2/hipsparse_bsrmv.h create mode 100644 library/include/level2/hipsparse_bsrsv.h create mode 100644 library/include/level2/hipsparse_bsrxmv.h create mode 100644 library/include/level2/hipsparse_csrmv.h create mode 100644 library/include/level2/hipsparse_csrsv.h create mode 100644 library/include/level2/hipsparse_gemvi.h create mode 100644 library/include/level2/hipsparse_hybmv.h create mode 100644 library/include/level3/hipsparse_bsrmm.h create mode 100644 library/include/level3/hipsparse_bsrsm.h create mode 100644 library/include/level3/hipsparse_csrmm.h create mode 100644 library/include/level3/hipsparse_csrsm.h create mode 100644 library/include/level3/hipsparse_gemmi.h create mode 100644 library/include/precond/hipsparse_bsric0.h create mode 100644 library/include/precond/hipsparse_bsrilu0.h create mode 100644 library/include/precond/hipsparse_csric0.h create mode 100644 library/include/precond/hipsparse_csrilu0.h create mode 100644 library/include/precond/hipsparse_gpsv_interleaved_batch.h create mode 100644 library/include/precond/hipsparse_gtsv.h create mode 100644 library/include/precond/hipsparse_gtsv_interleaved_batch.h create mode 100644 library/include/precond/hipsparse_gtsv_nopivot.h create mode 100644 library/include/precond/hipsparse_gtsv_strided_batch.h create mode 100644 library/include/reorder/hipsparse_csrcolor.h diff --git a/library/include/conversion/hipsparse_bsr2csr.h b/library/include/conversion/hipsparse_bsr2csr.h new file mode 100644 index 00000000..5b8422f2 --- /dev/null +++ b/library/include/conversion/hipsparse_bsr2csr.h @@ -0,0 +1,105 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Convert a sparse BSR matrix into a sparse CSR matrix +* +* \details +* \p hipsparseXbsr2csr converts a BSR matrix into a CSR matrix. It is assumed, +* that \p csr_val, \p csr_col_ind and \p csr_row_ptr are allocated. Allocation size +* for \p csr_row_ptr is computed by the number of block rows multiplied by the block +* dimension plus one. Allocation for \p csr_val and \p csr_col_ind is computed by the +* the number of blocks in the BSR matrix multiplied by the block dimension squared. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + float* csrValC, + int* csrRowPtrC, + int* csrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + double* csrValC, + int* csrRowPtrC, + int* csrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + hipComplex* csrValC, + int* csrRowPtrC, + int* csrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* csrValC, + int* csrRowPtrC, + int* csrColIndC); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_coo2csr.h b/library/include/conversion/hipsparse_coo2csr.h new file mode 100644 index 00000000..8039b50d --- /dev/null +++ b/library/include/conversion/hipsparse_coo2csr.h @@ -0,0 +1,56 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module + * \brief Convert a sparse COO matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXcoo2csr converts the COO array containing the row indices into a + * CSR array of row offsets, that point to the start of every row. + * It is assumed that the COO row index array is sorted. + * + * \note It can also be used, to convert a COO array containing the column indices into + * a CSC array of column offsets, that point to the start of every column. Then, it is + * assumed that the COO column index array is sorted, instead. + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcoo2csr(hipsparseHandle_t handle, + const int* cooRowInd, + int nnz, + int m, + int* csrRowPtr, + hipsparseIndexBase_t idxBase); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_coosort.h b/library/include/conversion/hipsparse_coosort.h new file mode 100644 index 00000000..564580bd --- /dev/null +++ b/library/include/conversion/hipsparse_coosort.h @@ -0,0 +1,109 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Sort a sparse COO matrix +* +* \details +* \p hipsparseXcoosort_bufferSizeExt returns the size of the temporary storage buffer +* in bytes required by hipsparseXcoosort(). The temporary storage buffer must be +* allocated by the user. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcoosort_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const int* cooRows, + const int* cooCols, + size_t* pBufferSizeInBytes); + +/*! \ingroup conv_module +* \brief Sort a sparse COO matrix by row +* +* \details +* \p hipsparseXcoosortByRow sorts a matrix in COO format by row. The sorted +* permutation vector \p perm can be used to obtain sorted \p coo_val array. In this +* case, \p perm must be initialized as the identity permutation, see +* hipsparseCreateIdentityPermutation(). +* +* \p hipsparseXcoosortByRow requires extra temporary storage buffer that has to be +* allocated by the user. Storage buffer size can be determined by +* hipsparseXcoosort_bufferSizeExt(). +* +* \note +* \p perm can be \p NULL if a sorted permutation vector is not required. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcoosortByRow(hipsparseHandle_t handle, + int m, + int n, + int nnz, + int* cooRows, + int* cooCols, + int* P, + void* pBuffer); + +/*! \ingroup conv_module +* \brief Sort a sparse COO matrix by column +* +* \details +* \p hipsparseXcoosortByColumn sorts a matrix in COO format by column. The sorted +* permutation vector \p perm can be used to obtain sorted \p coo_val array. In this +* case, \p perm must be initialized as the identity permutation, see +* hipsparseCreateIdentityPermutation(). +* +* \p hipsparseXcoosortByColumn requires extra temporary storage buffer that has to be +* allocated by the user. Storage buffer size can be determined by +* hipsparseXcoosort_bufferSizeExt(). +* +* \note +* \p perm can be \p NULL if a sorted permutation vector is not required. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcoosortByColumn(hipsparseHandle_t handle, + int m, + int n, + int nnz, + int* cooRows, + int* cooCols, + int* P, + void* pBuffer); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_create_identity_permutation.h b/library/include/conversion/hipsparse_create_identity_permutation.h new file mode 100644 index 00000000..9c553be7 --- /dev/null +++ b/library/include/conversion/hipsparse_create_identity_permutation.h @@ -0,0 +1,56 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief Create the identity map +* +* \details +* \p hipsparseCreateIdentityPermutation stores the identity map in \p p, such that +* \f$p = 0:1:(n-1)\f$. +* +* \code{.c} +* for(i = 0; i < n; ++i) +* { +* p[i] = i; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateIdentityPermutation(hipsparseHandle_t handle, int n, int* p); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csc2dense.h b/library/include/conversion/hipsparse_csc2dense.h new file mode 100644 index 00000000..282bb765 --- /dev/null +++ b/library/include/conversion/hipsparse_csc2dense.h @@ -0,0 +1,86 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup conv_module +* \brief +* This function converts the sparse matrix in CSC format into a dense matrix. +* It is executed asynchronously with respect to the host and may return control to the application on the host before the entire result is ready. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsc2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const float* csc_val, + const int* csc_row_ind, + const int* csc_col_ptr, + float* A, + int ld); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsc2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const double* csc_val, + const int* csc_row_ind, + const int* csc_col_ptr, + double* A, + int ld); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsc2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipComplex* csc_val, + const int* csc_row_ind, + const int* csc_col_ptr, + hipComplex* A, + int ld); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsc2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipDoubleComplex* csc_val, + const int* csc_row_ind, + const int* csc_col_ptr, + hipDoubleComplex* A, + int ld); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_cscsort.h b/library/include/conversion/hipsparse_cscsort.h new file mode 100644 index 00000000..2dfb1a6b --- /dev/null +++ b/library/include/conversion/hipsparse_cscsort.h @@ -0,0 +1,78 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Sort a sparse CSC matrix +* +* \details +* \p hipsparseXcscsort_bufferSizeExt returns the size of the temporary storage buffer +* in bytes required by hipsparseXcscsort(). The temporary storage buffer must be +* allocated by the user. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcscsort_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const int* cscColPtr, + const int* cscRowInd, + size_t* pBufferSizeInBytes); + +/*! \ingroup conv_module +* \brief Sort a sparse CSC matrix +* +* \details +* \p hipsparseXcscsort sorts a matrix in CSC format. The sorted permutation vector +* \p perm can be used to obtain sorted \p csc_val array. In this case, \p perm must be +* initialized as the identity permutation, see hipsparseCreateIdentityPermutation(). +* +* \p hipsparseXcscsort requires extra temporary storage buffer that has to be allocated by +* the user. Storage buffer size can be determined by hipsparseXcscsort_bufferSizeExt(). +* +* \note +* \p perm can be \p NULL if a sorted permutation vector is not required. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcscsort(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + const int* cscColPtr, + int* cscRowInd, + int* P, + void* pBuffer); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2bsr.h b/library/include/conversion/hipsparse_csr2bsr.h new file mode 100644 index 00000000..146c93ff --- /dev/null +++ b/library/include/conversion/hipsparse_csr2bsr.h @@ -0,0 +1,126 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief +* This function computes the number of nonzero block columns per row and the total number of nonzero blocks in a sparse +* BSR matrix given a sparse CSR matrix as input. +* +* \details +* The routine does support asynchronous execution if the pointer mode is set to device. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsr2bsrNnz(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const int* csrRowPtrA, + const int* csrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + int* bsrRowPtrC, + int* bsrNnzb); + +/*! \ingroup conv_module +* \brief Convert a sparse CSR matrix into a sparse BSR matrix +* +* \details +* \p hipsparseXcsr2bsr converts a CSR matrix into a BSR matrix. It is assumed, +* that \p bsr_val, \p bsr_col_ind and \p bsr_row_ptr are allocated. Allocation size +* for \p bsr_row_ptr is computed as \p mb+1 where \p mb is the number of block rows in +* the BSR matrix. Allocation size for \p bsr_val and \p bsr_col_ind is computed using +* \p csr2bsr_nnz() which also fills in \p bsr_row_ptr. +* +* \p hipsparseXcsr2bsr requires extra temporary storage that is allocated internally if +* \p block_dim>16 +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2bsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + float* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2bsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + double* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2bsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + hipComplex* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2bsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + int blockDim, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2coo.h b/library/include/conversion/hipsparse_csr2coo.h new file mode 100644 index 00000000..e803803a --- /dev/null +++ b/library/include/conversion/hipsparse_csr2coo.h @@ -0,0 +1,55 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Convert a sparse CSR matrix into a sparse COO matrix +* +* \details +* \p hipsparseXcsr2coo converts the CSR array containing the row offsets, that point +* to the start of every row, into a COO array of row indices. +* +* \note +* It can also be used to convert a CSC array containing the column offsets into a COO +* array of column indices. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsr2coo(hipsparseHandle_t handle, + const int* csrRowPtr, + int nnz, + int m, + int* cooRowInd, + hipsparseIndexBase_t idxBase); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2csc.h b/library/include/conversion/hipsparse_csr2csc.h new file mode 100644 index 00000000..21b0350d --- /dev/null +++ b/library/include/conversion/hipsparse_csr2csc.h @@ -0,0 +1,211 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup conv_module +* \brief Convert a sparse CSR matrix into a sparse CSC matrix +* +* \details +* \p hipsparseXcsr2csc converts a CSR matrix into a CSC matrix. \p hipsparseXcsr2csc +* can also be used to convert a CSC matrix into a CSR matrix. \p copy_values decides +* whether \p csc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) +* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). +* +* \note +* The resulting matrix can also be seen as the transpose of the input matrix. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2csc(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const float* csrSortedVal, + const int* csrSortedRowPtr, + const int* csrSortedColInd, + float* cscSortedVal, + int* cscSortedRowInd, + int* cscSortedColPtr, + hipsparseAction_t copyValues, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2csc(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const double* csrSortedVal, + const int* csrSortedRowPtr, + const int* csrSortedColInd, + double* cscSortedVal, + int* cscSortedRowInd, + int* cscSortedColPtr, + hipsparseAction_t copyValues, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2csc(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipComplex* csrSortedVal, + const int* csrSortedRowPtr, + const int* csrSortedColInd, + hipComplex* cscSortedVal, + int* cscSortedRowInd, + int* cscSortedColPtr, + hipsparseAction_t copyValues, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2csc(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipDoubleComplex* csrSortedVal, + const int* csrSortedRowPtr, + const int* csrSortedColInd, + hipDoubleComplex* cscSortedVal, + int* cscSortedRowInd, + int* cscSortedColPtr, + hipsparseAction_t copyValues, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse csr2csc algorithms. + * + * \details + * This is a list of the \ref hipsparseCsr2CscAlg_t algorithms that can be used by the hipSPARSE + * library routines \ref hipsparseCsr2cscEx2_bufferSize and \ref hipsparseCsr2cscEx2. + */ +#if(!defined(CUDART_VERSION)) +typedef enum +{ + HIPSPARSE_CSR2CSC_ALG_DEFAULT = 0, + HIPSPARSE_CSR2CSC_ALG1 = 1, + HIPSPARSE_CSR2CSC_ALG2 = 2 +} hipsparseCsr2CscAlg_t; +#else +#if(CUDART_VERSION >= 12000) +typedef enum +{ + HIPSPARSE_CSR2CSC_ALG_DEFAULT = 0, + HIPSPARSE_CSR2CSC_ALG1 = 1 +} hipsparseCsr2CscAlg_t; +#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 12000) +typedef enum +{ + HIPSPARSE_CSR2CSC_ALG1 = 1, + HIPSPARSE_CSR2CSC_ALG2 = 2 +} hipsparseCsr2CscAlg_t; +#endif +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +/*! \ingroup conv_module +* \brief This function computes the size of the user allocated temporary storage buffer used +* when converting a sparse CSR matrix into a sparse CSC matrix. +* +* \details +* \p hipsparseCsr2cscEx2_bufferSize calculates the required user allocated temporary buffer needed +* by \p hipsparseCsr2cscEx2 to convert a CSR matrix into a CSC matrix. \p hipsparseCsr2cscEx2 +* can also be used to convert a CSC matrix into a CSR matrix. \p copy_values decides +* whether \p csc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) +* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). +* +* \note +* The resulting matrix can also be seen as the transpose of the input matrix. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCsr2cscEx2_bufferSize(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const void* csrVal, + const int* csrRowPtr, + const int* csrColInd, + void* cscVal, + int* cscColPtr, + int* cscRowInd, + hipDataType valType, + hipsparseAction_t copyValues, + hipsparseIndexBase_t idxBase, + hipsparseCsr2CscAlg_t alg, + size_t* bufferSize); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +/*! \ingroup conv_module +* \brief Convert a sparse CSR matrix into a sparse CSC matrix +* +* \details +* \p hipsparseCsr2cscEx2 converts a CSR matrix into a CSC matrix. \p hipsparseCsr2cscEx2 +* can also be used to convert a CSC matrix into a CSR matrix. \p copy_values decides +* whether \p csc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) +* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). +* +* \note +* The resulting matrix can also be seen as the transpose of the input matrix. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCsr2cscEx2(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const void* csrVal, + const int* csrRowPtr, + const int* csrColInd, + void* cscVal, + int* cscColPtr, + int* cscRowInd, + hipDataType valType, + hipsparseAction_t copyValues, + hipsparseIndexBase_t idxBase, + hipsparseCsr2CscAlg_t alg, + void* buffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2csr_compress.h b/library/include/conversion/hipsparse_csr2csr_compress.h new file mode 100644 index 00000000..01010d0d --- /dev/null +++ b/library/include/conversion/hipsparse_csr2csr_compress.h @@ -0,0 +1,101 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module + * \brief Convert a sparse CSR matrix into a compressed sparse CSR matrix + * + * \details + * \p hipsparseXcsr2csr_compress converts a CSR matrix into a compressed CSR matrix by + * removing entries in the input CSR matrix that are below a non-negative threshold \p tol + * + * \note + * In the case of complex matrices only the magnitude of the real part of \p tol is used. + */ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2csr_compress(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrColIndA, + const int* csrRowPtrA, + int nnzA, + const int* nnzPerRow, + float* csrValC, + int* csrColIndC, + int* csrRowPtrC, + float tol); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2csr_compress(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrColIndA, + const int* csrRowPtrA, + int nnzA, + const int* nnzPerRow, + double* csrValC, + int* csrColIndC, + int* csrRowPtrC, + double tol); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2csr_compress(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipComplex* csrValA, + const int* csrColIndA, + const int* csrRowPtrA, + int nnzA, + const int* nnzPerRow, + hipComplex* csrValC, + int* csrColIndC, + int* csrRowPtrC, + hipComplex tol); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2csr_compress(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrValA, + const int* csrColIndA, + const int* csrRowPtrA, + int nnzA, + const int* nnzPerRow, + hipDoubleComplex* csrValC, + int* csrColIndC, + int* csrRowPtrC, + hipDoubleComplex tol); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2csru.h b/library/include/conversion/hipsparse_csr2csru.h new file mode 100644 index 00000000..b8cf3f4b --- /dev/null +++ b/library/include/conversion/hipsparse_csr2csru.h @@ -0,0 +1,93 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function converts sorted CSR format to unsorted CSR format. The required +* temporary storage has to be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2csru(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2csru(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2csru(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2csru(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2dense.h b/library/include/conversion/hipsparse_csr2dense.h new file mode 100644 index 00000000..8794b21e --- /dev/null +++ b/library/include/conversion/hipsparse_csr2dense.h @@ -0,0 +1,86 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup conv_module +* \brief +* This function converts the sparse matrix in CSR format into a dense matrix. +* It is executed asynchronously with respect to the host and may return control to the application on the host before the entire result is ready. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const float* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + float* A, + int ld); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const double* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + double* A, + int ld); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipComplex* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + hipComplex* A, + int ld); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2dense(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipDoubleComplex* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + hipDoubleComplex* A, + int ld); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2gebsr.h b/library/include/conversion/hipsparse_csr2gebsr.h new file mode 100644 index 00000000..468cc885 --- /dev/null +++ b/library/include/conversion/hipsparse_csr2gebsr.h @@ -0,0 +1,200 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief + * \details + * \p hipsparseXcsr2gebsr_bufferSize returns the size of the temporary buffer that + * is required by \p hipsparseXcsr2gebcsrNnz and \p hipsparseXcsr2gebcsr. + * The temporary storage buffer must be allocated by the user. + * +* This function computes the number of nonzero block columns per row and the total number of nonzero blocks in a sparse +* GEneral BSR matrix given a sparse CSR matrix as input. +* +* \details +* The routine does support asynchronous execution if the pointer mode is set to device. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const float* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const double* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const hipComplex* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const hipDoubleComplex* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); +/**@}*/ + +/*! \ingroup conv_module +* \brief +* This function computes the number of nonzero block columns per row and the total number of nonzero blocks in a sparse +* GEneral BSR matrix given a sparse CSR matrix as input. +* +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsr2gebsrNnz(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const int* csr_row_ptr, + const int* csr_col_ind, + const hipsparseMatDescr_t bsr_descr, + int* bsr_row_ptr, + int row_block_dim, + int col_block_dim, + int* bsr_nnz_devhost, + void* p_buffer); + +/*! \ingroup conv_module +* \brief Convert a sparse CSR matrix into a sparse GEneral BSR matrix +* +* \details +* \p hipsparseXcsr2gebsr converts a CSR matrix into a GEneral BSR matrix. It is assumed, +* that \p bsr_val, \p bsr_col_ind and \p bsr_row_ptr are allocated. Allocation size +* for \p bsr_row_ptr is computed as \p mb+1 where \p mb is the number of block rows in +* the GEneral BSR matrix. Allocation size for \p bsr_val and \p bsr_col_ind is computed using +* \p csr2gebsr_nnz() which also fills in \p bsr_row_ptr. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const float* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + const hipsparseMatDescr_t bsr_descr, + float* bsr_val, + int* bsr_row_ptr, + int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + void* p_buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const double* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + const hipsparseMatDescr_t bsr_descr, + double* bsr_val, + int* bsr_row_ptr, + int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + void* p_buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const hipComplex* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + const hipsparseMatDescr_t bsr_descr, + hipComplex* bsr_val, + int* bsr_row_ptr, + int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + void* p_buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dir, + int m, + int n, + const hipsparseMatDescr_t csr_descr, + const hipDoubleComplex* csr_val, + const int* csr_row_ptr, + const int* csr_col_ind, + const hipsparseMatDescr_t bsr_descr, + hipDoubleComplex* bsr_val, + int* bsr_row_ptr, + int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + void* p_buffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2hyb.h b/library/include/conversion/hipsparse_csr2hyb.h new file mode 100644 index 00000000..4aa639ed --- /dev/null +++ b/library/include/conversion/hipsparse_csr2hyb.h @@ -0,0 +1,100 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup conv_module +* \brief Convert a sparse CSR matrix into a sparse HYB matrix +* +* \details +* \p hipsparseXcsr2hyb converts a CSR matrix into a HYB matrix. It is assumed +* that \p hyb has been initialized with hipsparseCreateHybMat(). +* +* \note +* This function requires a significant amount of storage for the HYB matrix, +* depending on the matrix structure. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsr2hyb(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + hipsparseHybMat_t hybA, + int userEllWidth, + hipsparseHybPartition_t partitionType); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsr2hyb(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + hipsparseHybMat_t hybA, + int userEllWidth, + hipsparseHybPartition_t partitionType); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsr2hyb(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + hipsparseHybMat_t hybA, + int userEllWidth, + hipsparseHybPartition_t partitionType); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsr2hyb(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + hipsparseHybMat_t hybA, + int userEllWidth, + hipsparseHybPartition_t partitionType); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csrsort.h b/library/include/conversion/hipsparse_csrsort.h new file mode 100644 index 00000000..bd88dbfa --- /dev/null +++ b/library/include/conversion/hipsparse_csrsort.h @@ -0,0 +1,78 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Sort a sparse CSR matrix +* +* \details +* \p hipsparseXcsrsort_bufferSizeExt returns the size of the temporary storage buffer +* in bytes required by hipsparseXcsrsort(). The temporary storage buffer must be allocated by +* the user. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsrsort_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const int* csrRowPtr, + const int* csrColInd, + size_t* pBufferSizeInBytes); + +/*! \ingroup conv_module +* \brief Sort a sparse CSR matrix +* +* \details +* \p hipsparseXcsrsort sorts a matrix in CSR format. The sorted permutation vector +* \p perm can be used to obtain sorted \p csr_val array. In this case, \p perm must be +* initialized as the identity permutation, see hipsparseCreateIdentityPermutation(). +* +* \p hipsparseXcsrsort requires extra temporary storage buffer that has to be allocated by +* the user. Storage buffer size can be determined by hipsparseXcsrsort_bufferSizeExt(). +* +* \note +* \p perm can be \p NULL if a sorted permutation vector is not required. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsrsort(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + const int* csrRowPtr, + int* csrColInd, + int* P, + void* pBuffer); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csru2csr.h b/library/include/conversion/hipsparse_csru2csr.h new file mode 100644 index 00000000..3dd5fdf9 --- /dev/null +++ b/library/include/conversion/hipsparse_csru2csr.h @@ -0,0 +1,151 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function calculates the amount of temporary storage in bytes required for +* hipsparseXcsru2csr() and hipsparseXcsr2csru(). +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsru2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + float* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + size_t* pBufferSizeInBytes); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsru2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + double* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + size_t* pBufferSizeInBytes); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsru2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + hipComplex* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + size_t* pBufferSizeInBytes); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsru2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnz, + hipDoubleComplex* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + size_t* pBufferSizeInBytes); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function converts unsorted CSR format to sorted CSR format. The required +* temporary storage has to be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsru2csr(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsru2csr(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsru2csr(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsru2csr(hipsparseHandle_t handle, + int m, + int n, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrVal, + const int* csrRowPtr, + int* csrColInd, + csru2csrInfo_t info, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_dense2csc.h b/library/include/conversion/hipsparse_dense2csc.h new file mode 100644 index 00000000..f24a186e --- /dev/null +++ b/library/include/conversion/hipsparse_dense2csc.h @@ -0,0 +1,92 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup conv_module +* \brief +* +* This function converts the matrix A in dense format into a sparse matrix in CSC format. +* All the parameters are assumed to have been pre-allocated by the user and the arrays are filled in based on nnz_per_columns, which can be pre-computed with hipsparseXnnz(). +* It is executed asynchronously with respect to the host and may return control to the application on the host before the entire result is ready. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSdense2csc(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const float* A, + int ld, + const int* nnz_per_columns, + float* csc_val, + int* csc_row_ind, + int* csc_col_ptr); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDdense2csc(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const double* A, + int ld, + const int* nnz_per_columns, + double* csc_val, + int* csc_row_ind, + int* csc_col_ptr); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCdense2csc(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipComplex* A, + int ld, + const int* nnz_per_columns, + hipComplex* csc_val, + int* csc_row_ind, + int* csc_col_ptr); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZdense2csc(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipDoubleComplex* A, + int ld, + const int* nnz_per_columns, + hipDoubleComplex* csc_val, + int* csc_row_ind, + int* csc_col_ptr); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_dense2csr.h b/library/include/conversion/hipsparse_dense2csr.h new file mode 100644 index 00000000..8518c2b2 --- /dev/null +++ b/library/include/conversion/hipsparse_dense2csr.h @@ -0,0 +1,90 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief +* This function converts the matrix A in dense format into a sparse matrix in CSR format. +* All the parameters are assumed to have been pre-allocated by the user and the arrays +* are filled in based on nnz_per_row, which can be pre-computed with hipsparseXnnz(). +* It is executed asynchronously with respect to the host and may return control to the +* application on the host before the entire result is ready. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSdense2csr(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const float* A, + int ld, + const int* nnz_per_rows, + float* csr_val, + int* csr_row_ptr, + int* csr_col_ind); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDdense2csr(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const double* A, + int ld, + const int* nnz_per_rows, + double* csr_val, + int* csr_row_ptr, + int* csr_col_ind); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCdense2csr(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipComplex* A, + int ld, + const int* nnz_per_rows, + hipComplex* csr_val, + int* csr_row_ptr, + int* csr_col_ind); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZdense2csr(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descr, + const hipDoubleComplex* A, + int ld, + const int* nnz_per_rows, + hipDoubleComplex* csr_val, + int* csr_row_ptr, + int* csr_col_ind); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_gebsr2csr.h b/library/include/conversion/hipsparse_gebsr2csr.h new file mode 100644 index 00000000..a4fe3bb2 --- /dev/null +++ b/library/include/conversion/hipsparse_gebsr2csr.h @@ -0,0 +1,109 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Convert a sparse general BSR matrix into a sparse CSR matrix +* +* \details +* \p hipsparseXgebsr2csr converts a BSR matrix into a CSR matrix. It is assumed, +* that \p csr_val, \p csr_col_ind and \p csr_row_ptr are allocated. Allocation size +* for \p csr_row_ptr is computed by the number of block rows multiplied by the block +* dimension plus one. Allocation for \p csr_val and \p csr_col_ind is computed by the +* the number of blocks in the BSR matrix multiplied by the product of the block dimensions. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgebsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDim, + int colBlockDim, + const hipsparseMatDescr_t descrC, + float* csrValC, + int* csrRowPtrC, + int* csrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgebsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDim, + int colBlockDim, + const hipsparseMatDescr_t descrC, + double* csrValC, + int* csrRowPtrC, + int* csrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgebsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDim, + int colBlockDim, + const hipsparseMatDescr_t descrC, + hipComplex* csrValC, + int* csrRowPtrC, + int* csrColIndC); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgebsr2csr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDim, + int colBlockDim, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* csrValC, + int* csrRowPtrC, + int* csrColIndC); +/**@}*/ + +#ifdef __cplusplus +} +#endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsc.h b/library/include/conversion/hipsparse_gebsr2gebsc.h new file mode 100644 index 00000000..3b02f48f --- /dev/null +++ b/library/include/conversion/hipsparse_gebsr2gebsc.h @@ -0,0 +1,177 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief Convert a sparse GEneral BSR matrix into a sparse GEneral BSC matrix +* +* \details +* \p hipsparseXgebsr2gebsc_bufferSize returns the size of the temporary storage buffer +* required by hipsparseXgebsr2gebsc(). +* The temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgebsr2gebsc_bufferSize(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const float* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgebsr2gebsc_bufferSize(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const double* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgebsr2gebsc_bufferSize(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const hipComplex* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgebsr2gebsc_bufferSize(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const hipDoubleComplex* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + size_t* p_buffer_size); +/**@}*/ + +/*! \ingroup conv_module +* \brief Convert a sparse GEneral BSR matrix into a sparse GEneral BSC matrix +* +* \details +* \p hipsparseXgebsr2gebsc converts a GEneral BSR matrix into a GEneral BSC matrix. \p hipsparseXgebsr2gebsc +* can also be used to convert a GEneral BSC matrix into a GEneral BSR matrix. \p copy_values decides +* whether \p bsc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) +* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). +* +* \p hipsparseXgebsr2gebsc requires extra temporary storage buffer that has to be allocated +* by the user. Storage buffer size can be determined by hipsparseXgebsr2gebsc_bufferSize(). +* +* \note +* The resulting matrix can also be seen as the transpose of the input matrix. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgebsr2gebsc(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const float* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + float* bsc_val, + int* bsc_row_ind, + int* bsc_col_ptr, + hipsparseAction_t copy_values, + hipsparseIndexBase_t idx_base, + void* temp_buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgebsr2gebsc(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const double* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + double* bsc_val, + int* bsc_row_ind, + int* bsc_col_ptr, + hipsparseAction_t copy_values, + hipsparseIndexBase_t idx_base, + void* temp_buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgebsr2gebsc(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const hipComplex* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + hipComplex* bsc_val, + int* bsc_row_ind, + int* bsc_col_ptr, + hipsparseAction_t copy_values, + hipsparseIndexBase_t idx_base, + void* temp_buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgebsr2gebsc(hipsparseHandle_t handle, + int mb, + int nb, + int nnzb, + const hipDoubleComplex* bsr_val, + const int* bsr_row_ptr, + const int* bsr_col_ind, + int row_block_dim, + int col_block_dim, + hipDoubleComplex* bsc_val, + int* bsc_row_ind, + int* bsc_col_ptr, + hipsparseAction_t copy_values, + hipsparseIndexBase_t idx_base, + void* temp_buffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_gebsr2gebsr.h b/library/include/conversion/hipsparse_gebsr2gebsr.h new file mode 100644 index 00000000..dd046596 --- /dev/null +++ b/library/include/conversion/hipsparse_gebsr2gebsr.h @@ -0,0 +1,229 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief +* This function computes the the size of the user allocated temporary storage buffer used when converting a sparse +* general BSR matrix to another sparse general BSR matrix. +* +* \details +* \p hipsparseXgebsr2gebsr_bufferSize returns the size of the temporary storage buffer +* that is required by hipsparseXgebsr2gebsrNnz() and hipsparseXgebsr2gebsr(). +* The temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgebsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + int rowBlockDimC, + int colBlockDimC, + int* bufferSize); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgebsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + int rowBlockDimC, + int colBlockDimC, + int* bufferSize); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgebsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + int rowBlockDimC, + int colBlockDimC, + int* bufferSize); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgebsr2gebsr_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + int rowBlockDimC, + int colBlockDimC, + int* bufferSize); +/**@}*/ + +/*! \ingroup conv_module +* \brief This function is used when converting a general BSR sparse matrix \p A to another general BSR sparse matrix \p C. +* Specifically, this function determines the number of non-zero blocks that will exist in \p C (stored using either a host +* or device pointer), and computes the row pointer array for \p C. +* +* \details +* The routine does support asynchronous execution. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXgebsr2gebsrNnz(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + const hipsparseMatDescr_t descrC, + int* bsrRowPtrC, + int rowBlockDimC, + int colBlockDimC, + int* nnzTotalDevHostPtr, + void* buffer); + +/*! \ingroup conv_module +* \brief +* This function converts the general BSR sparse matrix \p A to another general BSR sparse matrix \p C. +* +* \details +* The conversion uses three steps. First, the user calls hipsparseXgebsr2gebsr_bufferSize() to determine the size of +* the required temporary storage buffer. The user then allocates this buffer. Secondly, the user then allocates \p mb_C+1 +* integers for the row pointer array for \p C where \p mb_C=(m+row_block_dim_C-1)/row_block_dim_C. The user then calls +* hipsparseXgebsr2gebsrNnz() to fill in the row pointer array for \p C ( \p bsr_row_ptr_C ) and determine the number of +* non-zero blocks that will exist in \p C. Finally, the user allocates space for the colimn indices array of \p C to have +* \p nnzb_C elements and space for the values array of \p C to have \p nnzb_C*roc_block_dim_C*col_block_dim_C and then calls +* hipsparseXgebsr2gebsr() to complete the conversion. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgebsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + const hipsparseMatDescr_t descrC, + float* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC, + int rowBlockDimC, + int colBlockDimC, + void* buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgebsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + const hipsparseMatDescr_t descrC, + double* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC, + int rowBlockDimC, + int colBlockDimC, + void* buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgebsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + const hipsparseMatDescr_t descrC, + hipComplex* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC, + int rowBlockDimC, + int colBlockDimC, + void* buffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgebsr2gebsr(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int rowBlockDimA, + int colBlockDimA, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* bsrValC, + int* bsrRowPtrC, + int* bsrColIndC, + int rowBlockDimC, + int colBlockDimC, + void* buffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_hyb2csr.h b/library/include/conversion/hipsparse_hyb2csr.h new file mode 100644 index 00000000..47ca3801 --- /dev/null +++ b/library/include/conversion/hipsparse_hyb2csr.h @@ -0,0 +1,79 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup conv_module +* \brief Convert a sparse HYB matrix into a sparse CSR matrix +* +* \details +* \p hipsparseXhyb2csr converts a HYB matrix into a CSR matrix. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseShyb2csr(hipsparseHandle_t handle, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + float* csrSortedValA, + int* csrSortedRowPtrA, + int* csrSortedColIndA); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDhyb2csr(hipsparseHandle_t handle, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + double* csrSortedValA, + int* csrSortedRowPtrA, + int* csrSortedColIndA); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseChyb2csr(hipsparseHandle_t handle, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + hipComplex* csrSortedValA, + int* csrSortedRowPtrA, + int* csrSortedColIndA); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZhyb2csr(hipsparseHandle_t handle, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + hipDoubleComplex* csrSortedValA, + int* csrSortedRowPtrA, + int* csrSortedColIndA); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_nnz.h b/library/include/conversion/hipsparse_nnz.h new file mode 100644 index 00000000..6fc56af8 --- /dev/null +++ b/library/include/conversion/hipsparse_nnz.h @@ -0,0 +1,86 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module +* \brief +* This function computes the number of nonzero elements per row or column and the total +* number of nonzero elements in a dense matrix. +* +* \details +* The routine does support asynchronous execution if the pointer mode is set to device. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSnnz(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const float* A, + int lda, + int* nnzPerRowColumn, + int* nnzTotalDevHostPtr); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnnz(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const double* A, + int lda, + int* nnzPerRowColumn, + int* nnzTotalDevHostPtr); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCnnz(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipComplex* A, + int lda, + int* nnzPerRowColumn, + int* nnzTotalDevHostPtr); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZnnz(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int m, + int n, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* A, + int lda, + int* nnzPerRowColumn, + int* nnzTotalDevHostPtr); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_nnz_compress.h b/library/include/conversion/hipsparse_nnz_compress.h new file mode 100644 index 00000000..70083f1e --- /dev/null +++ b/library/include/conversion/hipsparse_nnz_compress.h @@ -0,0 +1,85 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* Given a sparse CSR matrix and a non-negative tolerance, this function computes how many entries would be left +* in each row of the matrix if elements less than the tolerance were removed. It also computes the total number +* of remaining elements in the matrix. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSnnz_compress(hipsparseHandle_t handle, + int m, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + int* nnzPerRow, + int* nnzC, + float tol); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnnz_compress(hipsparseHandle_t handle, + int m, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + int* nnzPerRow, + int* nnzC, + double tol); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCnnz_compress(hipsparseHandle_t handle, + int m, + const hipsparseMatDescr_t descrA, + const hipComplex* csrValA, + const int* csrRowPtrA, + int* nnzPerRow, + int* nnzC, + hipComplex tol); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZnnz_compress(hipsparseHandle_t handle, + int m, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrValA, + const int* csrRowPtrA, + int* nnzPerRow, + int* nnzC, + hipDoubleComplex tol); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_csr2csr.h b/library/include/conversion/hipsparse_prune_csr2csr.h new file mode 100644 index 00000000..a7d4c11f --- /dev/null +++ b/library/include/conversion/hipsparse_prune_csr2csr.h @@ -0,0 +1,218 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup conv_module + * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXpruneCsr2csr_bufferSize returns the size of the temporary buffer that + * is required by \p hipsparseXpruneCsr2csrNnz and hipsparseXpruneCsr2csr. The + * temporary storage buffer must be allocated by the user. + */ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csr_bufferSize(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* threshold, + const hipsparseMatDescr_t descrC, + const float* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + size_t* bufferSize); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csr_bufferSize(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* threshold, + const hipsparseMatDescr_t descrC, + const double* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + size_t* bufferSize); +/**@}*/ + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXpruneCsr2csr_bufferSizeExt returns the size of the temporary buffer that + * is required by \p hipsparseXpruneCsr2csrNnz and hipsparseXpruneCsr2csr. The + * temporary storage buffer must be allocated by the user. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* threshold, + const hipsparseMatDescr_t descrC, + const float* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + size_t* bufferSize); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* threshold, + const hipsparseMatDescr_t descrC, + const double* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + size_t* bufferSize); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXpruneCsr2csrNnz computes the number of nonzero elements per row and the total + * number of nonzero elements in a sparse CSR matrix once elements less than the threshold are + * pruned from the matrix. + * + * \note The routine does support asynchronous execution if the pointer mode is set to device. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csrNnz(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* threshold, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csrNnz(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* threshold, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr, + void* buffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix + * + * \details + * This function converts the sparse CSR matrix A into a sparse CSR matrix C by pruning values in A + * that are less than the threshold. All the parameters are assumed to have been pre-allocated by the user. + * The user first calls hipsparseXpruneCsr2csr_bufferSize() to determine the size of the buffer used + * by hipsparseXpruneCsr2csrNnz() and hipsparseXpruneCsr2csr() which the user then allocates. The user then + * allocates \p csr_row_ptr_C to have \p m+1 elements and then calls hipsparseXpruneCsr2csrNnz() which fills + * in the \p csr_row_ptr_C array stores then number of elements that are larger than the pruning threshold + * in \p nnz_total_dev_host_ptr. The user then calls hipsparseXpruneCsr2csr() to complete the conversion. It + * is executed asynchronously with respect to the host and may return control to the application on the host + * before the entire result is ready. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csr(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* threshold, + const hipsparseMatDescr_t descrC, + float* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csr(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* threshold, + const hipsparseMatDescr_t descrC, + double* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + void* buffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h new file mode 100644 index 00000000..1d72b3a0 --- /dev/null +++ b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h @@ -0,0 +1,229 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXpruneCsr2csrByPercentage_bufferSize returns the size of the temporary buffer that + * is required by \p hipsparseXpruneCsr2csrNnzByPercentage. + * The temporary storage buffer must be allocated by the user. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csrByPercentage_bufferSize(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + float percentage, + const hipsparseMatDescr_t descrC, + const float* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + pruneInfo_t info, + size_t* bufferSize); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage_bufferSize(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + double percentage, + const hipsparseMatDescr_t descrC, + const double* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + pruneInfo_t info, + size_t* bufferSize); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXpruneCsr2csrByPercentage_bufferSizeExt returns the size of the temporary buffer that + * is required by \p hipsparseXpruneCsr2csrNnzByPercentage. + * The temporary storage buffer must be allocated by the user. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + float percentage, + const hipsparseMatDescr_t descrC, + const float* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + pruneInfo_t info, + size_t* bufferSize); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + double percentage, + const hipsparseMatDescr_t descrC, + const double* csrValC, + const int* csrRowPtrC, + const int* csrColIndC, + pruneInfo_t info, + size_t* bufferSize); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix + * + * \details + * \p hipsparseXpruneCsr2csrNnzByPercentage computes the number of nonzero elements per row and the total + * number of nonzero elements in a sparse CSR matrix once elements less than the threshold are + * pruned from the matrix. + * + * \note The routine does support asynchronous execution if the pointer mode is set to device. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csrNnzByPercentage(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + float percentage, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr, + pruneInfo_t info, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csrNnzByPercentage(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + double percentage, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr, + pruneInfo_t info, + void* buffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module + * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix + * + * \details + * This function converts the sparse CSR matrix A into a sparse CSR matrix C by pruning values in A + * that are less than the threshold. All the parameters are assumed to have been pre-allocated by the user. + * The user first calls hipsparseXpruneCsr2csr_bufferSize() to determine the size of the buffer used + * by hipsparseXpruneCsr2csrNnz() and hipsparseXpruneCsr2csr() which the user then allocates. The user then + * allocates \p csr_row_ptr_C to have \p m+1 elements and then calls hipsparseXpruneCsr2csrNnz() which fills + * in the \p csr_row_ptr_C array stores then number of elements that are larger than the pruning threshold + * in \p nnz_total_dev_host_ptr. The user then calls hipsparseXpruneCsr2csr() to complete the conversion. It + * is executed asynchronously with respect to the host and may return control to the application on the host + * before the entire result is ready. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneCsr2csrByPercentage(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + float percentage, + const hipsparseMatDescr_t descrC, + float* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + pruneInfo_t info, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage(hipsparseHandle_t handle, + int m, + int n, + int nnzA, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + double percentage, + const hipsparseMatDescr_t descrC, + double* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + pruneInfo_t info, + void* buffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_dense2csr.h b/library/include/conversion/hipsparse_prune_dense2csr.h new file mode 100644 index 00000000..da97e467 --- /dev/null +++ b/library/include/conversion/hipsparse_prune_dense2csr.h @@ -0,0 +1,190 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function computes the the size of the user allocated temporary storage buffer used when converting and pruning +* a dense matrix to a CSR matrix. +* +* \details +* \p hipsparseXpruneDense2csr_bufferSizeExt returns the size of the temporary storage buffer +* that is required by hipsparseXpruneDense2csrNnz() and hipsparseXpruneDense2csr(). The +* temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csr_bufferSize(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + const float* threshold, + const hipsparseMatDescr_t descr, + const float* csrVal, + const int* csrRowPtr, + const int* csrColInd, + size_t* bufferSize); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csr_bufferSize(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + const double* threshold, + const hipsparseMatDescr_t descr, + const double* csrVal, + const int* csrRowPtr, + const int* csrColInd, + size_t* bufferSize); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + const float* threshold, + const hipsparseMatDescr_t descr, + const float* csrVal, + const int* csrRowPtr, + const int* csrColInd, + size_t* bufferSize); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csr_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + const double* threshold, + const hipsparseMatDescr_t descr, + const double* csrVal, + const int* csrRowPtr, + const int* csrColInd, + size_t* bufferSize); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function computes the number of nonzero elements per row and the total number of +* nonzero elements in a dense matrix once elements less than the threshold are pruned +* from the matrix. +* +* \details +* The routine does support asynchronous execution if the pointer mode is set to device. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csrNnz(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + const float* threshold, + const hipsparseMatDescr_t descr, + int* csrRowPtr, + int* nnzTotalDevHostPtr, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csrNnz(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + const double* threshold, + const hipsparseMatDescr_t descr, + int* csrRowPtr, + int* nnzTotalDevHostPtr, + void* buffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function converts the matrix A in dense format into a sparse matrix in CSR format +* while pruning values that are less than the threshold. All the parameters are assumed +* to have been pre-allocated by the user. +* +* \details +* The user first allocates \p csrRowPtr to have \p m+1 elements and then calls +* hipsparseXpruneDense2csrNnz() which fills in the \p csrRowPtr array and stores the +* number of elements that are larger than the pruning threshold in \p nnzTotalDevHostPtr. +* The user then allocates \p csrColInd and \p csrVal to have size \p nnzTotalDevHostPtr +* and completes the conversion by calling hipsparseXpruneDense2csr(). A temporary storage +* buffer is used by both hipsparseXpruneDense2csrNnz() and hipsparseXpruneDense2csr() and +* must be allocated by the user and whose size is determined by +* hipsparseXpruneDense2csr_bufferSizeExt(). The routine hipsparseXpruneDense2csr() is +* executed asynchronously with respect to the host and may return control to the +* application on the host before the entire result is ready. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csr(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + const float* threshold, + const hipsparseMatDescr_t descr, + float* csrVal, + const int* csrRowPtr, + int* csrColInd, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csr(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + const double* threshold, + const hipsparseMatDescr_t descr, + double* csrVal, + const int* csrRowPtr, + int* csrColInd, + void* buffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h new file mode 100644 index 00000000..4a03fcd8 --- /dev/null +++ b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h @@ -0,0 +1,279 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function computes the size of the user allocated temporary storage buffer used +* when converting and pruning by percentage a dense matrix to a CSR matrix. +* +* \details +* When converting and pruning a dense matrix A to a CSR matrix by percentage the +* following steps are performed. First the user calls +* \p hipsparseXpruneDense2csrByPercentage_bufferSize which determines the size of the +* temporary storage buffer. Once determined, this buffer must be allocated by the user. +* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls +* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion +* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value +* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. +* +* The pruning by percentage works by first sorting the absolute values of the dense +* matrix \p A. We then determine a position in this sorted array by +* \f[ +* pos = ceil(m*n*(percentage/100)) - 1 +* pos = min(pos, m*n-1) +* pos = max(pos, 0) +* threshold = sorted_A[pos] +* \f] +* Once we have this threshold we prune values in the dense matrix \p A as in +* \p hipsparseXpruneDense2csr. It is executed asynchronously with respect to the host +* and may return control to the application on the host before the entire result is +* ready. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csrByPercentage_bufferSize(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + float percentage, + const hipsparseMatDescr_t descr, + const float* csrVal, + const int* csrRowPtr, + const int* csrColInd, + pruneInfo_t info, + size_t* bufferSize); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csrByPercentage_bufferSize(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + double percentage, + const hipsparseMatDescr_t descr, + const double* csrVal, + const int* csrRowPtr, + const int* csrColInd, + pruneInfo_t info, + size_t* bufferSize); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function computes the size of the user allocated temporary storage buffer used +* when converting and pruning by percentage a dense matrix to a CSR matrix. +* +* \details +* When converting and pruning a dense matrix A to a CSR matrix by percentage the +* following steps are performed. First the user calls +* \p hipsparseXpruneDense2csrByPercentage_bufferSizeExt which determines the size of the +* temporary storage buffer. Once determined, this buffer must be allocated by the user. +* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls +* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion +* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value +* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. +* +* The pruning by percentage works by first sorting the absolute values of the dense +* matrix \p A. We then determine a position in this sorted array by +* \f[ +* pos = ceil(m*n*(percentage/100)) - 1 +* pos = min(pos, m*n-1) +* pos = max(pos, 0) +* threshold = sorted_A[pos] +* \f] +* Once we have this threshold we prune values in the dense matrix \p A as in +* \p hipsparseXpruneDense2csr. It is executed asynchronously with respect to the host +* and may return control to the application on the host before the entire result is +* ready. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseSpruneDense2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + float percentage, + const hipsparseMatDescr_t descr, + const float* csrVal, + const int* csrRowPtr, + const int* csrColInd, + pruneInfo_t info, + size_t* bufferSize); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseDpruneDense2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + double percentage, + const hipsparseMatDescr_t descr, + const double* csrVal, + const int* csrRowPtr, + const int* csrColInd, + pruneInfo_t info, + size_t* bufferSize); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function computes the number of nonzero elements per row and the total number of +* nonzero elements in a dense matrix when converting and pruning by percentage a dense +* matrix to a CSR matrix. +* +* \details +* When converting and pruning a dense matrix A to a CSR matrix by percentage the +* following steps are performed. First the user calls +* \p hipsparseXpruneDense2csrByPercentage_bufferSize which determines the size of the +* temporary storage buffer. Once determined, this buffer must be allocated by the user. +* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls +* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion +* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value +* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. +* +* The pruning by percentage works by first sorting the absolute values of the dense +* matrix \p A. We then determine a position in this sorted array by +* \f[ +* pos = ceil(m*n*(percentage/100)) - 1 +* pos = min(pos, m*n-1) +* pos = max(pos, 0) +* threshold = sorted_A[pos] +* \f] +* Once we have this threshold we prune values in the dense matrix \p A as in +* \p hipsparseXpruneDense2csr. The routine does support asynchronous execution if the +* pointer mode is set to device. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csrNnzByPercentage(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + float percentage, + const hipsparseMatDescr_t descr, + int* csrRowPtr, + int* nnzTotalDevHostPtr, + pruneInfo_t info, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csrNnzByPercentage(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + double percentage, + const hipsparseMatDescr_t descr, + int* csrRowPtr, + int* nnzTotalDevHostPtr, + pruneInfo_t info, + void* buffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup conv_module +* \brief +* This function computes the number of nonzero elements per row and the total number of +* nonzero elements in a dense matrix when converting and pruning by percentage a dense +* matrix to a CSR matrix. +* +* \details +* When converting and pruning a dense matrix A to a CSR matrix by percentage the +* following steps are performed. First the user calls +* \p hipsparseXpruneDense2csrByPercentage_bufferSize which determines the size of the +* temporary storage buffer. Once determined, this buffer must be allocated by the user. +* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls +* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion +* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value +* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. +* +* The pruning by percentage works by first sorting the absolute values of the dense +* matrix \p A. We then determine a position in this sorted array by +* \f[ +* pos = ceil(m*n*(percentage/100)) - 1 +* pos = min(pos, m*n-1) +* pos = max(pos, 0) +* threshold = sorted_A[pos] +* \f] +* Once we have this threshold we prune values in the dense matrix \p A as in +* \p hipsparseXpruneDense2csr. The routine does support asynchronous execution if the +* pointer mode is set to device. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpruneDense2csrByPercentage(hipsparseHandle_t handle, + int m, + int n, + const float* A, + int lda, + float percentage, + const hipsparseMatDescr_t descr, + float* csrVal, + const int* csrRowPtr, + int* csrColInd, + pruneInfo_t info, + void* buffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDpruneDense2csrByPercentage(hipsparseHandle_t handle, + int m, + int n, + const double* A, + int lda, + double percentage, + const hipsparseMatDescr_t descr, + double* csrVal, + const int* csrRowPtr, + int* csrColInd, + pruneInfo_t info, + void* buffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/extra/hipsparse_csrgeam.h b/library/include/extra/hipsparse_csrgeam.h new file mode 100644 index 00000000..4aba4f4f --- /dev/null +++ b/library/include/extra/hipsparse_csrgeam.h @@ -0,0 +1,423 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix addition using CSR storage format +* +* \details +* \p hipsparseXcsrgeamNnz computes the total CSR non-zero elements and the CSR row +* offsets, that point to the start of every row of the sparse CSR matrix, of the +* resulting matrix C. It is assumed that \p csr_row_ptr_C has been allocated with +* size \p m + 1. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* \note +* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsrgeamNnz(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr); + +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix addition using CSR storage format +* +* \details +* \p hipsparseXcsrgeam multiplies the scalar \f$\alpha\f$ with the sparse +* \f$m \times n\f$ matrix \f$A\f$, defined in CSR storage format, multiplies the +* scalar \f$\beta\f$ with the sparse \f$m \times n\f$ matrix \f$B\f$, defined in CSR +* storage format, and adds both resulting matrices to obtain the sparse +* \f$m \times n\f$ matrix \f$C\f$, defined in CSR storage format, such that +* \f[ +* C := \alpha \cdot A + \beta \cdot B. +* \f] +* +* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and +* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of +* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of +* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgeamNnz(). +* +* \note Both scalars \f$\alpha\f$ and \f$beta\f$ have to be valid. +* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +* \note This function is non blocking and executed asynchronously with respect to the +* host. It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrgeam(hipsparseHandle_t handle, + int m, + int n, + const float* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const float* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + float* csrValC, + int* csrRowPtrC, + int* csrColIndC); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrgeam(hipsparseHandle_t handle, + int m, + int n, + const double* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const double* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + double* csrValC, + int* csrRowPtrC, + int* csrColIndC); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrgeam(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipComplex* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipComplex* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + hipComplex* csrValC, + int* csrRowPtrC, + int* csrColIndC); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrgeam(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipDoubleComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipDoubleComplex* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipDoubleComplex* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* csrValC, + int* csrRowPtrC, + int* csrColIndC); +/**@}*/ +#endif + +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrgeam2_bufferSizeExt returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXcsrgeam2Nnz() and hipsparseXcsrgeam2(). The +* temporary storage buffer must be allocated by the user. +* +* \note +* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrgeam2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const float* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const float* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + const float* csrSortedValC, + const int* csrSortedRowPtrC, + const int* csrSortedColIndC, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrgeam2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const double* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const double* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + const double* csrSortedValC, + const int* csrSortedRowPtrC, + const int* csrSortedColIndC, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrgeam2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipComplex* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + const hipComplex* csrSortedValC, + const int* csrSortedRowPtrC, + const int* csrSortedColIndC, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrgeam2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipDoubleComplex* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + const hipDoubleComplex* csrSortedValC, + const int* csrSortedRowPtrC, + const int* csrSortedColIndC, + size_t* pBufferSizeInBytes); +/**@}*/ + +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix addition using CSR storage format +* +* \details +* \p hipsparseXcsrgeam2Nnz computes the total CSR non-zero elements and the CSR row +* offsets, that point to the start of every row of the sparse CSR matrix, of the +* resulting matrix C. It is assumed that \p csr_row_ptr_C has been allocated with +* size \p m + 1. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* \note +* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsrgeam2Nnz(hipsparseHandle_t handle, + int m, + int n, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + int* csrSortedRowPtrC, + int* nnzTotalDevHostPtr, + void* workspace); + + +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix addition using CSR storage format +* +* \details +* \p hipsparseXcsrgeam2 multiplies the scalar \f$\alpha\f$ with the sparse +* \f$m \times n\f$ matrix \f$A\f$, defined in CSR storage format, multiplies the +* scalar \f$\beta\f$ with the sparse \f$m \times n\f$ matrix \f$B\f$, defined in CSR +* storage format, and adds both resulting matrices to obtain the sparse +* \f$m \times n\f$ matrix \f$C\f$, defined in CSR storage format, such that +* \f[ +* C := \alpha \cdot A + \beta \cdot B. +* \f] +* +* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and +* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of +* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of +* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgeam2Nnz(). +* +* \note Both scalars \f$\alpha\f$ and \f$beta\f$ have to be valid. +* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +* \note This function is non blocking and executed asynchronously with respect to the +* host. It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrgeam2(hipsparseHandle_t handle, + int m, + int n, + const float* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const float* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + float* csrSortedValC, + int* csrSortedRowPtrC, + int* csrSortedColIndC, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrgeam2(hipsparseHandle_t handle, + int m, + int n, + const double* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const double* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + double* csrSortedValC, + int* csrSortedRowPtrC, + int* csrSortedColIndC, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrgeam2(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipComplex* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + hipComplex* csrSortedValC, + int* csrSortedRowPtrC, + int* csrSortedColIndC, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrgeam2(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* beta, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipDoubleComplex* csrSortedValB, + const int* csrSortedRowPtrB, + const int* csrSortedColIndB, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* csrSortedValC, + int* csrSortedRowPtrC, + int* csrSortedColIndC, + void* pBuffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/extra/hipsparse_csrgemm.h b/library/include/extra/hipsparse_csrgemm.h new file mode 100644 index 00000000..224b760c --- /dev/null +++ b/library/include/extra/hipsparse_csrgemm.h @@ -0,0 +1,530 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrgemmNnz computes the total CSR non-zero elements and the CSR row +* offsets, that point to the start of every row of the sparse CSR matrix, of the +* resulting multiplied matrix C. It is assumed that \p csr_row_ptr_C has been allocated +* with size \p m + 1. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Please note, that for matrix products with more than 8192 intermediate products per +* row, additional temporary storage buffer is allocated by the algorithm. +* +* \note +* Currently, only \p trans_A == \p trans_B == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is +* supported. +* +* \note +* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsrgemmNnz(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr); + + + +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrgemm multiplies the sparse \f$m \times k\f$ matrix \f$A\f$, defined in +* CSR storage format with the sparse \f$k \times n\f$ matrix \f$B\f$, defined in CSR +* storage format, and stores the result in the sparse \f$m \times n\f$ matrix \f$C\f$, +* defined in CSR storage format, such that +* \f[ +* C := op(A) \cdot op(B), +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* and +* \f[ +* op(B) = \left\{ +* \begin{array}{ll} +* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and +* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of +* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of +* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgemmNnz(). +* +* \note Currently, only \p trans_A == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. +* \note Currently, only \p trans_B == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. +* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +* \note This function is non blocking and executed asynchronously with respect to the +* host. It may return before the actual computation has finished. +* \note Please note, that for matrix products with more than 4096 non-zero entries per +* row, additional temporary storage buffer is allocated by the algorithm. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrgemm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + const hipsparseMatDescr_t descrA, + int nnzA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const float* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + float* csrValC, + const int* csrRowPtrC, + int* csrColIndC); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrgemm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + const hipsparseMatDescr_t descrA, + int nnzA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const double* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + double* csrValC, + const int* csrRowPtrC, + int* csrColIndC); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrgemm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipComplex* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + hipComplex* csrValC, + const int* csrRowPtrC, + int* csrColIndC); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrgemm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipDoubleComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipDoubleComplex* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* csrValC, + const int* csrRowPtrC, + int* csrColIndC); +/**@}*/ +#endif + + + + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrgemm2_bufferSizeExt returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXcsrgemm2Nnz() and hipsparseXcsrgemm2(). The +* temporary storage buffer must be allocated by the user. +* +* \note +* Please note, that for matrix products with more than 4096 non-zero entries per row, +* additional temporary storage buffer is allocated by the algorithm. +* +* \note +* Please note, that for matrix products with more than 8192 intermediate products per +* row, additional temporary storage buffer is allocated by the algorithm. +* +* \note +* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrgemm2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int k, + const float* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const float* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const int* csrRowPtrD, + const int* csrColIndD, + csrgemm2Info_t info, + size_t* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrgemm2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int k, + const double* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const double* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const int* csrRowPtrD, + const int* csrColIndD, + csrgemm2Info_t info, + size_t* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrgemm2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int k, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipComplex* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const int* csrRowPtrD, + const int* csrColIndD, + csrgemm2Info_t info, + size_t* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrgemm2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + int k, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipDoubleComplex* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const int* csrRowPtrD, + const int* csrColIndD, + csrgemm2Info_t info, + size_t* pBufferSizeInBytes); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrgemm2Nnz computes the total CSR non-zero elements and the CSR row +* offsets, that point to the start of every row of the sparse CSR matrix, of the +* resulting multiplied matrix C. It is assumed that \p csr_row_ptr_C has been allocated +* with size \p m + 1. +* The required buffer size can be obtained by hipsparseXcsrgemm2_bufferSizeExt(). +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Please note, that for matrix products with more than 8192 intermediate products per +* row, additional temporary storage buffer is allocated by the algorithm. +* +* \note +* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseXcsrgemm2Nnz(hipsparseHandle_t handle, + int m, + int n, + int k, + const hipsparseMatDescr_t descrA, + int nnzA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipsparseMatDescr_t descrD, + int nnzD, + const int* csrRowPtrD, + const int* csrColIndD, + const hipsparseMatDescr_t descrC, + int* csrRowPtrC, + int* nnzTotalDevHostPtr, + const csrgemm2Info_t info, + void* pBuffer); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup extra_module +* \brief Sparse matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrgemm2 multiplies the scalar \f$\alpha\f$ with the sparse +* \f$m \times k\f$ matrix \f$A\f$, defined in CSR storage format, and the sparse +* \f$k \times n\f$ matrix \f$B\f$, defined in CSR storage format, and adds the result +* to the sparse \f$m \times n\f$ matrix \f$D\f$ that is multiplied by \f$\beta\f$. The +* final result is stored in the sparse \f$m \times n\f$ matrix \f$C\f$, defined in CSR +* storage format, such +* that +* \f[ +* C := \alpha \cdot A \cdot B + \beta \cdot D +* \f] +* +* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and +* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of +* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of +* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgemm2Nnz(). The +* required buffer size for the computation can be obtained by +* hipsparseXcsrgemm2_bufferSizeExt(). +* +* \note If \f$\alpha == 0\f$, then \f$C = \beta \cdot D\f$ will be computed. +* \note If \f$\beta == 0\f$, then \f$C = \alpha \cdot A \cdot B\f$ will be computed. +* \note \f$\alpha == beta == 0\f$ is invalid. +* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. +* \note This function is non blocking and executed asynchronously with respect to the +* host. It may return before the actual computation has finished. +* \note Please note, that for matrix products with more than 4096 non-zero entries per +* row, additional temporary storage buffer is allocated by the algorithm. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrgemm2(hipsparseHandle_t handle, + int m, + int n, + int k, + const float* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const float* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const float* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const float* csrValD, + const int* csrRowPtrD, + const int* csrColIndD, + const hipsparseMatDescr_t descrC, + float* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + const csrgemm2Info_t info, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrgemm2(hipsparseHandle_t handle, + int m, + int n, + int k, + const double* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const double* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const double* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const double* csrValD, + const int* csrRowPtrD, + const int* csrColIndD, + const hipsparseMatDescr_t descrC, + double* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + const csrgemm2Info_t info, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrgemm2(hipsparseHandle_t handle, + int m, + int n, + int k, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipComplex* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipComplex* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const hipComplex* csrValD, + const int* csrRowPtrD, + const int* csrColIndD, + const hipsparseMatDescr_t descrC, + hipComplex* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + const csrgemm2Info_t info, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrgemm2(hipsparseHandle_t handle, + int m, + int n, + int k, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + int nnzA, + const hipDoubleComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const hipsparseMatDescr_t descrB, + int nnzB, + const hipDoubleComplex* csrValB, + const int* csrRowPtrB, + const int* csrColIndB, + const hipDoubleComplex* beta, + const hipsparseMatDescr_t descrD, + int nnzD, + const hipDoubleComplex* csrValD, + const int* csrRowPtrD, + const int* csrColIndD, + const hipsparseMatDescr_t descrC, + hipDoubleComplex* csrValC, + const int* csrRowPtrC, + int* csrColIndC, + const csrgemm2Info_t info, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_axpby.h b/library/include/generic/hipsparse_axpby.h new file mode 100644 index 00000000..ae5329d5 --- /dev/null +++ b/library/include/generic/hipsparse_axpby.h @@ -0,0 +1,140 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Scale a sparse vector and add it to a scaled dense vector. +* +* \details +* \ref hipsparseAxpby multiplies the sparse vector \f$x\f$ with scalar \f$\alpha\f$ and +* adds the result to the dense vector \f$y\f$ that is multiplied with scalar +* \f$\beta\f$, such that +* +* \f[ +* y := \alpha \cdot x + \beta \cdot y +* \f] +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* y[x_ind[i]] = alpha * x_val[i] + beta * y[x_ind[i]] +* } +* \endcode +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Size of sparse and dense vector +* int size = 9; +* +* // Sparse index vector +* std::vector hx_ind = {0, 3, 5}; +* +* // Sparse value vector +* std::vector hx_val = {1.0f, 2.0f, 3.0f}; +* +* // Dense vector +* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // Scalar alpha +* float alpha = 3.7f; +* +* // Scalar beta +* float beta = 1.2f; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * size); +* +* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Create sparse vector X +* hipsparseSpVecDescr_t vecX; +* hipsparseCreateSpVec(&vecX, +* size, +* nnz, +* dx_ind, +* dx_val, +* HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, +* HIP_R_32F); +* +* // Create dense vector Y +* hipsparseDnVecDescr_t vecY; +* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); +* +* // Call axpby to perform y = beta * y + alpha * x +* hipsparseAxpby(handle, &alpha, vecX, &beta, vecY); +* +* hipsparseDnVecGetValues(vecY, (void**)&dy); +* +* // Copy result back to host +* hipMemcpy(hy.data(), dy, sizeof(float) * size, hipMemcpyDeviceToHost); +* +* +* // Clear hipSPARSE +* hipsparseDestroySpVec(vecX); +* hipsparseDestroyDnVec(vecY); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, + const void* alpha, + hipsparseConstSpVecDescr_t vecX, + const void* beta, + hipsparseDnVecDescr_t vecY); +#elif(CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, + const void* alpha, + hipsparseSpVecDescr_t vecX, + const void* beta, + hipsparseDnVecDescr_t vecY); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_dense2sparse.h b/library/include/generic/hipsparse_dense2sparse.h new file mode 100644 index 00000000..1334bce5 --- /dev/null +++ b/library/include/generic/hipsparse_dense2sparse.h @@ -0,0 +1,102 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Dense matrix to sparse matrix conversion +* +* \details +* \p hipsparseDenseToSparse_bufferSize computes the required user allocated buffer size needed when converting +* a dense matrix to a sparse matrix. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDenseToSparse_bufferSize(hipsparseHandle_t handle, + hipsparseConstDnMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseDenseToSparseAlg_t alg, + size_t* bufferSize); +#elif(CUDART_VERSION >= 11020) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDenseToSparse_bufferSize(hipsparseHandle_t handle, + hipsparseDnMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseDenseToSparseAlg_t alg, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Dense matrix to sparse matrix conversion +* +* \details +* \p hipsparseDenseToSparse_analysis performs analysis that is later used in \p hipsparseDenseToSparse_convert when +* converting a dense matrix to sparse matrix. This routine takes a user allocated buffer whose size must first be computed +* using \p hipsparseDenseToSparse_bufferSize. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDenseToSparse_analysis(hipsparseHandle_t handle, + hipsparseConstDnMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseDenseToSparseAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION >= 11020) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDenseToSparse_analysis(hipsparseHandle_t handle, + hipsparseDnMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseDenseToSparseAlg_t alg, + void* externalBuffer); +#endif + +/*! \ingroup generic_module +* \brief Description: Dense matrix to sparse matrix conversion +* +* \details +* \p hipsparseDenseToSparse_convert converts a dense matrix to a sparse matrix. This routine requires a user allocated buffer +* whose size must be determined by first calling \p hipsparseDenseToSparse_bufferSize. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t handle, + hipsparseConstDnMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseDenseToSparseAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION >= 11020) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t handle, + hipsparseDnMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseDenseToSparseAlg_t alg, + void* externalBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_gather.h b/library/include/generic/hipsparse_gather.h new file mode 100644 index 00000000..c3df4e4b --- /dev/null +++ b/library/include/generic/hipsparse_gather.h @@ -0,0 +1,121 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Gather elements from a dense vector and store them into a sparse vector. +* +* \details +* \ref hipsparseGather gathers the elements from the dense vector \f$y\f$ and stores +* them in the sparse vector \f$x\f$. +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* x_val[i] = y[x_ind[i]]; +* } +* \endcode +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Size of sparse and dense vector +* int size = 9; +* +* // Sparse index vector +* std::vector hx_ind = {0, 3, 5}; +* +* // Dense vector +* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * size); +* +* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Create sparse vector X +* hipsparseSpVecDescr_t vecX; +* hipsparseCreateSpVec(&vecX, +* size, +* nnz, +* dx_ind, +* dx_val, +* HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, +* HIP_R_32F); +* +* // Create dense vector Y +* hipsparseDnVecDescr_t vecY; +* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); +* +* // Perform gather +* hipsparseGather(handle, vecY, vecX); +* +* hipsparseSpVecGetValues(vecX, (void**)&dx_val); +* +* // Copy result back to host +* std::vector hx_val(nnz, 0.0f); +* hipMemcpy(hx_val.data(), dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroySpVec(vecX); +* hipsparseDestroyDnVec(vecY); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, + hipsparseConstDnVecDescr_t vecY, + hipsparseSpVecDescr_t vecX); +#elif(CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, + hipsparseDnVecDescr_t vecY, + hipsparseSpVecDescr_t vecX); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_rot.h b/library/include/generic/hipsparse_rot.h new file mode 100644 index 00000000..52427c97 --- /dev/null +++ b/library/include/generic/hipsparse_rot.h @@ -0,0 +1,137 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Apply Givens rotation to a dense and a sparse vector. +* +* \details +* \ref hipsparseRot applies the Givens rotation matrix \f$G\f$ to the sparse vector +* \f$x\f$ and the dense vector \f$y\f$, where +* \f[ +* G = \begin{pmatrix} c & s \\ -s & c \end{pmatrix} +* \f] +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* x_tmp = x_val[i]; +* y_tmp = y[x_ind[i]]; +* +* x_val[i] = c * x_tmp + s * y_tmp; +* y[x_ind[i]] = c * y_tmp - s * x_tmp; +* } +* \endcode +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Size of sparse and dense vector +* int size = 9; +* +* // Sparse index vector +* std::vector hx_ind = {0, 3, 5}; +* +* // Sparse value vector +* std::vector hx_val = {1.0f, 2.0f, 3.0f}; +* +* // Dense vector +* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // Scalar c +* float c = 3.7f; +* +* // Scalar s +* float s = 1.2f; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * size); +* +* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Create sparse vector X +* hipsparseSpVecDescr_t vecX; +* hipsparseCreateSpVec(&vecX, +* size, +* nnz, +* dx_ind, +* dx_val, +* HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, +* HIP_R_32F); +* +* // Create dense vector Y +* hipsparseDnVecDescr_t vecY; +* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); +* +* // Call rot +* hipsparseRot(handle, (void*)&c, (void*)&s, vecX, vecY); +* +* hipsparseSpVecGetValues(vecX, (void**)&dx_val); +* hipsparseDnVecGetValues(vecY, (void**)&dy); +* +* // Copy result back to host +* hipMemcpy(hx_val.data(), dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); +* hipMemcpy(hy.data(), dy, sizeof(float) * size, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroySpVec(vecX); +* hipsparseDestroyDnVec(vecY); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 11000 && CUDART_VERSION < 13000)) +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseRot(hipsparseHandle_t handle, + const void* c_coeff, + const void* s_coeff, + hipsparseSpVecDescr_t vecX, + hipsparseDnVecDescr_t vecY); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_scatter.h b/library/include/generic/hipsparse_scatter.h new file mode 100644 index 00000000..5371f191 --- /dev/null +++ b/library/include/generic/hipsparse_scatter.h @@ -0,0 +1,124 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Scatter elements from a sparse vector into a dense vector. +* +* \details +* \ref hipsparseScatter scatters the elements from the sparse vector \f$x\f$ in the dense +* vector \f$y\f$. +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* y[x_ind[i]] = x_val[i]; +* } +* \endcode +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Size of sparse and dense vector +* int size = 9; +* +* // Sparse index vector +* std::vector hx_ind = {0, 3, 5}; +* +* // Sparse value vector +* std::vector hx_val = {1.0f, 2.0f, 3.0f}; +* +* // Dense vector +* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * size); +* +* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Create sparse vector X +* hipsparseSpVecDescr_t vecX; +* hipsparseCreateSpVec(&vecX, +* size, +* nnz, +* dx_ind, +* dx_val, +* HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, +* HIP_R_32F); +* +* // Create dense vector Y +* hipsparseDnVecDescr_t vecY; +* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); +* +* // Perform scatter +* hipsparseScatter(handle, vecX, vecY); +* +* hipsparseDnVecGetValues(vecY, (void**)&dy); +* +* // Copy result back to host +* hipMemcpy(hy.data(), dy, sizeof(float) * size, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroySpVec(vecX); +* hipsparseDestroyDnVec(vecY); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, + hipsparseConstSpVecDescr_t vecX, + hipsparseDnVecDescr_t vecY); +#elif(CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, + hipsparseSpVecDescr_t vecX, + hipsparseDnVecDescr_t vecY); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_sddmm.h b/library/include/generic/hipsparse_sddmm.h new file mode 100644 index 00000000..11f570d6 --- /dev/null +++ b/library/include/generic/hipsparse_sddmm.h @@ -0,0 +1,168 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Calculate the buffer size required for the sampled dense dense matrix multiplication +* +* \details +* \p hipsparseSDDMM_bufferSize computes the required user allocated buffer size needed when computing the +* sampled dense dense matrix multiplication +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSDDMM_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstDnMatDescr_t A, + hipsparseConstDnMatDescr_t B, + const void* beta, + hipsparseSpMatDescr_t C, + hipDataType computeType, + hipsparseSDDMMAlg_t alg, + size_t* bufferSize); +#elif(CUDART_VERSION >= 11022) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSDDMM_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseDnMatDescr_t A, + const hipsparseDnMatDescr_t B, + const void* beta, + hipsparseSpMatDescr_t C, + hipDataType computeType, + hipsparseSDDMMAlg_t alg, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Preprocess step of the sampled dense dense matrix multiplication. +* +* \details +* \p hipsparseSDDMM_preprocess performs the required preprocessing used when computing the +* sampled dense dense matrix multiplication +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSDDMM_preprocess(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstDnMatDescr_t A, + hipsparseConstDnMatDescr_t B, + const void* beta, + hipsparseSpMatDescr_t C, + hipDataType computeType, + hipsparseSDDMMAlg_t alg, + void* tempBuffer); +#elif(CUDART_VERSION >= 11022) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSDDMM_preprocess(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseDnMatDescr_t A, + const hipsparseDnMatDescr_t B, + const void* beta, + hipsparseSpMatDescr_t C, + hipDataType computeType, + hipsparseSDDMMAlg_t alg, + void* tempBuffer); +#endif + +/*! \ingroup generic_module +* \brief Description: Sampled Dense-Dense Matrix Multiplication. +* +* \details +* \ref hipsparseSDDMM multiplies the scalar \f$\alpha\f$ with the dense +* \f$m \times k\f$ matrix \f$A\f$, the dense \f$k \times n\f$ matrix \f$B\f$, filtered by the sparsity pattern of the \f$m \times n\f$ sparse matrix \f$C\f$ and +* adds the result to \f$C\f$ scaled by +* \f$\beta\f$. The final result is stored in the sparse \f$m \times n\f$ matrix \f$C\f$, +* such that +* \f[ +* C := \alpha ( opA(A) \cdot opB(B) ) \cdot spy(C) + \beta C, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if opA == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if opA == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* \end{array} +* \right. +* \f], +* \f[ +* op(B) = \left\{ +* \begin{array}{ll} +* B, & \text{if opB == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* B^T, & \text{if opB == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* \end{array} +* \right. +* \f] +* and +* \f[ +* spy(C)_ij = \left\{ +* \begin{array}{ll} +* 1 \text{if i == j}, & 0 \text{if i != j} \\ +* \end{array} +* \right. +* \f] +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstDnMatDescr_t A, + hipsparseConstDnMatDescr_t B, + const void* beta, + hipsparseSpMatDescr_t C, + hipDataType computeType, + hipsparseSDDMMAlg_t alg, + void* tempBuffer); +#elif(CUDART_VERSION >= 11022) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseDnMatDescr_t A, + const hipsparseDnMatDescr_t B, + const void* beta, + hipsparseSpMatDescr_t C, + hipDataType computeType, + hipsparseSDDMMAlg_t alg, + void* tempBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_sparse2dense.h b/library/include/generic/hipsparse_sparse2dense.h new file mode 100644 index 00000000..1faebf73 --- /dev/null +++ b/library/include/generic/hipsparse_sparse2dense.h @@ -0,0 +1,78 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Sparse matrix to dense matrix conversion +* +* \details +* \p hipsparseSparseToDense_bufferSize computes the required user allocated buffer size needed when converting +* a sparse matrix to a dense matrix. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSparseToDense_bufferSize(hipsparseHandle_t handle, + hipsparseConstSpMatDescr_t matA, + hipsparseDnMatDescr_t matB, + hipsparseSparseToDenseAlg_t alg, + size_t* bufferSize); +#elif(CUDART_VERSION >= 11020) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSparseToDense_bufferSize(hipsparseHandle_t handle, + hipsparseSpMatDescr_t matA, + hipsparseDnMatDescr_t matB, + hipsparseSparseToDenseAlg_t alg, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Sparse matrix to dense matrix conversion +* +* \details +* \p hipsparseSparseToDense converts a sparse matrix to a dense matrix. This routine takes a user allocated buffer +* whose size must first be computed by calling \p hipsparseSparseToDense_bufferSize +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, + hipsparseConstSpMatDescr_t matA, + hipsparseDnMatDescr_t matB, + hipsparseSparseToDenseAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION >= 11020) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, + hipsparseSpMatDescr_t matA, + hipsparseDnMatDescr_t matB, + hipsparseSparseToDenseAlg_t alg, + void* externalBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spgemm.h b/library/include/generic/hipsparse_spgemm.h new file mode 100644 index 00000000..3c7f94f3 --- /dev/null +++ b/library/include/generic/hipsparse_spgemm.h @@ -0,0 +1,301 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Create sparse matrix sparse matrix product descriptor +* \details +* \p hipsparseSpGEMM_createDescr creates a sparse matrix sparse matrix product descriptor. It should be +* destroyed at the end using hipsparseSpGEMM_destroyDescr(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_createDescr(hipsparseSpGEMMDescr_t* descr); +#endif + +/*! \ingroup generic_module +* \brief Description: Destroy sparse matrix sparse matrix product descriptor +* \details +* \p hipsparseSpGEMM_destroyDescr destroys a sparse matrix sparse matrix product descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_destroyDescr(hipsparseSpGEMMDescr_t descr); +#endif + +/*! \ingroup generic_module +* \brief Description: Work estimation step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C +* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. +* +* \details +* \p hipsparseSpGEMM_workEstimation is called twice. We call it to compute the size of the first required user allocated +* buffer. After this buffer size is determined, the user allocates it and calls \p hipsparseSpGEMM_workEstimation +* a second time with the newly allocated buffer passed in. This second call inspects the matrices A and B to +* determine the number of intermediate products that will result from multipltying A and B together. +* +* \par Example (See full example below) +* \code{.c} +* void* dBuffer1 = NULL; +* size_t bufferSize1 = 0; +* +* hipsparseSpGEMMDescr_t spgemmDesc; +* hipsparseSpGEMM_createDescr(&spgemmDesc); +* +* size_t bufferSize1 = 0; +* hipsparseSpGEMM_workEstimation(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize1, NULL); +* hipMalloc((void**) &dBuffer1, bufferSize1); +* +* // Determine number of intermediate product when computing A * B +* hipsparseSpGEMM_workEstimation(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize1, dBuffer1); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_workEstimation(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize1, + void* externalBuffer1); +#elif(CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_workEstimation(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize1, + void* externalBuffer1); +#endif + +/*! \ingroup generic_module +* \brief Description: Compute step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C +* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. +* +* \details +* \p hipsparseSpGEMM_compute is called twice. First to compute the size of the second required user allocated +* buffer. After this buffer size is determined, the user allocates it and calls \p hipsparseSpGEMM_compute +* a second time with the newly allocated buffer passed in. This second call performs the actual computation +* of C' = alpha * A * B (the result is stored in the temporary buffers). +* +* \par Example (See full example below) +* \code{.c} +* void* dBuffer2 = NULL; +* size_t bufferSize2 = 0; +* +* size_t bufferSize2 = 0; +* hipsparseSpGEMM_compute(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize2, NULL); +* hipMalloc((void**) &dBuffer2, bufferSize2); +* +* // compute the intermediate product of A * B +* hipsparseSpGEMM_compute(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize2, dBuffer2); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_compute(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize2, + void* externalBuffer2); +#elif(CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_compute(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize2, + void* externalBuffer2); +#endif + +/*! \ingroup generic_module +* \brief Description: Copy step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C +* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. +* +* \details +* \p hipsparseSpGEMM_copy is called once to copy the results (that are currently stored in the temporary arrays) +* to the output sparse matrix. If beta != 0, then the beta * C portion of the computation: C' = alpha * A * B + beta * C +* is handled. This is possible because C' and C must have the same sparsity pattern. +* +* \note The two user allocated temporary buffers can only be freed after the call to \p hipsparseSpGEMM_copy +* +* \par Example (Full example) +* \code{.c} +* hipsparseHandle_t handle = NULL; +* hipsparseSpMatDescr_t matA, matB, matC; +* void* dBuffer1 = NULL; +* void* dBuffer2 = NULL; +* size_t bufferSize1 = 0; +* size_t bufferSize2 = 0; +* +* hipsparseCreate(&handle); +* +* // Create sparse matrix A in CSR format +* hipsparseCreateCsr(&matA, m, k, nnzA, +* dcsr_row_ptrA, dcsr_col_indA, dcsr_valA, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* hipsparseCreateCsr(&matB, k, n, nnzB, +* dcsr_row_ptrB, dcsr_col_indB, dcsr_valB, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* hipsparseCreateCsr(&matC, m, n, 0, +* dcsr_row_ptrC, NULL, NULL, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* +* hipsparseSpGEMMDescr_t spgemmDesc; +* hipsparseSpGEMM_createDescr(&spgemmDesc); +* +* // Determine size of first user allocated buffer +* hipsparseSpGEMM_workEstimation(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize1, NULL); +* hipMalloc((void**) &dBuffer1, bufferSize1); +* +* // Inspect the matrices A and B to determine the number of intermediate product in +* // C = alpha * A * B +* hipsparseSpGEMM_workEstimation(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize1, dBuffer1); +* +* // Determine size of second user allocated buffer +* hipsparseSpGEMM_compute(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize2, NULL); +* hipMalloc((void**) &dBuffer2, bufferSize2); +* +* // Compute C = alpha * A * B and store result in temporary buffers +* hipsparseSpGEMM_compute(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc, &bufferSize2, dBuffer2); +* +* // Get matrix C non-zero entries C_nnz1 +* int64_t C_num_rows1, C_num_cols1, C_nnz1; +* hipsparseSpMatGetSize(matC, &C_num_rows1, &C_num_cols1, &C_nnz1); +* +* // Allocate the CSR structures for the matrix C +* hipMalloc((void**) &dcsr_col_indC, C_nnz1 * sizeof(int)); +* hipMalloc((void**) &dcsr_valC, C_nnz1 * sizeof(float)); +* +* // Update matC with the new pointers +* hipsparseCsrSetPointers(matC, dcsr_row_ptrC, dcsr_col_indC, dcsr_valC); +* +* // Copy the final products to the matrix C +* hipsparseSpGEMM_copy(handle, opA, opB, +* &alpha, matA, matB, &beta, matC, +* computeType, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc); +* +* // Destroy matrix descriptors and handles +* hipsparseSpGEMM_destroyDescr(spgemmDesc); +* hipsparseDestroySpMat(matA); +* hipsparseDestroySpMat(matB); +* hipsparseDestroySpMat(matC); +* hipsparseDestroy(handle); +* +* // Free device memory +* hipFree(dBuffer1); +* hipFree(dBuffer2); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr); +#elif(CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spgemm_reuse.h b/library/include/generic/hipsparse_spgemm_reuse.h new file mode 100644 index 00000000..b81fa3d4 --- /dev/null +++ b/library/include/generic/hipsparse_spgemm_reuse.h @@ -0,0 +1,428 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Work estimation step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C +* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. +* +* \details +* \p hipsparseSpGEMMreuse_workEstimation is called twice. We call it to compute the size of the first required user allocated +* buffer. After this buffer size is determined, the user allocates it and calls \p hipsparseSpGEMMreuse_workEstimation +* a second time with the newly allocated buffer passed in. This second call inspects the matrices A and B to +* determine the number of intermediate products that will result from multipltying A and B together. +* +* \par Example (See full example below) +* \code{.c} +* void* dBuffer1 = NULL; +* size_t bufferSize1 = 0; +* +* hipsparseSpGEMMDescr_t spgemmDesc; +* hipsparseSpGEMM_createDescr(&spgemmDesc); +* +* size_t bufferSize1 = 0; +* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize1, NULL); +* hipMalloc((void**) &dBuffer1, bufferSize1); +* +* // Determine number of intermediate product when computing A * B +* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize1, dBuffer1); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_workEstimation(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + hipsparseSpMatDescr_t matC, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize1, + void* externalBuffer1); +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_workEstimation(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseSpMatDescr_t matC, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize1, + void* externalBuffer1); +#endif + +/*! \ingroup generic_module +* \brief Description: Nnz calculation step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C +* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. +* +* \par Example (See full example below) +* \code{.c} +* // Determine size of second, third, and fourth user allocated buffer +* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, +* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize2, NULL, &bufferSize3, NULL, +* &bufferSize4, NULL); +* +* hipMalloc((void**) &dBuffer2, bufferSize2); +* hipMalloc((void**) &dBuffer3, bufferSize3); +* hipMalloc((void**) &dBuffer4, bufferSize4); +* +* // COmpute sparsity pattern of C matrix and store in temporary buffers +* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, +* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize2, dBuffer2, &bufferSize3, dBuffer3, +* &bufferSize4, dBuffer4); +* +* // We can now free buffer 1 and 2 +* hipFree(dBuffer1); +* hipFree(dBuffer2); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_nnz(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + hipsparseSpMatDescr_t matC, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize2, + void* externalBuffer2, + size_t* bufferSize3, + void* externalBuffer3, + size_t* bufferSize4, + void* externalBuffer4); + +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_nnz(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseSpMatDescr_t matC, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize2, + void* externalBuffer2, + size_t* bufferSize3, + void* externalBuffer3, + size_t* bufferSize4, + void* externalBuffer4); + +#endif + +/*! \ingroup generic_module +* \brief Description: Copy step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C +* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. +* +* \par Example (See full example below) +* \code{.c} +* // Get matrix C non-zero entries nnzC +* int64_t rowsC, colsC, nnzC; +* hipsparseSpMatGetSize(matC, &rowsC, &colsC, &nnzC); +* +* // Allocate matrix C +* hipMalloc((void**) &dcsr_col_indC, sizeof(int) * nnzC); +* hipMalloc((void**) &dcsr_valC, sizeof(float) * nnzC); +* +* // Update matC with the new pointers. The C values array can be filled with data here +* // which is used if beta != 0. +* hipsparseCsrSetPointers(matC, dcsr_row_ptrC, dcsr_col_indC, dcsr_valC); +* +* // Determine size of fifth user allocated buffer +* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize5, NULL); +* +* hipMalloc((void**) &dBuffer5, bufferSize5); +* +* // Copy data from temporary buffers to the newly allocated C matrix +* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize5, dBuffer5); +* +* // We can now free buffer 3 +* hipFree(dBuffer3); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_copy(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + hipsparseSpMatDescr_t matC, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize5, + void* externalBuffer5); +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_copy(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + hipsparseSpMatDescr_t matC, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr, + size_t* bufferSize5, + void* externalBuffer5); +#endif + +/*! \ingroup generic_module +* \brief Description: Compute step of the sparse matrix sparse matrix product. +* +* \par Full example +* \code{.c} +* int m = 2; +* int k = 2; +* int n = 3; +* int nnzA = 4; +* int nnzB = 4; +* +* float alpha{1.0f}; +* float beta{0.0f}; +* +* hipsparseOperation_t opA = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseOperation_t opB = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipDataType computeType = HIP_R_32F; +* +* // A, B, and C are m×k, k×n, and m×n +* +* // A +* std::vector hcsr_row_ptrA = {0, 2, 4}; +* std::vector hcsr_col_indA = {0, 1, 0, 1}; +* std::vector hcsr_valA = {1.0f, 2.0f, 3.0f, 4.0f}; +* +* // B +* std::vector hcsr_row_ptrB = {0, 2, 4}; +* std::vector hcsr_col_indB = {1, 2, 0, 2}; +* std::vector hcsr_valB = {5.0f , 6.0f, 7.0f, 8.0f}; +* +* // Device memory management: Allocate and copy A, B +* int* dcsr_row_ptrA; +* int* dcsr_col_indA; +* float* dcsr_valA; +* int* dcsr_row_ptrB; +* int* dcsr_col_indB; +* float* dcsr_valB; +* int* dcsr_row_ptrC; +* int* dcsr_col_indC; +* float* dcsr_valC; +* hipMalloc((void**)&dcsr_row_ptrA, (m + 1) * sizeof(int)); +* hipMalloc((void**)&dcsr_col_indA, nnzA * sizeof(int)); +* hipMalloc((void**)&dcsr_valA, nnzA * sizeof(float)); +* hipMalloc((void**)&dcsr_row_ptrB, (k + 1) * sizeof(int)); +* hipMalloc((void**)&dcsr_col_indB, nnzB * sizeof(int)); +* hipMalloc((void**)&dcsr_valB, nnzB * sizeof(float)); +* hipMalloc((void**)&dcsr_row_ptrC, (m + 1) * sizeof(int)); +* +* hipMemcpy(dcsr_row_ptrA, hcsr_row_ptrA.data(), (m + 1) * sizeof(int), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_indA, hcsr_col_indA.data(), nnzA * sizeof(int), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_valA, hcsr_valA.data(), nnzA * sizeof(float), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_row_ptrB, hcsr_row_ptrB.data(), (k + 1) * sizeof(int), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_indB, hcsr_col_indB.data(), nnzB * sizeof(int), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_valB, hcsr_valB.data(), nnzB * sizeof(float), hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle = NULL; +* hipsparseSpMatDescr_t matA, matB, matC; +* void* dBuffer1 = NULL; +* void* dBuffer2 = NULL; +* void* dBuffer3 = NULL; +* void* dBuffer4 = NULL; +* void* dBuffer5 = NULL; +* size_t bufferSize1 = 0; +* size_t bufferSize2 = 0; +* size_t bufferSize3 = 0; +* size_t bufferSize4 = 0; +* size_t bufferSize5 = 0; +* +* hipsparseCreate(&handle); +* +* // Create sparse matrix A in CSR format +* hipsparseCreateCsr(&matA, m, k, nnzA, +* dcsr_row_ptrA, dcsr_col_indA, dcsr_valA, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* hipsparseCreateCsr(&matB, k, n, nnzB, +* dcsr_row_ptrB, dcsr_col_indB, dcsr_valB, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* hipsparseCreateCsr(&matC, m, n, 0, +* dcsr_row_ptrC, NULL, NULL, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* +* hipsparseSpGEMMDescr_t spgemmDesc; +* hipsparseSpGEMM_createDescr(&spgemmDesc); +* +* // Determine size of first user allocated buffer +* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize1, NULL); +* +* hipMalloc((void**) &dBuffer1, bufferSize1); +* +* // Inspect the matrices A and B to determine the number of intermediate product in +* // C = alpha * A * B +* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize1, dBuffer1); +* +* // Determine size of second, third, and fourth user allocated buffer +* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, +* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize2, NULL, &bufferSize3, NULL, +* &bufferSize4, NULL); +* +* hipMalloc((void**) &dBuffer2, bufferSize2); +* hipMalloc((void**) &dBuffer3, bufferSize3); +* hipMalloc((void**) &dBuffer4, bufferSize4); +* +* // COmpute sparsity pattern of C matrix and store in temporary buffers +* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, +* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize2, dBuffer2, &bufferSize3, dBuffer3, +* &bufferSize4, dBuffer4); +* +* // We can now free buffer 1 and 2 +* hipFree(dBuffer1); +* hipFree(dBuffer2); +* +* // Get matrix C non-zero entries nnzC +* int64_t rowsC, colsC, nnzC; +* hipsparseSpMatGetSize(matC, &rowsC, &colsC, &nnzC); +* +* // Allocate matrix C +* hipMalloc((void**) &dcsr_col_indC, sizeof(int) * nnzC); +* hipMalloc((void**) &dcsr_valC, sizeof(float) * nnzC); +* +* // Update matC with the new pointers. The C values array can be filled with data here +* // which is used if beta != 0. +* hipsparseCsrSetPointers(matC, dcsr_row_ptrC, dcsr_col_indC, dcsr_valC); +* +* // Determine size of fifth user allocated buffer +* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize5, NULL); +* +* hipMalloc((void**) &dBuffer5, bufferSize5); +* +* // Copy data from temporary buffers to the newly allocated C matrix +* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, +* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, +* &bufferSize5, dBuffer5); +* +* // We can now free buffer 3 +* hipFree(dBuffer3); +* +* // Compute C' = alpha * A * B + beta * C +* hipsparseSpGEMMreuse_compute(handle, opA, opB, &alpha, matA, matB, &beta, +* matC, computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc); +* +* // Copy results back to host if required using hipsparseCsrGet... +* +* // Update dcsr_valA, dcsr_valB with new values +* for(size_t i = 0; i < hcsr_valA.size(); i++){ hcsr_valA[i] = 1.0f; } +* for(size_t i = 0; i < hcsr_valB.size(); i++){ hcsr_valB[i] = 2.0f; } +* +* hipMemcpy(dcsr_valA, hcsr_valA.data(), sizeof(float) * nnzA, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_valB, hcsr_valB.data(), sizeof(float) * nnzB, hipMemcpyHostToDevice); +* +* // Compute C' = alpha * A * B + beta * C again with the new A and B values +* hipsparseSpGEMMreuse_compute(handle, opA, opB, &alpha, matA, matB, &beta, +* matC, computeType, HIPSPARSE_SPGEMM_DEFAULT, +* spgemmDesc); +* +* // Copy results back to host if required using hipsparseCsrGet... +* +* // Destroy matrix descriptors and handles +* hipsparseSpGEMM_destroyDescr(spgemmDesc); +* hipsparseDestroySpMat(matA); +* hipsparseDestroySpMat(matB); +* hipsparseDestroySpMat(matC); +* hipsparseDestroy(handle); +* +* // Free device memory +* hipFree(dBuffer4); +* hipFree(dBuffer5); +* hipFree(dcsr_row_ptrA); +* hipFree(dcsr_col_indA); +* hipFree(dcsr_valA); +* hipFree(dcsr_row_ptrB); +* hipFree(dcsr_col_indB); +* hipFree(dcsr_valB); +* hipFree(dcsr_row_ptrC); +* hipFree(dcsr_col_indC); +* hipFree(dcsr_valC); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_compute(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr); +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpGEMMreuse_compute(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseSpMatDescr_t matA, + hipsparseSpMatDescr_t matB, + const void* beta, + hipsparseSpMatDescr_t matC, + hipDataType computeType, + hipsparseSpGEMMAlg_t alg, + hipsparseSpGEMMDescr_t spgemmDescr); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spmm.h b/library/include/generic/hipsparse_spmm.h new file mode 100644 index 00000000..4ba4e599 --- /dev/null +++ b/library/include/generic/hipsparse_spmm.h @@ -0,0 +1,258 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Calculate the buffer size required for the sparse matrix multiplication with a dense matrix +* +* \details +* \p hipsparseSpMM_bufferSize computes the required user allocated buffer size needed when computing the +* sparse matrix multiplication with a dense matrix +* +* See full example below +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMM_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnMatDescr_t matB, + const void* beta, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpMMAlg_t alg, + size_t* bufferSize); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMM_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnMatDescr_t matB, + const void* beta, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpMMAlg_t alg, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Preprocess step of the sparse matrix multiplication with a dense matrix. +* +* \details +* \p hipsparseSpMM_preprocess performs the required preprocessing used when computing the +* sparse matrix multiplication with a dense matrix +* +* See full example below +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMM_preprocess(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnMatDescr_t matB, + const void* beta, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpMMAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION >= 11021) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMM_preprocess(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnMatDescr_t matB, + const void* beta, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpMMAlg_t alg, + void* externalBuffer); +#endif + +/*! \ingroup generic_module +* \brief Description: Compute the sparse matrix multiplication with a dense matrix +* +* \details +* \p hipsparseSpMM computes sparse matrix multiplication with a dense matrix +* +* \par Example +* \code{.c} +* // A, B, and C are m×k, k×n, and m×n +* int m = 3, n = 5, k = 4; +* int ldb = n, ldc = n; +* int nnz_A = 8, nnz_B = 20, nnz_C = 15; +* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseOperation_t transB = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseOperation_t transC = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseOrder_t order = HIPSPARSE_ORDER_ROW; +* +* // alpha and beta +* float alpha = 0.5f; +* float beta = 0.25f; +* +* std::vector hcsr_row_ptr = {0, 3, 5, 8}; +* std::vector hcsr_col_ind = {0, 1, 3, 1, 2, 0, 2, 3}; +* std::vector hcsr_val = {1, 2, 3, 4, 5, 6, 7, 8}; +* +* std::vector hB(nnz_B, 1.0f); +* std::vector hC(nnz_C, 1.0f); +* +* int *dcsr_row_ptr; +* int *dcsr_col_ind; +* float *dcsr_val; +* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz_A); +* hipMalloc((void**)&dcsr_val, sizeof(float) * nnz_A); +* +* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr.data(), sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_ind, hcsr_col_ind.data(), sizeof(int) * nnz_A, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_val, hcsr_val.data(), sizeof(float) * nnz_A, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* hipsparseSpMatDescr_t matA; +* hipsparseCreateCsr(&matA, m, k, nnz_A, +* dcsr_row_ptr, dcsr_col_ind, dcsr_val, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* +* // Allocate memory for the matrix B +* float* dB; +* hipMalloc((void**)&dB, sizeof(float) * nnz_B); +* hipMemcpy(dB, hB.data(), sizeof(float) * nnz_B, hipMemcpyHostToDevice); +* +* hipsparseDnMatDescr_t matB; +* hipsparseCreateDnMat(&matB, k, n, ldb, dB, HIP_R_32F, order); +* +* // Allocate memory for the resulting matrix C +* float* dC; +* hipMalloc((void**)&dC, sizeof(float) * nnz_C); +* hipMemcpy(dC, hC.data(), sizeof(float) * nnz_C, hipMemcpyHostToDevice); +* +* hipsparseDnMatDescr_t matC; +* hipsparseCreateDnMat(&matC, m, n, ldc, dC, HIP_R_32F, HIPSPARSE_ORDER_ROW); +* +* // Compute buffersize +* size_t bufferSize; +* hipsparseSpMM_bufferSize(handle, +* transA, +* transB, +* &alpha, +* matA, +* matB, +* &beta, +* matC, +* HIP_R_32F, +* HIPSPARSE_MM_ALG_DEFAULT, +* &bufferSize); +* +* void* buffer; +* hipMalloc(&buffer, bufferSize); +* +* // Preprocess operation (Optional) +* hipsparseSpMM_preprocess(handle, +* transA, +* transB, +* &alpha, +* matA, +* matB, +* &beta, +* matC, +* HIP_R_32F, +* HIPSPARSE_MM_ALG_DEFAULT, +* &buffer); +* +* // Perform operation +* hipsparseSpMM(handle, +* transA, +* transB, +* &alpha, +* matA, +* matB, +* &beta, +* matC, +* HIP_R_32F, +* HIPSPARSE_MM_ALG_DEFAULT, +* &buffer); +* +* // Copy device to host +* hipMemcpy(hC.data(), dC, sizeof(float) * nnz_C, hipMemcpyDeviceToHost); +* +* // Destroy matrix descriptors and handles +* hipsparseDestroySpMat(matA); +* hipsparseDestroyDnMat(matB); +* hipsparseDestroyDnMat(matC); +* hipsparseDestroy(handle); +* +* hipFree(buffer); +* hipFree(dcsr_row_ptr); +* hipFree(dcsr_col_ind); +* hipFree(dcsr_val); +* hipFree(dB); +* hipFree(dC); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnMatDescr_t matB, + const void* beta, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpMMAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnMatDescr_t matB, + const void* beta, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpMMAlg_t alg, + void* externalBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spmv.h b/library/include/generic/hipsparse_spmv.h new file mode 100644 index 00000000..405ee180 --- /dev/null +++ b/library/include/generic/hipsparse_spmv.h @@ -0,0 +1,246 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Buffer size step of the sparse matrix multiplication with a dense vector +* +* \details +* \p hipsparseSpMV_bufferSize computes the required user allocated buffer size needed when computing the +* sparse matrix multiplication with a dense vector +* +* See full example below +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMV_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnVecDescr_t vecX, + const void* beta, + const hipsparseDnVecDescr_t vecY, + hipDataType computeType, + hipsparseSpMVAlg_t alg, + size_t* bufferSize); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMV_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnVecDescr_t vecX, + const void* beta, + const hipsparseDnVecDescr_t vecY, + hipDataType computeType, + hipsparseSpMVAlg_t alg, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Preprocess step of the sparse matrix multiplication with a dense vector (optional) +* +* \details +* \p hipsparseSpMV_preprocess performs the optional preprocess used when computing the +* sparse matrix multiplication with a dense vector. This step is optional but if used may +* results in better performance. +* +* See full example below +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMV_preprocess(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnVecDescr_t vecX, + const void* beta, + const hipsparseDnVecDescr_t vecY, + hipDataType computeType, + hipsparseSpMVAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMV_preprocess(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnVecDescr_t vecX, + const void* beta, + const hipsparseDnVecDescr_t vecY, + hipDataType computeType, + hipsparseSpMVAlg_t alg, + void* externalBuffer); +#endif + +/*! \ingroup generic_module +* \brief Description: Compute the sparse matrix multiplication with a dense vector +* +* \details +* \p hipsparseSpMV computes sparse matrix multiplication with a dense vector +* +* \par Example +* \code{.c} +* // A, x, and y are m×k, k×1, and m×1 +* int m = 3, k = 4; +* int nnz_A = 8; +* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* +* // alpha and beta +* float alpha = 0.5f; +* float beta = 0.25f; +* +* std::vector hcsr_row_ptr = {0, 3, 5, 8}; +* std::vector hcsr_col_ind = {0, 1, 3, 1, 2, 0, 2, 3}; +* std::vector hcsr_val = {1, 2, 3, 4, 5, 6, 7, 8}; +* +* std::vector hx(k, 1.0f); +* std::vector hy(m, 1.0f); +* +* int *dcsr_row_ptr; +* int *dcsr_col_ind; +* float *dcsr_val; +* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz_A); +* hipMalloc((void**)&dcsr_val, sizeof(float) * nnz_A); +* +* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr.data(), sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_ind, hcsr_col_ind.data(), sizeof(int) * nnz_A, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_val, hcsr_val.data(), sizeof(float) * nnz_A, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* hipsparseSpMatDescr_t matA; +* hipsparseCreateCsr(&matA, m, k, nnz_A, +* dcsr_row_ptr, dcsr_col_ind, dcsr_val, +* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); +* +* // Allocate memory for the vector x +* float* dx; +* hipMalloc((void**)&dx, sizeof(float) * k); +* hipMemcpy(dx, hx.data(), sizeof(float) * k, hipMemcpyHostToDevice); +* +* hipsparseDnVecDescr_t vecX; +* hipsparseCreateDnVec(&vecX, k, dx, HIP_R_32F); +* +* // Allocate memory for the resulting vector y +* float* dy; +* hipMalloc((void**)&dy, sizeof(float) * m); +* hipMemcpy(dy, hy.data(), sizeof(float) * m, hipMemcpyHostToDevice); +* +* hipsparseDnMatDescr_t vecY; +* hipsparseCreateDnVec(&vecY, m, dy, HIP_R_32F); +* +* // Compute buffersize +* size_t bufferSize; +* hipsparseSpMV_bufferSize(handle, +* transA, +* &alpha, +* matA, +* vecX, +* &beta, +* vecY, +* HIP_R_32F, +* HIPSPARSE_MV_ALG_DEFAULT, +* &bufferSize); +* +* void* buffer; +* hipMalloc(&buffer, bufferSize); +* +* // Preprocess operation (Optional) +* hipsparseSpMV_preprocess(handle, +* transA, +* &alpha, +* matA, +* vecX, +* &beta, +* vecY, +* HIP_R_32F, +* HIPSPARSE_MV_ALG_DEFAULT, +* &buffer); +* +* // Perform operation +* hipsparseSpMV(handle, +* transA, +* &alpha, +* matA, +* vecX, +* &beta, +* vecY, +* HIP_R_32F, +* HIPSPARSE_MV_ALG_DEFAULT, +* &buffer); +* +* // Copy device to host +* hipMemcpy(hy.data(), dy, sizeof(float) * m, hipMemcpyDeviceToHost); +* +* // Destroy matrix descriptors and handles +* hipsparseDestroySpMat(matA); +* hipsparseDestroyDnVec(vecX); +* hipsparseDestroyDnVec(vecY); +* hipsparseDestroy(handle); +* +* hipFree(buffer); +* hipFree(dcsr_row_ptr); +* hipFree(dcsr_col_ind); +* hipFree(dcsr_val); +* hipFree(dx); +* hipFree(dy); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnVecDescr_t vecX, + const void* beta, + const hipsparseDnVecDescr_t vecY, + hipDataType computeType, + hipsparseSpMVAlg_t alg, + void* externalBuffer); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnVecDescr_t vecX, + const void* beta, + const hipsparseDnVecDescr_t vecY, + hipDataType computeType, + hipsparseSpMVAlg_t alg, + void* externalBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spsm.h b/library/include/generic/hipsparse_spsm.h new file mode 100644 index 00000000..94797fe2 --- /dev/null +++ b/library/include/generic/hipsparse_spsm.h @@ -0,0 +1,187 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Create sparse matrix triangular solve with multiple rhs descriptor +* \details +* \p hipsparseSpSM_createDescr creates a sparse matrix triangular solve with multiple rhs descriptor. It should be +* destroyed at the end using hipsparseSpSM_destroyDescr(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_createDescr(hipsparseSpSMDescr_t* descr); +#endif + +/*! \ingroup generic_module +* \brief Description: Destroy sparse matrix triangular solve with multiple rhs descriptor +* \details +* \p hipsparseSpSM_destroyDescr destroys a sparse matrix triangular solve with multiple rhs descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_destroyDescr(hipsparseSpSMDescr_t descr); +#endif + +/*! \ingroup generic_module +* \brief Description: Buffer size step of solution of triangular linear system op(A) * C = alpha * op(B), +* where A is a sparse matrix in CSR storage format, B and C are dense matrices. +* +* \details +* \p hipsparseSpSV_bufferSize computes the required user allocated buffer size needed when computing the +* solution of triangular linear system op(A) * C = alpha * op(B), where A is a sparse matrix in CSR storage +* format, B and C are dense matrices. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnMatDescr_t matB, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpSMAlg_t alg, + hipsparseSpSMDescr_t spsmDescr, + size_t* bufferSize); +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnMatDescr_t matB, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpSMAlg_t alg, + hipsparseSpSMDescr_t spsmDescr, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Analysis step of solution of triangular linear system op(A) * C = alpha * op(B), +* where A is a sparse matrix in CSR storage format, B and C are dense vectors. +* +* \details +* \p hipsparseSpSV_analysis performs the required analysis used when computing the +* solution of triangular linear system op(A) * C = alpha * op(B), +* where A is a sparse matrix in CSR storage format, B and C are dense vectors. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_analysis(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnMatDescr_t matB, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpSMAlg_t alg, + hipsparseSpSMDescr_t spsmDescr, + void* externalBuffer); +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_analysis(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnMatDescr_t matB, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpSMAlg_t alg, + hipsparseSpSMDescr_t spsmDescr, + void* externalBuffer); +#endif + +/*! \ingroup generic_module +* \brief Description: Sparse triangular system solve +* +* \details +* \p hipsparseSpSM_solve solves a sparse triangular linear system of a sparse +* \f$m \times m\f$ matrix, defined in CSR or COO storage format, a dense solution matrix +* \f$C\f$ and the right-hand side \f$B\f$ that is multiplied by \f$\alpha\f$, such that +* \f[ +* op(A) \cdot C = \alpha \cdot op(B), +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* and +* \f[ +* op(B) = \left\{ +* \begin{array}{ll} +* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnMatDescr_t matB, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpSMAlg_t alg, + hipsparseSpSMDescr_t spsmDescr, + void* externalBuffer); +#elif(CUDART_VERSION >= 11031) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, + hipsparseOperation_t opA, + hipsparseOperation_t opB, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnMatDescr_t matB, + const hipsparseDnMatDescr_t matC, + hipDataType computeType, + hipsparseSpSMAlg_t alg, + hipsparseSpSMDescr_t spsmDescr, + void* externalBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spsv.h b/library/include/generic/hipsparse_spsv.h new file mode 100644 index 00000000..5451a86a --- /dev/null +++ b/library/include/generic/hipsparse_spsv.h @@ -0,0 +1,169 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Create sparse matrix triangular solve descriptor +* \details +* \p hipsparseSpGEMM_createDescr creates a sparse matrix triangular solve descriptor. It should be +* destroyed at the end using hipsparseSpSV_destroyDescr(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_createDescr(hipsparseSpSVDescr_t* descr); +#endif + +/*! \ingroup generic_module +* \brief Description: Destroy sparse matrix triangular solve descriptor +* \details +* \p hipsparseSpSV_destroyDescr destroys a sparse matrix triangular solve descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_destroyDescr(hipsparseSpSVDescr_t descr); +#endif + +/*! \ingroup generic_module +* \brief Description: Buffer size step of solution of triangular linear system op(A) * Y = alpha * X, +* where A is a sparse matrix in CSR storage format, x and Y are dense vectors. +* +* \details +* \p hipsparseSpSV_bufferSize computes the required user allocated buffer size needed when computing the +* solution of triangular linear system op(A) * Y = alpha * X, where A is a sparse matrix in CSR storage +* format, x and Y are dense vectors. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnVecDescr_t x, + const hipsparseDnVecDescr_t y, + hipDataType computeType, + hipsparseSpSVAlg_t alg, + hipsparseSpSVDescr_t spsvDescr, + size_t* bufferSize); +#elif(CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnVecDescr_t x, + const hipsparseDnVecDescr_t y, + hipDataType computeType, + hipsparseSpSVAlg_t alg, + hipsparseSpSVDescr_t spsvDescr, + size_t* bufferSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Analysis step of solution of triangular linear system op(A) * Y = alpha * X, +* where A is a sparse matrix in CSR storage format, x and Y are dense vectors. +* +* \details +* \p hipsparseSpSV_analysis performs the required analysis used when computing the +* solution of triangular linear system op(A) * Y = alpha * X, +* where A is a sparse matrix in CSR storage format, x and Y are dense vectors. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_analysis(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnVecDescr_t x, + const hipsparseDnVecDescr_t y, + hipDataType computeType, + hipsparseSpSVAlg_t alg, + hipsparseSpSVDescr_t spsvDescr, + void* externalBuffer); +#elif(CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_analysis(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnVecDescr_t x, + const hipsparseDnVecDescr_t y, + hipDataType computeType, + hipsparseSpSVAlg_t alg, + hipsparseSpSVDescr_t spsvDescr, + void* externalBuffer); +#endif + +/*! \ingroup generic_module +* \brief Description: Sparse triangular solve +* +* \details +* \p hipsparseSpSV_solve solves a sparse triangular linear system of a sparse +* \f$m \times m\f$ matrix, defined in CSR or COO storage format, a dense solution vector +* \f$y\f$ and the right-hand side \f$x\f$ that is multiplied by \f$\alpha\f$, such that +* \f[ +* op(A) \cdot y = \alpha \cdot x, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + hipsparseConstSpMatDescr_t matA, + hipsparseConstDnVecDescr_t x, + const hipsparseDnVecDescr_t y, + hipDataType computeType, + hipsparseSpSVAlg_t alg, + hipsparseSpSVDescr_t spsvDescr); +#elif(CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, + hipsparseOperation_t opA, + const void* alpha, + const hipsparseSpMatDescr_t matA, + const hipsparseDnVecDescr_t x, + const hipsparseDnVecDescr_t y, + hipDataType computeType, + hipsparseSpSVAlg_t alg, + hipsparseSpSVDescr_t spsvDescr); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/generic/hipsparse_spvv.h b/library/include/generic/hipsparse_spvv.h new file mode 100644 index 00000000..1a42974e --- /dev/null +++ b/library/include/generic/hipsparse_spvv.h @@ -0,0 +1,177 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Compute the inner dot product of a sparse vector with a dense vector +* +* \details +* \p hipsparseSpVV_bufferSize computes the required user allocated buffer size needed when computing the +* inner dot product of a sparse vector with a dense vector +* +* See full example below +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVV_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opX, + hipsparseConstSpVecDescr_t vecX, + hipsparseConstDnVecDescr_t vecY, + void* result, + hipDataType computeType, + size_t* bufferSize); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVV_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t opX, + hipsparseSpVecDescr_t vecX, + hipsparseDnVecDescr_t vecY, + void* result, + hipDataType computeType, + size_t* bufferSize); +#endif + + + + +/*! \ingroup generic_module +* \brief Description: Compute the inner dot product of a sparse vector with a dense vector +* +* \details +* \p hipsparseSpVV computes the inner dot product of a sparse vector with a dense vector. This routine takes a user +* allocated buffer whose size must first be computed by calling \p hipsparseSpVV_bufferSize +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Size of sparse and dense vector +* int size = 9; +* +* // Sparse index vector +* std::vector hx_ind = {0, 3, 5}; +* +* // Sparse value vector +* std::vector hx_val = {1.0f, 2.0f, 3.0f}; +* +* // Dense vector +* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * size); +* +* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); +* +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Create sparse vector X +* hipsparseSpVecDescr_t vecX; +* hipsparseCreateSpVec(&vecX, +* size, +* nnz, +* dx_ind, +* dx_val, +* HIPSPARSE_INDEX_32I, +* HIPSPARSE_INDEX_BASE_ZERO, +* HIP_R_32F); +* +* // Create dense vector Y +* hipsparseDnVecDescr_t vecY; +* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); +* +* // Obtain buffer size +* float hresult = 0.0f; +* size_t buffer_size; +* hipsparseSpVV_bufferSize(handle, +* HIPSPARSE_OPERATION_NON_TRANSPOSE, +* vecX, +* vecY, +* &hresult, +* HIP_R_32F, +* &buffer_size); +* +* void* temp_buffer; +* hipMalloc(&temp_buffer, buffer_size); +* +* // SpVV +* hipsparseSpVV(handle, +* HIPSPARSE_OPERATION_NON_TRANSPOSE, +* vecX, +* vecY, +* &hresult, +* HIP_R_32F, +* temp_buffer); +* +* hipDeviceSynchronize(); +* +* std::cout << "hresult: " << hresult << std::endl; +* +* // Clear hipSPARSE +* hipsparseDestroySpVec(vecX); +* hipsparseDestroyDnVec(vecY); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* hipFree(temp_buffer); +* \endcode +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, + hipsparseOperation_t opX, + hipsparseConstSpVecDescr_t vecX, + hipsparseConstDnVecDescr_t vecY, + void* result, + hipDataType computeType, + void* externalBuffer); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, + hipsparseOperation_t opX, + hipsparseSpVecDescr_t vecX, + hipsparseDnVecDescr_t vecY, + void* result, + hipDataType computeType, + void* externalBuffer); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/hipsparse.h b/library/include/hipsparse.h index 3d4e6559..cc998bf9 100644 --- a/library/include/hipsparse.h +++ b/library/include/hipsparse.h @@ -85,959 +85,8 @@ #endif #endif -/// \cond DO_NOT_DOCUMENT -// Forward declarations -struct bsrsv2Info; -struct bsrsm2Info; -struct bsrilu02Info; -struct bsric02Info; -struct csrsv2Info; -struct csrsm2Info; -struct csrilu02Info; -struct csric02Info; -struct csrgemm2Info; -struct pruneInfo; -struct csru2csrInfo; -/// \endcond - -/*! \ingroup types_module - * \brief Handle to the hipSPARSE library context queue. - * - * \details - * The hipSPARSE handle is a structure holding the hipSPARSE library context. It must - * be initialized using hipsparseCreate() and the returned handle must be passed to all - * subsequent library function calls. It should be destroyed at the end using - * hipsparseDestroy(). - */ -typedef void* hipsparseHandle_t; - -/*! \ingroup types_module - * \brief Descriptor of the matrix. - * - * \details - * The hipSPARSE matrix descriptor is a structure holding all properties of a matrix. - * It must be initialized using hipsparseCreateMatDescr() and the returned descriptor - * must be passed to all subsequent library calls that involve the matrix. It should be - * destroyed at the end using hipsparseDestroyMatDescr(). - */ -typedef void* hipsparseMatDescr_t; - -/*! \ingroup types_module - * \brief HYB matrix storage format. - * - * \details - * The hipSPARSE HYB matrix structure holds the HYB matrix. It must be initialized using - * hipsparseCreateHybMat() and the returned HYB matrix must be passed to all subsequent - * library calls that involve the matrix. It should be destroyed at the end using - * hipsparseDestroyHybMat(). - */ -typedef void* hipsparseHybMat_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding coloring info. - * - * \details - * The hipSPARSE ColorInfo structure holds the coloring information. It must be - * initialized using hipsparseCreateColorInfo() and the returned structure must be - * passed to all subsequent library calls that involve the coloring. It should be - * destroyed at the end using hipsparseDestroyColorInfo(). - */ -typedef void* hipsparseColorInfo_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding bsrsv2 info. - * - * \details - * The hipSPARSE bsrsv2 structure holds the information used by hipsparseXbsrsv2_zeroPivot(), - * hipsparseXbsrsv2_bufferSize(), hipsparseXbsrsv2_bufferSizeExt(), hipsparseXbsrsv2_analysis(), - * and hipsparseXbsrsv2_solve(). It must be initialized using hipsparseCreateBsrsv2Info() and - * the returned structure must be passed to all subsequent library calls that involve bsrsv2. - * It should be destroyed at the end using hipsparseDestroyBsrsv2Info(). - */ -typedef struct bsrsv2Info* bsrsv2Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding bsrsm2 info. - * - * \details - * The hipSPARSE bsrsm2 structure holds the information used by hipsparseXbsrsm2_zeroPivot(), hipsparseXbsrsm2_bufferSize(), - * hipsparseXbsrsm2_analysis(), and hipsparseXbsrsm2_solve(). It must be initialized using - * hipsparseCreateBsrsm2Info() and the returned structure must be - * passed to all subsequent library calls that involve bsrsm2. It should be - * destroyed at the end using hipsparseDestroyBsrsm2Info(). - */ -typedef struct bsrsm2Info* bsrsm2Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding bsrilu02 info. - * - * \details - * The hipSPARSE bsrilu02 structure holds the information used by hipsparseXbsrilu02_zeroPivot(), - * hipsparseXbsrilu02_numericBoost(), hipsparseXbsrilu02_bufferSize(), hipsparseXbsrilu02_analysis(), - * and hipsparseXbsrilu02(). It must be initialized using hipsparseCreateBsrilu02Info() and the - * returned structure must be passed to all subsequent library calls that involve bsrilu02. It should be - * destroyed at the end using hipsparseDestroyBsrilu02Info(). - */ -typedef struct bsrilu02Info* bsrilu02Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding bsric02 info. - * - * \details - * The hipSPARSE bsric02 structure holds the information used by hipsparseXbsric02_zeroPivot(), hipsparseXbsric02_bufferSize(), - * hipsparseXbsric02_analysis(), and hipsparseXbsric02(). It must be initialized using - * hipsparseCreateBsric02Info() and the returned structure must be - * passed to all subsequent library calls that involve bsric02. It should be - * destroyed at the end using hipsparseDestroyBsric02Info(). - */ -typedef struct bsric02Info* bsric02Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding csrsv2 info. - * - * \details - * The hipSPARSE csrsv2 structure holds the information used by hipsparseXcsrsv2_zeroPivot(), hipsparseXcsrsv2_bufferSize(), - * hipsparseXcsrsv2_analysis(), and hipsparseXcsrsv2(). It must be initialized using - * hipsparseCreateCsrsv2Info() and the returned structure must be - * passed to all subsequent library calls that involve csrsv2. It should be - * destroyed at the end using hipsparseDestroyCsrsv2Info(). - */ -typedef struct csrsv2Info* csrsv2Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding csrsm2 info. - * - * \details - * The hipSPARSE csrsm2 structure holds the information used by hipsparseXcsrsm2_zeroPivot(), hipsparseXcsrsm2_bufferSize(), - * hipsparseXcsrsm2_analysis(), and hipsparseXcsrsm2(). It must be initialized using - * hipsparseCreateCsrsm2Info() and the returned structure must be - * passed to all subsequent library calls that involve csrsm2. It should be - * destroyed at the end using hipsparseDestroyCsrsm2Info(). - */ -typedef struct csrsm2Info* csrsm2Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding csrilu02 info. - * - * \details - * The hipSPARSE csrilu02 structure holds the information used by hipsparseXcsrilu02_zeroPivot(), - * hipsparseXcsrilu02_numericBoost(), hipsparseXcsrilu02_bufferSize(), hipsparseXcsrilu02_analysis(), - * and hipsparseXcsrilu02(). It must be initialized using hipsparseCreateCsrilu02Info() and the - * returned structure must be passed to all subsequent library calls that involve csrilu02. It should be - * destroyed at the end using hipsparseDestroyCsrilu02Info(). - */ -typedef struct csrilu02Info* csrilu02Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding csric02 info. - * - * \details - * The hipSPARSE csric02 structure holds the information used by hipsparseXcsric02_zeroPivot(), - * hipsparseXcsric02_bufferSize(), hipsparseXcsric02_analysis(), and hipsparseXcsric02(). It must be - * initialized using hipsparseCreateCsric02Info() and the returned structure must be passed to all - * subsequent library calls that involve csric02. It should be destroyed at the end using - * hipsparseDestroyCsric02Info(). - */ -typedef struct csric02Info* csric02Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding csrgemm2 info. - * - * \details - * The hipSPARSE csrgemm2 structure holds the information used by hipsparseXcsrgemm2_bufferSizeExt(), - * hipsparseXcsrgemm2Nnz(), and hipsparseXcsrgemm2(). It must be initialized using - * hipsparseCreateCsrgemm2Info() and the returned structure must be passed to all subsequent - * library calls that involve csrgemm2. It should be destroyed at the end using - * hipsparseDestroyCsrgemm2Info(). - */ -typedef struct csrgemm2Info* csrgemm2Info_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding prune info. - * - * \details - * The hipSPARSE prune structure holds the information used by hipsparseXpruneDense2csrByPercentage_bufferSize(), - * hipsparseXpruneDense2csrByPercentage_bufferSizeExt(), hipsparseXpruneCsr2csrByPercentage_bufferSize(), - * hipsparseXpruneCsr2csrByPercentage_bufferSizeExt(), hipsparseXpruneDense2csrNnzByPercentage(), - * hipsparseXpruneCsr2csrNnzByPercentage(), hipsparseXpruneDense2csrByPercentage(), and - * hipsparseXpruneCsr2csrByPercentage(). It must be initialized using hipsparseCreatePruneInfo() and the - * returned structure must be passed to all subsequent library calls that involve prune. It should be - * destroyed at the end using hipsparseDestroyPruneInfo(). - */ -typedef struct pruneInfo* pruneInfo_t; - -/*! \ingroup types_module - * \brief Pointer type to opaque structure holding csru2csr info. - * - * \details - * The hipSPARSE csru2csr structure holds the information used by hipsparseXcsru2csr_bufferSizeExt(), - * hipsparseXcsru2csr(), and hipsparseXcsr2csru(). It must be initialized using hipsparseCreateCsru2csrInfo() - * and the returned structure must be passed to all subsequent library calls that involve csru2csr. It should be - * destroyed at the end using hipsparseDestroyCsru2csrInfo(). - */ -typedef struct csru2csrInfo* csru2csrInfo_t; - -// clang-format off - -/*! \ingroup types_module - * \brief List of hipsparse status codes definition. - * - * \details - * This is a list of the \ref hipsparseStatus_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION)) -typedef enum { - HIPSPARSE_STATUS_SUCCESS = 0, /**< Function succeeds */ - HIPSPARSE_STATUS_NOT_INITIALIZED = 1, /**< hipSPARSE was not initialized */ - HIPSPARSE_STATUS_ALLOC_FAILED = 2, /**< Resource allocation failed */ - HIPSPARSE_STATUS_INVALID_VALUE = 3, /**< Unsupported value was passed to the function */ - HIPSPARSE_STATUS_ARCH_MISMATCH = 4, /**< Device architecture not supported */ - HIPSPARSE_STATUS_MAPPING_ERROR = 5, /**< Access to GPU memory space failed */ - HIPSPARSE_STATUS_EXECUTION_FAILED = 6, /**< GPU program failed to execute */ - HIPSPARSE_STATUS_INTERNAL_ERROR = 7, /**< An internal hipSPARSE operation failed */ - HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED = 8, /**< Matrix type not supported */ - HIPSPARSE_STATUS_ZERO_PIVOT = 9, /**< Zero pivot was computed */ - HIPSPARSE_STATUS_NOT_SUPPORTED = 10, /**< Operation is not supported */ - HIPSPARSE_STATUS_INSUFFICIENT_RESOURCES = 11 /**< Resources are insufficient */ -} hipsparseStatus_t; -#else -#if(CUDART_VERSION >= 11003) -typedef enum { - HIPSPARSE_STATUS_SUCCESS = 0, /**< Function succeeds */ - HIPSPARSE_STATUS_NOT_INITIALIZED = 1, /**< hipSPARSE was not initialized */ - HIPSPARSE_STATUS_ALLOC_FAILED = 2, /**< Resource allocation failed */ - HIPSPARSE_STATUS_INVALID_VALUE = 3, /**< Unsupported value was passed to the function */ - HIPSPARSE_STATUS_ARCH_MISMATCH = 4, /**< Device architecture not supported */ - HIPSPARSE_STATUS_MAPPING_ERROR = 5, /**< Access to GPU memory space failed */ - HIPSPARSE_STATUS_EXECUTION_FAILED = 6, /**< GPU program failed to execute */ - HIPSPARSE_STATUS_INTERNAL_ERROR = 7, /**< An internal hipSPARSE operation failed */ - HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED = 8, /**< Matrix type not supported */ - HIPSPARSE_STATUS_ZERO_PIVOT = 9, /**< Zero pivot was computed */ - HIPSPARSE_STATUS_NOT_SUPPORTED = 10, /**< Operation is not supported */ - HIPSPARSE_STATUS_INSUFFICIENT_RESOURCES = 11 /**< Resources are insufficient */ -} hipsparseStatus_t; -#elif(CUDART_VERSION >= 10010) -typedef enum { - HIPSPARSE_STATUS_SUCCESS = 0, /**< Function succeeds */ - HIPSPARSE_STATUS_NOT_INITIALIZED = 1, /**< hipSPARSE was not initialized */ - HIPSPARSE_STATUS_ALLOC_FAILED = 2, /**< Resource allocation failed */ - HIPSPARSE_STATUS_INVALID_VALUE = 3, /**< Unsupported value was passed to the function */ - HIPSPARSE_STATUS_ARCH_MISMATCH = 4, /**< Device architecture not supported */ - HIPSPARSE_STATUS_MAPPING_ERROR = 5, /**< Access to GPU memory space failed */ - HIPSPARSE_STATUS_EXECUTION_FAILED = 6, /**< GPU program failed to execute */ - HIPSPARSE_STATUS_INTERNAL_ERROR = 7, /**< An internal hipSPARSE operation failed */ - HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED = 8, /**< Matrix type not supported */ - HIPSPARSE_STATUS_ZERO_PIVOT = 9, /**< Zero pivot was computed */ - HIPSPARSE_STATUS_NOT_SUPPORTED = 10 /**< Operation is not supported */ -} hipsparseStatus_t; -#endif -#endif - -/*! \ingroup types_module - * \brief Indicates if the pointer is device pointer or host pointer. - * - * \details - * The \ref hipsparsePointerMode_t indicates whether scalar values are passed by - * reference on the host or device. The \ref hipsparsePointerMode_t can be changed by - * hipsparseSetPointerMode(). The currently used pointer mode can be obtained by - * hipsparseGetPointerMode(). - */ -typedef enum { - HIPSPARSE_POINTER_MODE_HOST = 0, /**< Scalar pointers are in host memory */ - HIPSPARSE_POINTER_MODE_DEVICE = 1 /**< Scalar pointers are in device memory */ -} hipsparsePointerMode_t; - -/*! \ingroup types_module - * \brief Specify where the operation is performed on. - * - * \details - * The \ref hipsparseAction_t indicates whether the operation is performed on the full - * matrix, or only on the sparsity pattern of the matrix. - */ -typedef enum { - HIPSPARSE_ACTION_SYMBOLIC = 0, /**< Operate only on indices */ - HIPSPARSE_ACTION_NUMERIC = 1 /**< Operate on data and indices */ -} hipsparseAction_t; - -/*! \ingroup types_module - * \brief Specify the matrix type. - * - * \details - * The \ref hipsparseMatrixType_t indices the type of a matrix. For a given - * \ref hipsparseMatDescr_t, the \ref hipsparseMatrixType_t can be set using - * hipsparseSetMatType(). The current \ref hipsparseMatrixType_t of a matrix can be - * obtained by hipsparseGetMatType(). - */ -typedef enum { - HIPSPARSE_MATRIX_TYPE_GENERAL = 0, /**< General matrix type */ - HIPSPARSE_MATRIX_TYPE_SYMMETRIC = 1, /**< Symmetric matrix type */ - HIPSPARSE_MATRIX_TYPE_HERMITIAN = 2, /**< Hermitian matrix type */ - HIPSPARSE_MATRIX_TYPE_TRIANGULAR = 3 /**< Triangular matrix type */ -} hipsparseMatrixType_t; - -/*! \ingroup types_module - * \brief Specify the matrix fill mode. - * - * \details - * The \ref hipsparseFillMode_t indicates whether the lower or the upper part is stored - * in a sparse triangular matrix. For a given \ref hipsparseMatDescr_t, the - * \ref hipsparseFillMode_t can be set using hipsparseSetMatFillMode(). The current - * \ref hipsparseFillMode_t of a matrix can be obtained by hipsparseGetMatFillMode(). - */ -typedef enum { - HIPSPARSE_FILL_MODE_LOWER = 0, /**< Lower triangular part is stored */ - HIPSPARSE_FILL_MODE_UPPER = 1 /**< Upper triangular part is stored */ -} hipsparseFillMode_t; - -/*! \ingroup types_module - * \brief Indicates if the diagonal entries are unity. - * - * \details - * The \ref hipsparseDiagType_t indicates whether the diagonal entries of a matrix are - * unity or not. If \ref HIPSPARSE_DIAG_TYPE_UNIT is specified, all present diagonal - * values will be ignored. For a given \ref hipsparseMatDescr_t, the - * \ref hipsparseDiagType_t can be set using hipsparseSetMatDiagType(). The current - * \ref hipsparseDiagType_t of a matrix can be obtained by hipsparseGetMatDiagType(). - */ -typedef enum { - HIPSPARSE_DIAG_TYPE_NON_UNIT = 0, /**< Diagonal entries are non-unity */ - HIPSPARSE_DIAG_TYPE_UNIT = 1 /**< Diagonal entries are unity */ -} hipsparseDiagType_t; - -/*! \ingroup types_module - * \brief Specify the matrix index base. - * - * \details - * The \ref hipsparseIndexBase_t indicates the index base of the indices. For a - * given \ref hipsparseMatDescr_t, the \ref hipsparseIndexBase_t can be set using - * hipsparseSetMatIndexBase(). The current \ref hipsparseIndexBase_t of a matrix - * can be obtained by hipsparseGetMatIndexBase(). - */ -typedef enum { - HIPSPARSE_INDEX_BASE_ZERO = 0, /**< Zero based indexing */ - HIPSPARSE_INDEX_BASE_ONE = 1 /**< One based indexing */ -} hipsparseIndexBase_t; - -/*! \ingroup types_module - * \brief Specify whether the matrix is to be transposed or not. - * - * \details - * The \ref hipsparseOperation_t indicates the operation performed with the given matrix. - */ -typedef enum { - HIPSPARSE_OPERATION_NON_TRANSPOSE = 0, /**< Operate with matrix */ - HIPSPARSE_OPERATION_TRANSPOSE = 1, /**< Operate with transpose */ - HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE = 2 /**< Operate with conj. transpose */ -} hipsparseOperation_t; - -/*! \ingroup types_module - * \brief HYB matrix partitioning type. - * - * \details - * The \ref hipsparseHybPartition_t type indicates how the hybrid format partitioning - * between COO and ELL storage formats is performed. - */ -typedef enum { - HIPSPARSE_HYB_PARTITION_AUTO = 0, /**< Automatically decide on ELL nnz per row */ - HIPSPARSE_HYB_PARTITION_USER = 1, /**< User given ELL nnz per row */ - HIPSPARSE_HYB_PARTITION_MAX = 2 /**< Max ELL nnz per row, no COO part */ -} hipsparseHybPartition_t; - -/*! \ingroup types_module - * \brief Specify policy in triangular solvers and factorizations. - * - * \details - * The \ref hipsparseSolvePolicy_t type indicates the solve policy for the triangular - * solve. - */ -typedef enum { - HIPSPARSE_SOLVE_POLICY_NO_LEVEL = 0, /**< No level information generated */ - HIPSPARSE_SOLVE_POLICY_USE_LEVEL = 1 /**< Generate level information */ -} hipsparseSolvePolicy_t; - -/// \cond DO_NOT_DOCUMENT -// Note: Add back to types.rst if we get documentation for this in the future -typedef enum { - HIPSPARSE_SIDE_LEFT = 0, - HIPSPARSE_SIDE_RIGHT = 1 -} hipsparseSideMode_t; -/// \endcond - -/*! \ingroup types_module - * \brief Specify the matrix direction. - * - * \details - * The \ref hipsparseDirection_t indicates whether a dense matrix should be parsed by - * rows or by columns, assuming column-major storage. - */ -typedef enum { - HIPSPARSE_DIRECTION_ROW = 0, /**< Parse the matrix by rows */ - HIPSPARSE_DIRECTION_COLUMN = 1 /**< Parse the matrix by columns */ -} hipsparseDirection_t; - -// clang-format on - -#ifdef __cplusplus -extern "C" { -#endif - -/*! \ingroup aux_module - * \brief Create a hipsparse handle - * - * \details - * \p hipsparseCreate creates the hipSPARSE library context. It must be - * initialized before any other hipSPARSE API function is invoked and must be passed to - * all subsequent library function calls. The handle should be destroyed at the end - * using hipsparseDestroy(). - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreate(hipsparseHandle_t* handle); - -/*! \ingroup aux_module - * \brief Destroy a hipsparse handle - * - * \details - * \p hipsparseDestroy destroys the hipSPARSE library context and releases all - * resources used by the hipSPARSE library. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroy(hipsparseHandle_t handle); - -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10000) -/*! \ingroup aux_module - * \brief Return the string representation of a hipSPARSE status's matching backend status enum name - * - * \details - * \p hipsparseGetErrorName takes a hipSPARSE status as input and first converts it to the matching backend - * status (either rocsparse_status or cusparseStatus_t). It then returns the string representation of this status - * enum name. If the status is not recognized, the function returns "Unrecognized status code". - * - * For example, hipsparseGetErrorName(HIPSPARSE_STATUS_SUCCESS) on a system with a rocSPARSE backend will - * return "rocsparse_status_success". On a system with a cuSPARSE backend this function would return - * "CUSPARSE_STATUS_SUCCESS". - */ -HIPSPARSE_EXPORT -const char* hipsparseGetErrorName(hipsparseStatus_t status); - -/*! \ingroup aux_module - * \brief Return the hipSPARSE status's matching backend status description as a string - * - * \details - * \p hipsparseGetErrorString takes a hipSPARSE status as input and first converts it to the matching backend - * status (either rocsparse_status or cusparseStatus_t). It then returns the string description of this status. - * If the status is not recognized, the function returns "Unrecognized status code". - */ -HIPSPARSE_EXPORT -const char* hipsparseGetErrorString(hipsparseStatus_t status); -#endif - -/*! \ingroup aux_module - * \brief Get hipSPARSE version - * - * \details - * \p hipsparseGetVersion gets the hipSPARSE library version number. - * - patch = version % 100 - * - minor = version / 100 % 1000 - * - major = version / 100000 - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseGetVersion(hipsparseHandle_t handle, int* version); - -/*! \ingroup aux_module - * \brief Get hipSPARSE git revision - * - * \details - * \p hipsparseGetGitRevision gets the hipSPARSE library git commit revision (SHA-1). - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseGetGitRevision(hipsparseHandle_t handle, char* rev); - -/*! \ingroup aux_module - * \brief Specify user defined HIP stream - * - * \details - * \p hipsparseSetStream specifies the stream to be used by the hipSPARSE library - * context and all subsequent function calls. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSetStream(hipsparseHandle_t handle, hipStream_t streamId); - -/*! \ingroup aux_module - * \brief Get current stream from library context - * - * \details - * \p hipsparseGetStream gets the hipSPARSE library context stream which is currently - * used for all subsequent function calls. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseGetStream(hipsparseHandle_t handle, hipStream_t* streamId); - -/*! \ingroup aux_module - * \brief Specify pointer mode - * - * \details - * \p hipsparseSetPointerMode specifies the pointer mode to be used by the hipSPARSE - * library context and all subsequent function calls. By default, all values are passed - * by reference on the host. Valid pointer modes are \ref HIPSPARSE_POINTER_MODE_HOST - * or \ref HIPSPARSE_POINTER_MODE_DEVICE. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSetPointerMode(hipsparseHandle_t handle, hipsparsePointerMode_t mode); - -/*! \ingroup aux_module - * \brief Get current pointer mode from library context - * - * \details - * \p hipsparseGetPointerMode gets the hipSPARSE library context pointer mode which - * is currently used for all subsequent function calls. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseGetPointerMode(hipsparseHandle_t handle, hipsparsePointerMode_t* mode); - -/*! \ingroup aux_module - * \brief Create a matrix descriptor - * \details - * \p hipsparseCreateMatDescr creates a matrix descriptor. It initializes - * \ref hipsparseMatrixType_t to \ref HIPSPARSE_MATRIX_TYPE_GENERAL and - * \ref hipsparseIndexBase_t to \ref HIPSPARSE_INDEX_BASE_ZERO. It should be destroyed - * at the end using hipsparseDestroyMatDescr(). - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateMatDescr(hipsparseMatDescr_t* descrA); - -/*! \ingroup aux_module - * \brief Destroy a matrix descriptor - * - * \details - * \p hipsparseDestroyMatDescr destroys a matrix descriptor and releases all - * resources used by the descriptor. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyMatDescr(hipsparseMatDescr_t descrA); - -/*! \ingroup aux_module - * \brief Copy a matrix descriptor - * \details - * \p hipsparseCopyMatDescr copies a matrix descriptor. Both, source and destination - * matrix descriptors must be initialized prior to calling \p hipsparseCopyMatDescr. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCopyMatDescr(hipsparseMatDescr_t dest, const hipsparseMatDescr_t src); - -/*! \ingroup aux_module - * \brief Specify the matrix type of a matrix descriptor - * - * \details - * \p hipsparseSetMatType sets the matrix type of a matrix descriptor. Valid - * matrix types are \ref HIPSPARSE_MATRIX_TYPE_GENERAL, - * \ref HIPSPARSE_MATRIX_TYPE_SYMMETRIC, \ref HIPSPARSE_MATRIX_TYPE_HERMITIAN or - * \ref HIPSPARSE_MATRIX_TYPE_TRIANGULAR. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSetMatType(hipsparseMatDescr_t descrA, hipsparseMatrixType_t type); - -/*! \ingroup aux_module - * \brief Get the matrix type of a matrix descriptor - * - * \details - * \p hipsparseGetMatType returns the matrix type of a matrix descriptor. - */ -HIPSPARSE_EXPORT -hipsparseMatrixType_t hipsparseGetMatType(const hipsparseMatDescr_t descrA); - -/*! \ingroup aux_module - * \brief Specify the matrix fill mode of a matrix descriptor - * - * \details - * \p hipsparseSetMatFillMode sets the matrix fill mode of a matrix descriptor. - * Valid fill modes are \ref HIPSPARSE_FILL_MODE_LOWER or - * \ref HIPSPARSE_FILL_MODE_UPPER. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSetMatFillMode(hipsparseMatDescr_t descrA, hipsparseFillMode_t fillMode); - -/*! \ingroup aux_module - * \brief Get the matrix fill mode of a matrix descriptor - * - * \details - * \p hipsparseGetMatFillMode returns the matrix fill mode of a matrix descriptor. - */ -HIPSPARSE_EXPORT -hipsparseFillMode_t hipsparseGetMatFillMode(const hipsparseMatDescr_t descrA); - -/*! \ingroup aux_module - * \brief Specify the matrix diagonal type of a matrix descriptor - * - * \details - * \p hipsparseSetMatDiagType sets the matrix diagonal type of a matrix - * descriptor. Valid diagonal types are \ref HIPSPARSE_DIAG_TYPE_UNIT or - * \ref HIPSPARSE_DIAG_TYPE_NON_UNIT. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSetMatDiagType(hipsparseMatDescr_t descrA, hipsparseDiagType_t diagType); - -/*! \ingroup aux_module - * \brief Get the matrix diagonal type of a matrix descriptor - * - * \details - * \p hipsparseGetMatDiagType returns the matrix diagonal type of a matrix - * descriptor. - */ -HIPSPARSE_EXPORT -hipsparseDiagType_t hipsparseGetMatDiagType(const hipsparseMatDescr_t descrA); - -/*! \ingroup aux_module - * \brief Specify the index base of a matrix descriptor - * - * \details - * \p hipsparseSetMatIndexBase sets the index base of a matrix descriptor. Valid - * options are \ref HIPSPARSE_INDEX_BASE_ZERO or \ref HIPSPARSE_INDEX_BASE_ONE. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSetMatIndexBase(hipsparseMatDescr_t descrA, hipsparseIndexBase_t base); - -/*! \ingroup aux_module - * \brief Get the index base of a matrix descriptor - * - * \details - * \p hipsparseGetMatIndexBase returns the index base of a matrix descriptor. - */ -HIPSPARSE_EXPORT -hipsparseIndexBase_t hipsparseGetMatIndexBase(const hipsparseMatDescr_t descrA); - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup aux_module - * \brief Create a \p HYB matrix structure - * - * \details - * \p hipsparseCreateHybMat creates a structure that holds the matrix in \p HYB - * storage format. It should be destroyed at the end using hipsparseDestroyHybMat(). - */ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateHybMat(hipsparseHybMat_t* hybA); - -/*! \ingroup aux_module - * \brief Destroy a \p HYB matrix structure - * - * \details - * \p hipsparseDestroyHybMat destroys a \p HYB structure. - */ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyHybMat(hipsparseHybMat_t hybA); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a bsrsv2 info structure - * - * \details - * \p hipsparseCreateBsrsv2Info creates a structure that holds the bsrsv2 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyBsrsv2Info(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateBsrsv2Info(bsrsv2Info_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a bsrsv2 info structure - * - * \details - * \p hipsparseDestroyBsrsv2Info destroys a bsrsv2 info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyBsrsv2Info(bsrsv2Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a bsrsm2 info structure - * - * \details - * \p hipsparseCreateBsrsm2Info creates a structure that holds the bsrsm2 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyBsrsm2Info(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateBsrsm2Info(bsrsm2Info_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a bsrsm2 info structure - * - * \details - * \p hipsparseDestroyBsrsm2Info destroys a bsrsm2 info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyBsrsm2Info(bsrsm2Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a bsrilu02 info structure - * - * \details - * \p hipsparseCreateBsrilu02Info creates a structure that holds the bsrilu02 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyBsrilu02Info(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateBsrilu02Info(bsrilu02Info_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a bsrilu02 info structure - * - * \details - * \p hipsparseDestroyBsrilu02Info destroys a bsrilu02 info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyBsrilu02Info(bsrilu02Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a bsric02 info structure - * - * \details - * \p hipsparseCreateBsric02Info creates a structure that holds the bsric02 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyBsric02Info(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateBsric02Info(bsric02Info_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a bsric02 info structure - * - * \details - * \p hipsparseDestroyBsric02Info destroys a bsric02 info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyBsric02Info(bsric02Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a csrsv2 info structure - * - * \details - * \p hipsparseCreateCsrsv2Info creates a structure that holds the csrsv2 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyCsrsv2Info(). - */ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsrsv2Info(csrsv2Info_t* info); - -/*! \ingroup aux_module - * \brief Destroy a csrsv2 info structure - * - * \details - * \p hipsparseDestroyCsrsv2Info destroys a csrsv2 info structure. - */ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyCsrsv2Info(csrsv2Info_t info); - -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a csrsm2 info structure - * - * \details - * \p hipsparseCreateCsrsm2Info creates a structure that holds the csrsm2 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyCsrsm2Info(). - */ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsrsm2Info(csrsm2Info_t* info); - -/*! \ingroup aux_module - * \brief Destroy a csrsm2 info structure - * - * \details - * \p hipsparseDestroyCsrsm2Info destroys a csrsm2 info structure. - */ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyCsrsm2Info(csrsm2Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a csrilu02 info structure - * - * \details - * \p hipsparseCreateCsrilu02Info creates a structure that holds the csrilu02 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyCsrilu02Info(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsrilu02Info(csrilu02Info_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a csrilu02 info structure - * - * \details - * \p hipsparseDestroyCsrilu02Info destroys a csrilu02 info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyCsrilu02Info(csrilu02Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a csric02 info structure - * - * \details - * \p hipsparseCreateCsric02Info creates a structure that holds the csric02 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyCsric02Info(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsric02Info(csric02Info_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a csric02 info structure - * - * \details - * \p hipsparseDestroyCsric02Info destroys a csric02 info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyCsric02Info(csric02Info_t info); -#endif - -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a csru2csr info structure - * - * \details - * \p hipsparseCreateCsru2csrInfo creates a structure that holds the csru2csr info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyCsru2csrInfo(). - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsru2csrInfo(csru2csrInfo_t* info); - -/*! \ingroup aux_module - * \brief Destroy a csru2csr info structure - * - * \details - * \p hipsparseDestroyCsru2csrInfo destroys a csru2csr info structure. - */ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyCsru2csrInfo(csru2csrInfo_t info); - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a color info structure - * - * \details - * \p hipsparseCreateColorInfo creates a structure that holds the color info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyColorInfo(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateColorInfo(hipsparseColorInfo_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a color info structure - * - * \details - * \p hipsparseDestroyColorInfo destroys a color info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyColorInfo(hipsparseColorInfo_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a csrgemm2 info structure - * - * \details - * \p hipsparseCreateCsrgemm2Info creates a structure that holds the csrgemm2 info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyCsrgemm2Info(). - */ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsrgemm2Info(csrgemm2Info_t* info); - -/*! \ingroup aux_module - * \brief Destroy a csrgemm2 info structure - * - * \details - * \p hipsparseDestroyCsrgemm2Info destroys a csrgemm2 info structure. - */ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyCsrgemm2Info(csrgemm2Info_t info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/* Info structures */ -/*! \ingroup aux_module - * \brief Create a prune info structure - * - * \details - * \p hipsparseCreatePruneInfo creates a structure that holds the prune info data - * that is gathered during the analysis routines available. It should be destroyed - * at the end using hipsparseDestroyPruneInfo(). - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreatePruneInfo(pruneInfo_t* info); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup aux_module - * \brief Destroy a prune info structure - * - * \details - * \p hipsparseDestroyPruneInfo destroys a prune info structure. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyPruneInfo(pruneInfo_t info); -#endif +#include "hipsparse_types.h" +#include "hipsparse_auxiliary.h" /* * =========================================================================== @@ -1045,13114 +94,126 @@ hipsparseStatus_t hipsparseDestroyPruneInfo(pruneInfo_t info); * =========================================================================== */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level1_module -* \brief Scale a sparse vector and add it to a dense vector. -* -* \details -* \p hipsparseXaxpyi multiplies the sparse vector \f$x\f$ with scalar \f$\alpha\f$ and -* adds the result to the dense vector \f$y\f$, such that -* -* \f[ -* y := y + \alpha \cdot x -* \f] -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* y[x_ind[i]] = y[x_ind[i]] + alpha * x_val[i]; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Sparse index vector -* int hx_ind[3] = {0, 3, 5}; -* -* // Sparse value vector -* double hx_val[3] = {1.0, 2.0, 3.0}; -* -* // Dense vector -* double hy[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; -* -* // Scalar alpha -* double alpha = 3.7; -* -* // Index base -* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; -* -* // Offload data to device -* int* dx_ind; -* double* dx_val; -* double* dy; -* -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(double) * nnz); -* hipMalloc((void**)&dy, sizeof(double) * 9); -* -* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val, sizeof(double) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(double) * 9, hipMemcpyHostToDevice); -* -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Call daxpyi to perform y = y + alpha * x -* hipsparseDaxpyi(handle, nnz, &alpha, dx_val, dx_ind, dy, idx_base); -* -* // Copy result back to host -* hipMemcpy(hy, dy, sizeof(double) * 9, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSaxpyi(hipsparseHandle_t handle, - int nnz, - const float* alpha, - const float* xVal, - const int* xInd, - float* y, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDaxpyi(hipsparseHandle_t handle, - int nnz, - const double* alpha, - const double* xVal, - const int* xInd, - double* y, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCaxpyi(hipsparseHandle_t handle, - int nnz, - const hipComplex* alpha, - const hipComplex* xVal, - const int* xInd, - hipComplex* y, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZaxpyi(hipsparseHandle_t handle, - int nnz, - const hipDoubleComplex* alpha, - const hipDoubleComplex* xVal, - const int* xInd, - hipDoubleComplex* y, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "level1/hipsparse_axpyi.h" +#include "level1/hipsparse_doti.h" +#include "level1/hipsparse_dotci.h" +#include "level1/hipsparse_gthr.h" +#include "level1/hipsparse_gthrz.h" +#include "level1/hipsparse_roti.h" +#include "level1/hipsparse_sctr.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup level1_module -* \brief Compute the dot product of a sparse vector with a dense vector. -* -* \details -* \p hipsparseXdoti computes the dot product of the sparse vector \f$x\f$ with the -* dense vector \f$y\f$, such that -* \f[ -* \text{result} := y^T x -* \f] -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* result += x_val[i] * y[x_ind[i]]; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Sparse index vector -* int hx_ind[3] = {0, 3, 5}; -* -* // Sparse value vector -* float hx_val[3] = {1.0f, 2.0f, 3.0f}; -* -* // Dense vector -* float hy[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // Index base -* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * 9); -* -* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val, sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); -* -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Call sdoti to compute the dot product -* float dot; -* hipsparseSdoti(handle, nnz, dx_val, dx_ind, dy, &dot, idx_base); -* -* // Clear hipSPARSE -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode +/* +* =========================================================================== +* level 2 SPARSE +* =========================================================================== */ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSdoti(hipsparseHandle_t handle, - int nnz, - const float* xVal, - const int* xInd, - const float* y, - float* result, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDdoti(hipsparseHandle_t handle, - int nnz, - const double* xVal, - const int* xInd, - const double* y, - double* result, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCdoti(hipsparseHandle_t handle, - int nnz, - const hipComplex* xVal, - const int* xInd, - const hipComplex* y, - hipComplex* result, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZdoti(hipsparseHandle_t handle, - int nnz, - const hipDoubleComplex* xVal, - const int* xInd, - const hipDoubleComplex* y, - hipDoubleComplex* result, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "level2/hipsparse_csrmv.h" +#include "level2/hipsparse_csrsv.h" +#include "level2/hipsparse_hybmv.h" +#include "level2/hipsparse_bsrmv.h" +#include "level2/hipsparse_bsrxmv.h" +#include "level2/hipsparse_bsrsv.h" +#include "level2/hipsparse_gemvi.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup level1_module -* \brief Compute the dot product of a complex conjugate sparse vector with a dense -* vector. -* -* \details -* \p hipsparseXdotci computes the dot product of the complex conjugate sparse vector -* \f$x\f$ with the dense vector \f$y\f$, such that -* \f[ -* \text{result} := \bar{x}^H y -* \f] -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* result += conj(x_val[i]) * y[x_ind[i]]; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. +/* +* =========================================================================== +* level 3 SPARSE +* =========================================================================== */ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCdotci(hipsparseHandle_t handle, - int nnz, - const hipComplex* xVal, - const int* xInd, - const hipComplex* y, - hipComplex* result, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZdotci(hipsparseHandle_t handle, - int nnz, - const hipDoubleComplex* xVal, - const int* xInd, - const hipDoubleComplex* y, - hipDoubleComplex* result, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "level3/hipsparse_bsrmm.h" +#include "level3/hipsparse_csrmm.h" +#include "level3/hipsparse_bsrsm.h" +#include "level3/hipsparse_csrsm.h" +#include "level3/hipsparse_gemmi.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level1_module -* \brief Gather elements from a dense vector and store them into a sparse vector. -* -* \details -* \p hipsparseXgthr gathers the elements that are listed in \p x_ind from the dense -* vector \f$y\f$ and stores them in the sparse vector \f$x\f$. -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* x_val[i] = y[x_ind[i]]; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Sparse index vector -* int hx_ind[3] = {0, 3, 5}; -* -* // Sparse value vector -* float hx_val[3]; -* -* // Dense vector -* float hy[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; -* -* // Index base -* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * 9); -* -* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); -* -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Call sgthr -* hipsparseSgthr(handle, nnz, dy, dx_val, dx_ind, idx_base); -* -* // Copy result back to host -* hipMemcpy(hx_val, dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode +/* +* =========================================================================== +* extra SPARSE +* =========================================================================== */ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgthr(hipsparseHandle_t handle, - int nnz, - const float* y, - float* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgthr(hipsparseHandle_t handle, - int nnz, - const double* y, - double* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgthr(hipsparseHandle_t handle, - int nnz, - const hipComplex* y, - hipComplex* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgthr(hipsparseHandle_t handle, - int nnz, - const hipDoubleComplex* y, - hipDoubleComplex* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "extra/hipsparse_csrgeam.h" +#include "extra/hipsparse_csrgemm.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level1_module -* \brief Gather and zero out elements from a dense vector and store them into a sparse -* vector. -* -* \details -* \p hipsparseXgthrz gathers the elements that are listed in \p x_ind from the dense -* vector \f$y\f$ and stores them in the sparse vector \f$x\f$. The gathered elements -* in \f$y\f$ are replaced by zero. -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* x_val[i] = y[x_ind[i]]; -* y[x_ind[i]] = 0; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. +/* +* =========================================================================== +* preconditioner SPARSE +* =========================================================================== */ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgthrz(hipsparseHandle_t handle, - int nnz, - float* y, - float* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgthrz(hipsparseHandle_t handle, - int nnz, - double* y, - double* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgthrz(hipsparseHandle_t handle, - int nnz, - hipComplex* y, - hipComplex* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgthrz(hipsparseHandle_t handle, - int nnz, - hipDoubleComplex* y, - hipDoubleComplex* xVal, - const int* xInd, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "precond/hipsparse_bsrilu0.h" +#include "precond/hipsparse_csrilu0.h" +#include "precond/hipsparse_bsric0.h" +#include "precond/hipsparse_csric0.h" +#include "precond/hipsparse_gtsv.h" +#include "precond/hipsparse_gtsv_nopivot.h" +#include "precond/hipsparse_gtsv_strided_batch.h" +#include "precond/hipsparse_gtsv_interleaved_batch.h" +#include "precond/hipsparse_gpsv_interleaved_batch.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level1_module -* \brief Apply Givens rotation to a dense and a sparse vector. -* -* \details -* \p hipsparseXroti applies the Givens rotation matrix \f$G\f$ to the sparse vector -* \f$x\f$ and the dense vector \f$y\f$, where -* \f[ -* G = \begin{pmatrix} c & s \\ -s & c \end{pmatrix} -* \f] -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* x_tmp = x_val[i]; -* y_tmp = y[x_ind[i]]; -* -* x_val[i] = c * x_tmp + s * y_tmp; -* y[x_ind[i]] = c * y_tmp - s * x_tmp; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Sparse index vector -* int hx_ind[3] = {0, 3, 5}; -* -* // Sparse value vector -* float hx_val[3] = {1.0f, 2.0f, 3.0f}; -* -* // Dense vector -* float hy[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // c and s -* float c = 3.7; -* float s = 1.3; -* -* // Index base -* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * 9); -* -* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val, sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); -* -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Call sroti -* hipsparseSroti(handle, nnz, dx_val, dx_ind, dy, &c, &s, idx_base); -* -* // Copy result back to host -* hipMemcpy(hx_val, dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); -* hipMemcpy(hy, dy, sizeof(float) * 9, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode +/* +* =========================================================================== +* Sparse Format Conversions +* =========================================================================== */ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSroti(hipsparseHandle_t handle, - int nnz, - float* xVal, - const int* xInd, - float* y, - const float* c, - const float* s, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDroti(hipsparseHandle_t handle, - int nnz, - double* xVal, - const int* xInd, - double* y, - const double* c, - const double* s, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "conversion/hipsparse_nnz.h" +#include "conversion/hipsparse_dense2csr.h" +#include "conversion/hipsparse_prune_dense2csr.h" +#include "conversion/hipsparse_prune_dense2csr_by_percentage.h" +#include "conversion/hipsparse_dense2csc.h" +#include "conversion/hipsparse_csr2dense.h" +#include "conversion/hipsparse_csc2dense.h" +#include "conversion/hipsparse_nnz_compress.h" +#include "conversion/hipsparse_csr2coo.h" +#include "conversion/hipsparse_csr2csc.h" +#include "conversion/hipsparse_csr2hyb.h" +#include "conversion/hipsparse_gebsr2gebsc.h" +#include "conversion/hipsparse_csr2gebsr.h" +#include "conversion/hipsparse_csr2bsr.h" +#include "conversion/hipsparse_bsr2csr.h" +#include "conversion/hipsparse_gebsr2csr.h" +#include "conversion/hipsparse_csr2csr_compress.h" +#include "conversion/hipsparse_prune_csr2csr.h" +#include "conversion/hipsparse_prune_csr2csr_by_percentage.h" +#include "conversion/hipsparse_hyb2csr.h" +#include "conversion/hipsparse_coo2csr.h" +#include "conversion/hipsparse_create_identity_permutation.h" +#include "conversion/hipsparse_csrsort.h" +#include "conversion/hipsparse_cscsort.h" +#include "conversion/hipsparse_coosort.h" +#include "conversion/hipsparse_gebsr2gebsr.h" +#include "conversion/hipsparse_csru2csr.h" +#include "conversion/hipsparse_csr2csru.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level1_module -* \brief Scatter elements from a dense vector across a sparse vector. -* -* \details -* \p hipsparseXsctr scatters the elements that are listed in \p x_ind from the sparse -* vector \f$x\f$ into the dense vector \f$y\f$. Indices of \f$y\f$ that are not listed -* in \p x_ind remain unchanged. -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* y[x_ind[i]] = x_val[i]; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Sparse index vector -* int hx_ind[3] = {0, 3, 5}; -* -* // Sparse value vector -* float hx_val[3] = {9.0, 2.0, 3.0}; -* -* // Dense vector -* float hy[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; -* -* // Index base -* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * 9); -* -* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val, sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); -* -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Call ssctr -* hipsparseSsctr(handle, nnz, dx_val, dx_ind, dy, idx_base); -* -* // Copy result back to host -* hipMemcpy(hy, dy, sizeof(float) * 9, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode +/* +* =========================================================================== +* reordering SPARSE +* =========================================================================== */ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSsctr(hipsparseHandle_t handle, - int nnz, - const float* xVal, - const int* xInd, - float* y, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDsctr(hipsparseHandle_t handle, - int nnz, - const double* xVal, - const int* xInd, - double* y, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCsctr(hipsparseHandle_t handle, - int nnz, - const hipComplex* xVal, - const int* xInd, - hipComplex* y, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZsctr(hipsparseHandle_t handle, - int nnz, - const hipDoubleComplex* xVal, - const int* xInd, - hipDoubleComplex* y, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif +#include "reorder/hipsparse_csrcolor.h" /* * =========================================================================== -* level 2 SPARSE +* generic SPARSE * =========================================================================== */ +#include "hipsparse_generic_types.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup level2_module -* \brief Sparse matrix vector multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrmv multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times n\f$ -* matrix, defined in CSR storage format, and the dense vector \f$x\f$ and adds the -* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, -* such that -* \f[ -* y := \alpha \cdot op(A) \cdot x + \beta \cdot y, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \code{.c} -* for(i = 0; i < m; ++i) -* { -* y[i] = beta * y[i]; -* -* for(j = csr_row_ptr[i]; j < csr_row_ptr[i + 1]; ++j) -* { -* y[i] = y[i] + alpha * csr_val[j] * x[csr_col_ind[j]]; -* } -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // alpha * ( 1.0 0.0 2.0 ) * ( 1.0 ) + beta * ( 4.0 ) = ( 31.1 ) -* // ( 3.0 0.0 4.0 ) * ( 2.0 ) ( 5.0 ) = ( 62.0 ) -* // ( 5.0 6.0 0.0 ) * ( 3.0 ) ( 6.0 ) = ( 70.7 ) -* // ( 7.0 0.0 8.0 ) * ( 7.0 ) = ( 123.8 ) -* -* int m = 4; -* int n = 3; -* int nnz = 8; -* -* // CSR row pointers -* int hcsr_row_ptr[5] = {0, 2, 4, 6, 8}; -* -* // CSR column indices -* int hcsr_col_ind[8] = {0, 2, 0, 2, 0, 1, 0, 2}; -* -* // CSR values -* double hcsr_val[8] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; -* -* // Transposition of the matrix -* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* -* // Scalar alpha and beta -* double alpha = 3.7; -* double beta = 1.3; -* -* // x and y -* double hx[3] = {1.0, 2.0, 3.0}; -* double hy[4] = {4.0, 5.0, 6.0, 7.0}; -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Offload data to device -* int* dcsr_row_ptr; -* int* dcsr_col_ind; -* double* dcsr_val; -* double* dx; -* double* dy; -* -* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dcsr_val, sizeof(double) * nnz); -* hipMalloc((void**)&dx, sizeof(double) * n); -* hipMalloc((void**)&dy, sizeof(double) * m); -* -* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_val, hcsr_val, sizeof(double) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx, hx, sizeof(double) * n, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(double) * m, hipMemcpyHostToDevice); -* -* // Call dcsrmv to perform y = alpha * A x + beta * y -* hipsparseDcsrmv(handle, -* trans, -* m, -* n, -* nnz, -* &alpha, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* dx, -* &beta, -* dy); -* -* // Copy result back to host -* hipMemcpy(hy, dy, sizeof(double) * m, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroyMatDescr(descr); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dcsr_row_ptr); -* hipFree(dcsr_col_ind); -* hipFree(dcsr_val); -* hipFree(dx); -* hipFree(dy); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* x, - const float* beta, - float* y); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* x, - const double* beta, - double* y); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* x, - const hipComplex* beta, - hipComplex* y); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* x, - const hipDoubleComplex* beta, - hipDoubleComplex* y); -/**@}*/ -#endif +/* Sparse vector API */ +#include "hipsparse_generic_auxiliary.h" -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using CSR storage format -* -* \details -* \p hipsparseXcsrsv2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a -* structural or numerical zero has been found during hipsparseScsrsv2_solve(), -* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() or hipsparseZcsrsv2_solve() -* computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is stored in \p position, -* using same index base as the CSR matrix. -* -* \p position can be in host or device memory. If no zero pivot has been found, -* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. -* -* \note \p hipsparseXcsrsv2_zeroPivot is a blocking function. It might influence -* performance negatively. -*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXcsrsv2_zeroPivot(hipsparseHandle_t handle, csrsv2Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using CSR storage format -* -* \details -* \p hipsparseXcsrsv2_bufferSize returns the size of the temporary storage buffer in bytes -* that is required by hipsparseScsrsv2_analysis(), hipsparseDcsrsv2_analysis(), -* hipsparseCcsrsv2_analysis(), hipsparseZcsrsv2_analysis(), hipsparseScsrsv2_solve(), -* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). The -* temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -/*! \ingroup level2_module -* \brief Sparse triangular solve using CSR storage format -* -* \details -* \p hipsparseXcsrsv2_bufferSizeExt returns the size of the temporary storage buffer in bytes -* that is required by hipsparseScsrsv2_analysis(), hipsparseDcsrsv2_analysis(), -* hipsparseCcsrsv2_analysis(), hipsparseZcsrsv2_analysis(), hipsparseScsrsv2_solve(), -* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). The -* temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - size_t* pBufferSizeInBytes); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using CSR storage format -* -* \details -* \p hipsparseXcsrsv2_analysis performs the analysis step for hipsparseScsrsv2_solve(), -* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsv2_analysis(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsv2_analysis(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsv2_analysis(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsv2_analysis(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using CSR storage format -* -* \details -* \p hipsparseXcsrsv2_solve solves a sparse triangular linear system of a sparse -* \f$m \times m\f$ matrix, defined in CSR storage format, a dense solution vector -* \f$y\f$ and the right-hand side \f$x\f$ that is multiplied by \f$\alpha\f$, such that -* \f[ -* op(A) \cdot y = \alpha \cdot x, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \p hipsparseXcsrsv2_solve requires a user allocated temporary buffer. Its size is -* returned by hipsparseXcsrsv2_bufferSize() or hipsparseXcsrsv2_bufferSizeExt(). -* Furthermore, analysis meta data is required. It can be obtained by -* hipsparseXcsrsv2_analysis(). \p hipsparseXcsrsv2_solve reports the first zero pivot -* (either numerical or structural zero). The zero pivot status can be checked calling -* hipsparseXcsrsv2_zeroPivot(). If -* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be -* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. -* -* \note -* The sparse CSR matrix has to be sorted. This can be achieved by calling -* hipsparseXcsrsort(). -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE and -* \p trans == \ref HIPSPARSE_OPERATION_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // alpha * ( 1.0 0.0 2.0 0.0 ) * ( x_0 ) = ( 32.0 ) -* // ( 3.0 2.0 4.0 1.0 ) * ( x_1 ) = ( 14.7 ) -* // ( 5.0 6.0 1.0 3.0 ) * ( x_2 ) = ( 33.6 ) -* // ( 7.0 0.0 8.0 0.6 ) * ( x_3 ) = ( 10.0 ) -* -* int m = 4; -* int nnz = 13; -* -* // CSR row pointers -* int hcsr_row_ptr[5] = {0, 2, 6, 10, 13}; -* -* // CSR column indices -* int hcsr_col_ind[13] = {0, 2, 0, 1, 2, 3, 0, 1, 2, 3, 0, 2, 3}; -* -* // CSR values -* double hcsr_val[13] = {1.0, 2.0, 3.0, 2.0, 4.0, 1.0, 5.0, 6.0, 1.0, 3.0, 7.0, 8.0, 0.6}; -* -* // Transposition of the matrix -* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseSolvePolicy_t policy = HIPSPARSE_SOLVE_POLICY_USE_LEVEL; -* -* // Scalar alpha -* double alpha = 1.0; -* -* // f and x -* double hf[4] = {32.0, 14.7, 33.6, 10.0}; -* double hx[4]; -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Set index base on descriptor -* hipsparseSetMatIndexBase(descr, HIPSPARSE_INDEX_BASE_ZERO); -* -* // Set fill mode on descriptor -* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); -* -* // Set diag type on descriptor -* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_UNIT); -* -* // Csrsv info -* csrsv2Info_t info; -* hipsparseCreateCsrsv2Info(&info); -* -* // Offload data to device -* int* dcsr_row_ptr; -* int* dcsr_col_ind; -* double* dcsr_val; -* double* df; -* double* dx; -* -* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dcsr_val, sizeof(double) * nnz); -* hipMalloc((void**)&df, sizeof(double) * m); -* hipMalloc((void**)&dx, sizeof(double) * m); -* -* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_val, hcsr_val, sizeof(double) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(df, hf, sizeof(double) * m, hipMemcpyHostToDevice); -* -* int bufferSize = 0; -* hipsparseDcsrsv2_bufferSize(handle, -* trans, -* m, -* nnz, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* info, -* &bufferSize); -* -* void* dbuffer = nullptr; -* hipMalloc((void**)&dbuffer, bufferSize); -* -* hipsparseDcsrsv2_analysis(handle, -* trans, -* m, -* nnz, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* info, -* policy, -* dbuffer); -* -* // Call dcsrsv to perform alpha * A * x = f -* hipsparseDcsrsv2_solve(handle, -* trans, -* m, -* nnz, -* &alpha, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* info, -* df, -* dx, -* policy, -* dbuffer); -* -* // Copy result back to host -* hipMemcpy(hx, dx, sizeof(double) * m, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroyMatDescr(descr); -* hipsparseDestroyCsrsv2Info(info); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dcsr_row_ptr); -* hipFree(dcsr_col_ind); -* hipFree(dcsr_val); -* hipFree(df); -* hipFree(dx); -* hipFree(dbuffer); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsv2_solve(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - const float* f, - float* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsv2_solve(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - const double* f, - double* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsv2_solve(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - const hipComplex* f, - hipComplex* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsv2_solve(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrsv2Info_t info, - const hipDoubleComplex* f, - hipDoubleComplex* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup level2_module -* \brief Sparse matrix vector multiplication using HYB storage format -* -* \details -* \p hipsparseXhybmv multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times n\f$ -* matrix, defined in HYB storage format, and the dense vector \f$x\f$ and adds the -* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, -* such that -* \f[ -* y := \alpha \cdot op(A) \cdot x + \beta \cdot y, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // A sparse matrix -* // 1 0 3 4 -* // 0 0 5 1 -* // 0 2 0 0 -* // 4 0 0 8 -* int hAptr[5] = {0, 3, 5, 6, 8}; -* int hAcol[8] = {0, 2, 3, 2, 3, 1, 0, 3}; -* double hAval[8] = {1.0, 3.0, 4.0, 5.0, 1.0, 2.0, 4.0, 8.0}; -* -* int m = 4; -* int n = 4; -* int nnz = 8; -* -* double halpha = 1.0; -* double hbeta = 0.0; -* -* double hx[4] = {1.0, 2.0, 3.0, 4.0}; -* double hy[4] = {4.0, 5.0, 6.0, 7.0}; -* -* // Matrix descriptor -* hipsparseMatDescr_t descrA; -* hipsparseCreateMatDescr(&descrA); -* -* // Offload data to device -* int* dAptr = NULL; -* int* dAcol = NULL; -* double* dAval = NULL; -* double* dx = NULL; -* double* dy = NULL; -* -* hipMalloc((void**)&dAptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dAcol, sizeof(int) * nnz); -* hipMalloc((void**)&dAval, sizeof(double) * nnz); -* hipMalloc((void**)&dx, sizeof(double) * n); -* hipMalloc((void**)&dy, sizeof(double) * m); -* -* hipMemcpy(dAptr, hAptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dAcol, hAcol, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dAval, hAval, sizeof(double) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx, hx, sizeof(double) * n, hipMemcpyHostToDevice); -* -* // Convert CSR matrix to HYB format -* hipsparseHybMat_t hybA; -* hipsparseCreateHybMat(&hybA); -* -* hipsparseDcsr2hyb(handle, m, n, descrA, dAval, dAptr, dAcol, hybA, 0, HIPSPARSE_HYB_PARTITION_AUTO); -* -* // Clean up CSR structures -* hipFree(dAptr); -* hipFree(dAcol); -* hipFree(dAval); -* -* // Call hipsparse hybmv -* hipsparseDhybmv(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, &halpha, descrA, hybA, dx, &hbeta, dy); -* -* // Copy result back to host -* hipMemcpy(hy, dy, sizeof(double) * m, hipMemcpyDeviceToHost); -* -* // Clear up on device -* hipsparseDestroyHybMat(hybA); -* hipsparseDestroyMatDescr(descrA); -* hipsparseDestroy(handle); -* -* hipFree(dx); -* hipFree(dy); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseShybmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - const float* alpha, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - const float* x, - const float* beta, - float* y); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDhybmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - const double* alpha, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - const double* x, - const double* beta, - double* y); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseChybmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - const hipComplex* x, - const hipComplex* beta, - hipComplex* y); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZhybmv(hipsparseHandle_t handle, - hipsparseOperation_t transA, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - const hipDoubleComplex* x, - const hipDoubleComplex* beta, - hipDoubleComplex* y); -/**@}*/ -#endif - -/*! \ingroup level2_module -* \brief Sparse matrix vector multiplication using BSR storage format -* -* \details -* \p hipsparseXbsrmv multiplies the scalar \f$\alpha\f$ with a sparse -* \f$(mb \cdot \text{block_dim}) \times (nb \cdot \text{block_dim})\f$ -* matrix, defined in BSR storage format, and the dense vector \f$x\f$ and adds the -* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, -* such that -* \f[ -* y := \alpha \cdot op(A) \cdot x + \beta \cdot y, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // alpha * ( 1.0 0.0 2.0 ) * ( 1.0 ) + beta * ( 4.0 ) = ( 31.1 ) -* // ( 3.0 0.0 4.0 ) * ( 2.0 ) ( 5.0 ) = ( 62.0 ) -* // ( 5.0 6.0 0.0 ) * ( 3.0 ) ( 6.0 ) = ( 70.7 ) -* // ( 7.0 0.0 8.0 ) * ( 7.0 ) = ( 123.8 ) -* -* // BSR block dimension -* int bsr_dim = 2; -* -* // Number of block rows and columns -* int mb = 2; -* int nb = 2; -* -* // Number of non-zero blocks -* int nnzb = 4; -* -* // BSR row pointers -* int hbsr_row_ptr[3] = {0, 2, 4}; -* -* // BSR column indices -* int hbsr_col_ind[4] = {0, 1, 0, 1}; -* -* // BSR values -* double hbsr_val[16] -* = {1.0, 3.0, 0.0, 0.0, 2.0, 4.0, 0.0, 0.0, 5.0, 7.0, 6.0, 0.0, 0.0, 8.0, 0.0, 0.0}; -* -* // Block storage in column major -* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_COLUMN; -* -* // Transposition of the matrix -* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* -* // Scalar alpha and beta -* double alpha = 3.7; -* double beta = 1.3; -* -* // x and y -* double hx[4] = {1.0, 2.0, 3.0, 0.0}; -* double hy[4] = {4.0, 5.0, 6.0, 7.0}; -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Offload data to device -* int* dbsr_row_ptr; -* int* dbsr_col_ind; -* double* dbsr_val; -* double* dx; -* double* dy; -* -* hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); -* hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); -* hipMalloc((void**)&dbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim); -* hipMalloc((void**)&dx, sizeof(double) * nb * bsr_dim); -* hipMalloc((void**)&dy, sizeof(double) * mb * bsr_dim); -* -* hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); -* hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); -* hipMemcpy(dbsr_val, hbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim, hipMemcpyHostToDevice); -* hipMemcpy(dx, hx, sizeof(double) * nb * bsr_dim, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy, sizeof(double) * mb * bsr_dim, hipMemcpyHostToDevice); -* -* // Call dbsrmv to perform y = alpha * A x + beta * y -* hipsparseDbsrmv(handle, -* dir, -* trans, -* mb, -* nb, -* nnzb, -* &alpha, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* dx, -* &beta, -* dy); -* -* // Copy result back to host -* hipMemcpy(hy, dy, sizeof(double) * mb * bsr_dim, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroyMatDescr(descr); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dbsr_row_ptr); -* hipFree(dbsr_col_ind); -* hipFree(dbsr_val); -* hipFree(dx); -* hipFree(dy); -* \endcode -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrmv(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nb, - int nnzb, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - const float* x, - const float* beta, - float* y); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrmv(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nb, - int nnzb, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - const double* x, - const double* beta, - double* y); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrmv(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nb, - int nnzb, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - const hipComplex* x, - const hipComplex* beta, - hipComplex* y); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrmv(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nb, - int nnzb, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - const hipDoubleComplex* x, - const hipDoubleComplex* beta, - hipDoubleComplex* y); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level2_module -* \brief Sparse matrix vector multiplication with mask operation using BSR storage format -* -* \details -* \p hipsparseXbsrxmv multiplies the scalar \f$\alpha\f$ with a sparse -* \f$(mb \cdot \text{block_dim}) \times (nb \cdot \text{block_dim})\f$ -* modified matrix, defined in BSR storage format, and the dense vector \f$x\f$ and adds the -* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, -* such that -* \f[ -* y := \left( \alpha \cdot op(A) \cdot x + \beta \cdot y \right)\left( \text{mask} \right), -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* The \f$\text{mask}\f$ is defined as an array of block row indices. -* The input sparse matrix is defined with a modified BSR storage format where the beginning and the end of each row -* is defined with two arrays, \p bsr_row_ptr and \p bsr_end_ptr (both of size \p mb), rather the usual \p bsr_row_ptr of size \p mb + 1. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. -* Currently, \p block_dim == 1 is not supported. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrxmv(hipsparseHandle_t handle, - hipsparseDirection_t dir, - hipsparseOperation_t trans, - int sizeOfMask, - int mb, - int nb, - int nnzb, - const float* alpha, - const hipsparseMatDescr_t descr, - const float* bsrVal, - const int* bsrMaskPtr, - const int* bsrRowPtr, - const int* bsrEndPtr, - const int* bsrColInd, - int blockDim, - const float* x, - const float* beta, - float* y); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrxmv(hipsparseHandle_t handle, - hipsparseDirection_t dir, - hipsparseOperation_t trans, - int sizeOfMask, - int mb, - int nb, - int nnzb, - const double* alpha, - const hipsparseMatDescr_t descr, - const double* bsrVal, - const int* bsrMaskPtr, - const int* bsrRowPtr, - const int* bsrEndPtr, - const int* bsrColInd, - int blockDim, - const double* x, - const double* beta, - double* y); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrxmv(hipsparseHandle_t handle, - hipsparseDirection_t dir, - hipsparseOperation_t trans, - int sizeOfMask, - int mb, - int nb, - int nnzb, - const hipComplex* alpha, - const hipsparseMatDescr_t descr, - const hipComplex* bsrVal, - const int* bsrMaskPtr, - const int* bsrRowPtr, - const int* bsrEndPtr, - const int* bsrColInd, - int blockDim, - const hipComplex* x, - const hipComplex* beta, - hipComplex* y); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrxmv(hipsparseHandle_t handle, - hipsparseDirection_t dir, - hipsparseOperation_t trans, - int sizeOfMask, - int mb, - int nb, - int nnzb, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descr, - const hipDoubleComplex* bsrVal, - const int* bsrMaskPtr, - const int* bsrRowPtr, - const int* bsrEndPtr, - const int* bsrColInd, - int blockDim, - const hipDoubleComplex* x, - const hipDoubleComplex* beta, - hipDoubleComplex* y); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using BSR storage format -* -* \details -* \p hipsparseXbsrsv2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a -* structural or numerical zero has been found during hipsparseXbsrsv2_analysis() or -* hipsparseXbsrsv2_solve() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ -* is stored in \p position, using same index base as the BSR matrix. -* -* \p position can be in host or device memory. If no zero pivot has been found, -* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. -* -* \note \p hipsparseXbsrsv2_zeroPivot is a blocking function. It might influence -* performance negatively. -*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXbsrsv2_zeroPivot(hipsparseHandle_t handle, bsrsv2Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using BSR storage format -* -* \details -* \p hipsparseXbsrsv2_bufferSize returns the size of the temporary storage buffer in bytes -* that is required by hipsparseXbsrsv2_analysis() and hipsparseXbsrsv2_solve(). The -* temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsv2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -/*! \ingroup level2_module -* \brief Sparse triangular solve using BSR storage format -* -* \details -* \p hipsparseXbsrsv2_bufferSizeExt returns the size of the temporary storage buffer in bytes -* that is required by hipsparseXbsrsv2_analysis() and hipsparseXbsrsv2_solve(). The -* temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsv2_bufferSizeExt(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - size_t* pBufferSizeInBytes); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using BSR storage format -* -* \details -* \p hipsparseXbsrsv2_analysis performs the analysis step for hipsparseXbsrsv2_solve(). -* -* \note -* If the matrix sparsity pattern changes, the gathered information will become invalid. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsv2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsv2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsv2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsv2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level2_module -* \brief Sparse triangular solve using BSR storage format -* -* \details -* \p hipsparseXbsrsv2_solve solves a sparse triangular linear system of a sparse -* \f$m \times m\f$ matrix, defined in BSR storage format, a dense solution vector -* \f$y\f$ and the right-hand side \f$x\f$ that is multiplied by \f$\alpha\f$, such that -* \f[ -* op(A) \cdot y = \alpha \cdot x, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \p hipsparseXbsrsv2_solve requires a user allocated temporary buffer. Its size is -* returned by hipsparseXbsrsv2_bufferSize() or hipsparseXbsrsv2_bufferSizeExt(). -* Furthermore, analysis meta data is required. It can be obtained by -* hipsparseXbsrsv2_analysis(). \p hipsparseXbsrsv2_solve reports the first zero pivot -* (either numerical or structural zero). The zero pivot status can be checked calling -* hipsparseXbsrsv2_zeroPivot(). If -* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be -* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. -* -* \note -* The sparse BSR matrix has to be sorted. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE and -* \p trans == \ref HIPSPARSE_OPERATION_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // A = ( 1.0 0.0 0.0 0.0 ) -* // ( 2.0 3.0 0.0 0.0 ) -* // ( 4.0 5.0 6.0 0.0 ) -* // ( 7.0 0.0 8.0 9.0 ) -* // -* // with bsr_dim = 2 -* // -* // ------------------- -* // = | 1.0 0.0 | 0.0 0.0 | -* // | 2.0 3.0 | 0.0 0.0 | -* // ------------------- -* // | 4.0 5.0 | 6.0 0.0 | -* // | 7.0 0.0 | 8.0 9.0 | -* // ------------------- -* -* // Number of rows and columns -* int m = 4; -* -* // Number of block rows and block columns -* int mb = 2; -* int nb = 2; -* -* // BSR block dimension -* int bsr_dim = 2; -* -* // Number of non-zero blocks -* int nnzb = 3; -* -* // BSR row pointers -* int hbsr_row_ptr[3] = {0, 1, 3}; -* -* // BSR column indices -* int hbsr_col_ind[3] = {0, 0, 1}; -* -* // BSR values -* double hbsr_val[12] = {1.0, 2.0, 0.0, 3.0, 4.0, 7.0, 5.0, 0.0, 6.0, 8.0, 0.0, 9.0}; -* -* // Storage scheme of the BSR blocks -* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_COLUMN; -* -* // Transposition of the matrix and rhs matrix -* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* -* // Solve policy -* hipsparseSolvePolicy_t solve_policy = HIPSPARSE_SOLVE_POLICY_USE_LEVEL; -* -* // Scalar alpha and beta -* double alpha = 3.7; -* -* double hx[4] = {1, 2, 3, 4}; -* double hy[4]; -* -* // Offload data to device -* int* dbsr_row_ptr; -* int* dbsr_col_ind; -* double* dbsr_val; -* double* dx; -* double* dy; -* -* hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); -* hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); -* hipMalloc((void**)&dbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim); -* hipMalloc((void**)&dx, sizeof(double) * nb * bsr_dim); -* hipMalloc((void**)&dy, sizeof(double) * mb * bsr_dim); -* -* hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); -* hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); -* hipMemcpy(dbsr_val, hbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim, hipMemcpyHostToDevice); -* hipMemcpy(dx, hx, sizeof(double) * nb * bsr_dim, hipMemcpyHostToDevice); -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Matrix fill mode -* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); -* -* // Matrix diagonal type -* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_UNIT); -* -* // Matrix info structure -* bsrsv2Info_t info; -* hipsparseCreateBsrsv2Info(&info); -* -* // Obtain required buffer size -* int buffer_size; -* hipsparseDbsrsv2_bufferSize(handle, -* dir, -* trans, -* mb, -* nnzb, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* info, -* &buffer_size); -* -* // Allocate temporary buffer -* void* dbuffer; -* hipMalloc(&dbuffer, buffer_size); -* -* // Perform analysis step -* hipsparseDbsrsv2_analysis(handle, -* dir, -* trans, -* mb, -* nnzb, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* info, -* solve_policy, -* dbuffer); -* -* // Call dbsrsm to perform lower triangular solve LX = B -* hipsparseDbsrsv2_solve(handle, -* dir, -* trans, -* mb, -* nnzb, -* &alpha, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* info, -* dx, -* dy, -* solve_policy, -* dbuffer); -* -* // Check for zero pivots -* int pivot; -* hipsparseStatus_t status = hipsparseXbsrsv2_zeroPivot(handle, info, &pivot); -* -* if(status == HIPSPARSE_STATUS_ZERO_PIVOT) -* { -* std::cout << "Found zero pivot in matrix row " << pivot << std::endl; -* } -* -* // Copy results back to the host -* hipMemcpy(hy, dy, sizeof(double) * mb * bsr_dim, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroyBsrsv2Info(info); -* hipsparseDestroyMatDescr(descr); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dbsr_row_ptr); -* hipFree(dbsr_col_ind); -* hipFree(dbsr_val); -* hipFree(dx); -* hipFree(dy); -* hipFree(dbuffer); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsv2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - const float* f, - float* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsv2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - const double* f, - double* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsv2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - const hipComplex* f, - hipComplex* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsv2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - int mb, - int nnzb, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsv2Info_t info, - const hipDoubleComplex* f, - hipDoubleComplex* x, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -/*! \ingroup level2_module - * \brief Dense matrix sparse vector multiplication - * - * \details - * \p hipsparseXgemvi_bufferSize returns the size of the temporary storage buffer in bytes - * required by hipsparseXgemvi(). The temporary storage buffer must be allocated by the - * user. - */ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgemvi_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - int* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgemvi_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - int* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgemvi_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - int* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgemvi_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int nnz, - int* pBufferSizeInBytes); -/**@}*/ - -/*! \ingroup level2_module - * \brief Dense matrix sparse vector multiplication - * - * \details - * \p hipsparseXgemvi multiplies the scalar \f$\alpha\f$ with a dense \f$m \times n\f$ - * matrix \f$A\f$ and the sparse vector \f$x\f$ and adds the result to the dense vector - * \f$y\f$ that is multiplied by the scalar \f$\beta\f$, such that - * \f[ - * y := \alpha \cdot op(A) \cdot x + \beta \cdot y, - * \f] - * with - * \f[ - * op(A) = \left\{ - * \begin{array}{ll} - * A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ - * A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ - * A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} - * \end{array} - * \right. - * \f] - * - * \p hipsparseXgemvi requires a user allocated temporary buffer. Its size is returned - * by hipsparseXgemvi_bufferSize(). - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. - * - * \note - * Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. - */ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgemvi(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - const float* alpha, - const float* A, - int lda, - int nnz, - const float* x, - const int* xInd, - const float* beta, - float* y, - hipsparseIndexBase_t idxBase, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgemvi(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - const double* alpha, - const double* A, - int lda, - int nnz, - const double* x, - const int* xInd, - const double* beta, - double* y, - hipsparseIndexBase_t idxBase, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgemvi(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - const hipComplex* alpha, - const hipComplex* A, - int lda, - int nnz, - const hipComplex* x, - const int* xInd, - const hipComplex* beta, - hipComplex* y, - hipsparseIndexBase_t idxBase, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgemvi(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - const hipDoubleComplex* alpha, - const hipDoubleComplex* A, - int lda, - int nnz, - const hipDoubleComplex* x, - const int* xInd, - const hipDoubleComplex* beta, - hipDoubleComplex* y, - hipsparseIndexBase_t idxBase, - void* pBuffer); -/**@}*/ - -/* -* =========================================================================== -* level 3 SPARSE -* =========================================================================== -*/ - -/*! \ingroup level3_module - * \brief Sparse matrix dense matrix multiplication using BSR storage format - * - * \details - * \p hipsparseXbsrmm multiplies the scalar \f$\alpha\f$ with a sparse \f$mb \times kb\f$ - * matrix \f$A\f$, defined in BSR storage format, and the dense \f$k \times n\f$ - * matrix \f$B\f$ (where \f$k = block\_dim \times kb\f$) and adds the result to the dense - * \f$m \times n\f$ matrix \f$C\f$ (where \f$m = block\_dim \times mb\f$) that - * is multiplied by the scalar \f$\beta\f$, such that - * \f[ - * C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C, - * \f] - * with - * \f[ - * op(A) = \left\{ - * \begin{array}{ll} - * A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ - * \end{array} - * \right. - * \f] - * and - * \f[ - * op(B) = \left\{ - * \begin{array}{ll} - * B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ - * B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ - * \end{array} - * \right. - * \f] - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. - * - * \note - * Currently, only \p trans_A == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. - * - * \par Example - * \code{.c} - * // hipSPARSE handle - * hipsparseHandle_t handle; - * hipsparseCreate(&handle); - * - * // 1 2 0 3 0 0 - * // A = 0 4 5 0 0 0 - * // 0 0 0 7 8 0 - * // 0 0 1 2 4 1 - * - * int block_dim = 2; - * int mb = 2; - * int kb = 3; - * int nnzb = 4; - * hipsparseDirection_t dir = HIPSPARSE_DIRECTION_ROW; - * - * int hbsr_row_ptr[2 + 1] = {0, 2, 4}; - * int hbsr_col_ind[4] = {0, 1, 1, 2}; - * float hbsr_val[4 * 2 * 2] = {1, 2, 0, 4, 0, 3, 5, 0, 0, 7, 1, 2, 8, 0, 4, 1}; - * - * // Set dimension n of B - * int n = 3; - * int m = mb * block_dim; - * int k = kb * block_dim; - * - * // Allocate and generate dense matrix B (k x n) - * float hB[6 * 3] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, - * 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f}; - * - * int* dbsr_row_ptr = NULL; - * int* dbsr_col_ind = NULL; - * float* dbsr_val = NULL; - * hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); - * hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); - * hipMalloc((void**)&dbsr_val, sizeof(float) * nnzb * block_dim * block_dim); - * hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); - * hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); - * hipMemcpy(dbsr_val, hbsr_val, sizeof(float) * nnzb * block_dim * block_dim, hipMemcpyHostToDevice); - * - * // Copy B to the device - * float* dB; - * hipMalloc((void**)&dB, sizeof(float) * k * n); - * hipMemcpy(dB, hB, sizeof(float) * k * n, hipMemcpyHostToDevice); - * - * // alpha and beta - * float alpha = 1.0f; - * float beta = 0.0f; - * - * // Allocate memory for the resulting matrix C - * float* dC; - * hipMalloc((void**)&dC, sizeof(float) * m * n); - * - * // Matrix descriptor - * hipsparseMatDescr_t descr; - * hipsparseCreateMatDescr(&descr); - * - * // Perform the matrix multiplication - * hipsparseSbsrmm(handle, - * dir, - * HIPSPARSE_OPERATION_NON_TRANSPOSE, - * HIPSPARSE_OPERATION_NON_TRANSPOSE, - * mb, - * n, - * kb, - * nnzb, - * &alpha, - * descr, - * dbsr_val, - * dbsr_row_ptr, - * dbsr_col_ind, - * block_dim, - * dB, - * k, - * &beta, - * dC, - * m); - * - * // Copy results to host - * float hC[6 * 3]; - * hipMemcpy(hC, dC, sizeof(float) * m * n, hipMemcpyDeviceToHost); - * - * hipFree(dbsr_row_ptr); - * hipFree(dbsr_col_ind); - * hipFree(dbsr_val); - * hipFree(dB); - * hipFree(dC); - * \endcode - */ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrmm(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int mb, - int n, - int kb, - int nnzb, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const float* B, - int ldb, - const float* beta, - float* C, - int ldc); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrmm(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int mb, - int n, - int kb, - int nnzb, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const double* B, - int ldb, - const double* beta, - double* C, - int ldc); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrmm(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int mb, - int n, - int kb, - int nnzb, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const hipComplex* B, - int ldb, - const hipComplex* beta, - hipComplex* C, - int ldc); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrmm(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int mb, - int n, - int kb, - int nnzb, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const hipDoubleComplex* B, - int ldb, - const hipDoubleComplex* beta, - hipDoubleComplex* C, - int ldc); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup level3_module -* \brief Sparse matrix dense matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrmm multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times k\f$ -* matrix \f$A\f$, defined in CSR storage format, and the dense \f$k \times n\f$ -* matrix \f$B\f$ and adds the result to the dense \f$m \times n\f$ matrix \f$C\f$ that -* is multiplied by the scalar \f$\beta\f$, such that -* \f[ -* C := \alpha \cdot op(A) \cdot B + \beta \cdot C, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \code{.c} -* for(i = 0; i < ldc; ++i) -* { -* for(j = 0; j < n; ++j) -* { -* C[i][j] = beta * C[i][j]; -* -* for(k = csr_row_ptr[i]; k < csr_row_ptr[i + 1]; ++k) -* { -* C[i][j] += alpha * csr_val[k] * B[csr_col_ind[k]][j]; -* } -* } -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // 1 2 0 3 0 0 -* // A = 0 4 5 0 0 0 -* // 0 0 0 7 8 0 -* // 0 0 1 2 4 1 -* -* int m = 4; -* int k = 6; -* int nnz = 11; -* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_ROW; -* -* int hcsr_row_ptr[4 + 1] = {0, 3, 5, 7, 11}; -* int hcsr_col_ind[11] = {0, 1, 3, 1, 2, 3, 4, 2, 3, 4, 5}; -* float hcsr_val[11] = {1, 2, 3, 4, 5, 7, 8, 1, 2, 4, 1}; -* -* // Set dimension n of B -* int n = 3; -* -* // Allocate and generate dense matrix B (k x n) -* float hB[6 * 3] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, -* 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f}; -* -* int* dcsr_row_ptr = NULL; -* int* dcsr_col_ind = NULL; -* float* dcsr_val = NULL; -* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dcsr_val, sizeof(float) * nnz); -* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_val, hcsr_val, sizeof(float) * nnz, hipMemcpyHostToDevice); -* -* // Copy B to the device -* float* dB; -* hipMalloc((void**)&dB, sizeof(float) * k * n); -* hipMemcpy(dB, hB, sizeof(float) * k * n, hipMemcpyHostToDevice); -* -* // alpha and beta -* float alpha = 1.0f; -* float beta = 0.0f; -* -* // Allocate memory for the resulting matrix C -* float* dC; -* hipMalloc((void**)&dC, sizeof(float) * m * n); -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Perform the matrix multiplication -* hipsparseScsrmm(handle, -* HIPSPARSE_OPERATION_NON_TRANSPOSE, -* m, -* n, -* k, -* nnz, -* &alpha, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* dB, -* k, -* &beta, -* dC, -* m); -* -* // Copy results to host -* float hC[6 * 3]; -* hipMemcpy(hC, dC, sizeof(float) * m * n, hipMemcpyDeviceToHost); -* -* hipFree(dcsr_row_ptr); -* hipFree(dcsr_col_ind); -* hipFree(dcsr_val); -* hipFree(dB); -* hipFree(dC); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrmm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int k, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* B, - int ldb, - const float* beta, - float* C, - int ldc); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrmm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int k, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* B, - int ldb, - const double* beta, - double* C, - int ldc); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrmm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int k, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* B, - int ldb, - const hipComplex* beta, - hipComplex* C, - int ldc); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrmm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - int m, - int n, - int k, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* B, - int ldb, - const hipDoubleComplex* beta, - hipDoubleComplex* C, - int ldc); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup level3_module -* \brief Sparse matrix dense matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrmm2 multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times k\f$ -* matrix \f$A\f$, defined in CSR storage format, and the dense \f$k \times n\f$ -* matrix \f$B\f$ and adds the result to the dense \f$m \times n\f$ matrix \f$C\f$ that -* is multiplied by the scalar \f$\beta\f$, such that -* \f[ -* C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* and -* \f[ -* op(B) = \left\{ -* \begin{array}{ll} -* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \code{.c} -* for(i = 0; i < ldc; ++i) -* { -* for(j = 0; j < n; ++j) -* { -* C[i][j] = beta * C[i][j]; -* -* for(k = csr_row_ptr[i]; k < csr_row_ptr[i + 1]; ++k) -* { -* C[i][j] += alpha * csr_val[k] * B[csr_col_ind[k]][j]; -* } -* } -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrmm2(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* B, - int ldb, - const float* beta, - float* C, - int ldc); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrmm2(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* B, - int ldb, - const double* beta, - double* C, - int ldc); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrmm2(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* B, - int ldb, - const hipComplex* beta, - hipComplex* C, - int ldc); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrmm2(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* B, - int ldb, - const hipDoubleComplex* beta, - hipDoubleComplex* C, - int ldc); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using BSR storage format -* -* \details -* \p hipsparseXbsrsm2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a -* structural or numerical zero has been found during hipsparseXbsrsm2_analysis() or -* hipsparseXbsrsm2_solve() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ -* is stored in \p position, using same index base as the BSR matrix. -* -* \p position can be in host or device memory. If no zero pivot has been found, -* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. -* -* \note \p hipsparseXbsrsm2_zeroPivot is a blocking function. It might influence -* performance negatively. -*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXbsrsm2_zeroPivot(hipsparseHandle_t handle, bsrsm2Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using BSR storage format -* -* \details -* \p hipsparseXbsrsm2_buffer_size returns the size of the temporary storage buffer in bytes -* that is required by hipsparseXbsrsm2_analysis() and hipsparseXbsrsm2_solve(). The -* temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsm2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - int* pBufferSizeInBytes); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsm2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - int* pBufferSizeInBytes); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsm2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - int* pBufferSizeInBytes); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsm2_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using BSR storage format -* -* \details -* \p hipsparseXbsrsm2_analysis performs the analysis step for hipsparseXbsrsm2_solve(). -* -* \note -* If the matrix sparsity pattern changes, the gathered information will become invalid. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsm2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - const float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsm2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - const double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsm2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsm2_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using BSR storage format -* -* \details -* \p hipsparseXbsrsm2_solve solves a sparse triangular linear system of a sparse -* \f$m \times m\f$ matrix, defined in BSR storage format, a dense solution matrix -* \f$X\f$ and the right-hand side matrix \f$B\f$ that is multiplied by \f$\alpha\f$, such that -* \f[ -* op(A) \cdot op(X) = \alpha \cdot op(B), -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* , -* \f[ -* op(X) = \left\{ -* \begin{array}{ll} -* X, & \text{if trans_X == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* X^T, & \text{if trans_X == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* X^H, & \text{if trans_X == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \p hipsparseXbsrsm2_solve requires a user allocated temporary buffer. Its size is -* returned by hipsparseXbsrsm2_bufferSize(). Furthermore, analysis meta data is -* required. It can be obtained by hipsparseXbsrsm2_analysis(). \p hipsparseXbsrsm2_solve -* reports the first zero pivot (either numerical or structural zero). The zero pivot -* status can be checked calling hipsparseXbsrsm2_zeroPivot(). If -* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be -* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. -* -* \note -* The sparse BSR matrix has to be sorted. -* -* \note -* Operation type of B and X must match, if \f$op(B)=B, op(X)=X\f$. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans_A != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and -* \p trans_X != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // A = ( 1.0 0.0 0.0 0.0 ) -* // ( 2.0 3.0 0.0 0.0 ) -* // ( 4.0 5.0 6.0 0.0 ) -* // ( 7.0 0.0 8.0 9.0 ) -* // -* // with bsr_dim = 2 -* // -* // ------------------- -* // = | 1.0 0.0 | 0.0 0.0 | -* // | 2.0 3.0 | 0.0 0.0 | -* // ------------------- -* // | 4.0 5.0 | 6.0 0.0 | -* // | 7.0 0.0 | 8.0 9.0 | -* // ------------------- -* -* // Number of rows and columns -* int m = 4; -* -* // Number of block rows and block columns -* int mb = 2; -* int nb = 2; -* -* // BSR block dimension -* int bsr_dim = 2; -* -* // Number of right-hand-sides -* int nrhs = 4; -* -* // Number of non-zero blocks -* int nnzb = 3; -* -* // BSR row pointers -* int hbsr_row_ptr[3] = {0, 1, 3}; -* -* // BSR column indices -* int hbsr_col_ind[3] = {0, 0, 1}; -* -* // BSR values -* double hbsr_val[12] = {1.0, 2.0, 0.0, 3.0, 4.0, 7.0, 5.0, 0.0, 6.0, 8.0, 0.0, 9.0}; -* -* // Storage scheme of the BSR blocks -* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_COLUMN; -* -* // Transposition of the matrix and rhs matrix -* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseOperation_t transX = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* -* // Solve policy -* hipsparseSolvePolicy_t solve_policy = HIPSPARSE_SOLVE_POLICY_NO_LEVEL; -* -* // Scalar alpha and beta -* double alpha = 1.0; -* -* // rhs and solution matrix -* int ldb = nb * bsr_dim; -* int ldx = mb * bsr_dim; -* -* double hB[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; -* double hX[16]; -* -* // Offload data to device -* int* dbsr_row_ptr; -* int* dbsr_col_ind; -* double* dbsr_val; -* double* dB; -* double* dX; -* -* hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); -* hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); -* hipMalloc((void**)&dbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim); -* hipMalloc((void**)&dB, sizeof(double) * nb * bsr_dim * nrhs); -* hipMalloc((void**)&dX, sizeof(double) * mb * bsr_dim * nrhs); -* -* hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); -* hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); -* hipMemcpy(dbsr_val, hbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim, hipMemcpyHostToDevice); -* hipMemcpy(dB, hB, sizeof(double) * nb * bsr_dim * nrhs, hipMemcpyHostToDevice); -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Matrix fill mode -* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); -* -* // Matrix diagonal type -* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_NON_UNIT); -* -* // Matrix info structure -* bsrsm2Info_t info; -* hipsparseCreateBsrsm2Info(&info); -* -* // Obtain required buffer size -* int buffer_size; -* hipsparseDbsrsm2_bufferSize(handle, -* dir, -* transA, -* transX, -* mb, -* nrhs, -* nnzb, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* info, -* &buffer_size); -* -* // Allocate temporary buffer -* void* dbuffer; -* hipMalloc(&dbuffer, buffer_size); -* -* // Perform analysis step -* hipsparseDbsrsm2_analysis(handle, -* dir, -* transA, -* transX, -* mb, -* nrhs, -* nnzb, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* info, -* solve_policy, -* dbuffer); -* -* // Call dbsrsm to perform lower triangular solve LX = B -* hipsparseDbsrsm2_solve(handle, -* dir, -* transA, -* transX, -* mb, -* nrhs, -* nnzb, -* &alpha, -* descr, -* dbsr_val, -* dbsr_row_ptr, -* dbsr_col_ind, -* bsr_dim, -* info, -* dB, -* ldb, -* dX, -* ldx, -* solve_policy, -* dbuffer); -* -* // Check for zero pivots -* int pivot; -* hipsparseStatus_t status = hipsparseXbsrsm2_zeroPivot(handle, info, &pivot); -* -* if(status == HIPSPARSE_STATUS_ZERO_PIVOT) -* { -* std::cout << "Found zero pivot in matrix row " << pivot << std::endl; -* } -* -* // Copy result back to host -* hipMemcpy(hX, dX, sizeof(double) * mb * bsr_dim * nrhs, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroyBsrsm2Info(info); -* hipsparseDestroyMatDescr(descr); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dbsr_row_ptr); -* hipFree(dbsr_col_ind); -* hipFree(dbsr_val); -* hipFree(dB); -* hipFree(dX); -* hipFree(dbuffer); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrsm2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - const float* B, - int ldb, - float* X, - int ldx, - hipsparseSolvePolicy_t policy, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrsm2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - const double* B, - int ldb, - double* X, - int ldx, - hipsparseSolvePolicy_t policy, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrsm2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - const hipComplex* B, - int ldb, - hipComplex* X, - int ldx, - hipsparseSolvePolicy_t policy, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrsm2_solve(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - hipsparseOperation_t transA, - hipsparseOperation_t transX, - int mb, - int nrhs, - int nnzb, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrsm2Info_t info, - const hipDoubleComplex* B, - int ldb, - hipDoubleComplex* X, - int ldx, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using CSR storage format -* -* \details -* \p hipsparseXcsrsm2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a -* structural or numerical zero has been found during hipsparseXcsrsm2_analysis() or -* hipsparseXcsrsm2_solve() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ -* is stored in \p position, using same index base as the CSR matrix. -* -* \p position can be in host or device memory. If no zero pivot has been found, -* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. -* -* \note \p hipsparseXcsrsm2_zeroPivot is a blocking function. It might influence -* performance negatively. -*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXcsrsm2_zeroPivot(hipsparseHandle_t handle, csrsm2Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using CSR storage format -* -* \details -* \p hipsparseXcsrsm2_bufferSizeExt returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXcsrsm2_analysis() and hipsparseXcsrsm2_solve(). -* The temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsm2_bufferSizeExt(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - size_t* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsm2_bufferSizeExt(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - size_t* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsm2_bufferSizeExt(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - size_t* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsm2_bufferSizeExt(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - size_t* pBufferSizeInBytes); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using CSR storage format -* -* \details -* \p hipsparseXcsrsm2_analysis performs the analysis step for hipsparseXcsrsm2_solve(). -* -* \note -* If the matrix sparsity pattern changes, the gathered information will become invalid. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsm2_analysis(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsm2_analysis(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsm2_analysis(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsm2_analysis(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level3_module -* \brief Sparse triangular system solve using CSR storage format -* -* \details -* \p hipsparseXcsrsm2_solve solves a sparse triangular linear system of a sparse -* \f$m \times m\f$ matrix, defined in CSR storage format, a dense solution matrix -* \f$X\f$ and the right-hand side matrix \f$B\f$ that is multiplied by \f$\alpha\f$, such that -* \f[ -* op(A) \cdot op(X) = \alpha \cdot op(B), -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* , -* \f[ -* op(B) = \left\{ -* \begin{array}{ll} -* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* and -* \f[ -* op(X) = \left\{ -* \begin{array}{ll} -* X, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* X^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* X^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \p hipsparseXcsrsm2_solve requires a user allocated temporary buffer. Its size is -* returned by hipsparseXcsrsm2_bufferSizeExt(). Furthermore, analysis meta data is -* required. It can be obtained by hipsparseXcsrsm2_analysis(). -* \p hipsparseXcsrsm2_solve reports the first zero pivot (either numerical or structural -* zero). The zero pivot status can be checked calling hipsparseXcsrsm2_zeroPivot(). If -* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be -* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. -* -* \note -* The sparse CSR matrix has to be sorted. This can be achieved by calling -* hipsparseXcsrsort(). -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Currently, only \p trans_A != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and -* \p trans_B != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported. -* -* \par Example -* \code{.c} -* // hipSPARSE handle -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // A = ( 1.0 0.0 0.0 0.0 ) -* // ( 2.0 3.0 0.0 0.0 ) -* // ( 4.0 5.0 6.0 0.0 ) -* // ( 7.0 0.0 8.0 9.0 ) -* -* // Number of rows and columns -* int m = 4; -* int n = 4; -* -* // Number of right-hand-sides -* int nrhs = 4; -* -* // Number of non-zeros -* int nnz = 9; -* -* // CSR row pointers -* int hcsr_row_ptr[5] = {0, 1, 3, 6, 9}; -* -* // CSR column indices -* int hcsr_col_ind[9] = {0, 0, 1, 0, 1, 2, 0, 2, 3}; -* -* // CSR values -* double hcsr_val[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; -* -* // Transposition of the matrix and rhs matrix -* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseOperation_t transB = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* -* // Solve policy -* hipsparseSolvePolicy_t solve_policy = HIPSPARSE_SOLVE_POLICY_NO_LEVEL; -* -* // Scalar alpha and beta -* double alpha = 1.0; -* -* // rhs and solution matrix -* int ldb = n; -* -* double hB[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; -* -* // Offload data to device -* int* dcsr_row_ptr; -* int* dcsr_col_ind; -* double* dcsr_val; -* double* dB; -* -* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dcsr_val, sizeof(double) * nnz); -* hipMalloc((void**)&dB, sizeof(double) * n * nrhs); -* -* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_val, hcsr_val, sizeof(double) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dB, hB, sizeof(double) * n * nrhs, hipMemcpyHostToDevice); -* -* // Matrix descriptor -* hipsparseMatDescr_t descr; -* hipsparseCreateMatDescr(&descr); -* -* // Matrix fill mode -* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); -* -* // Matrix diagonal type -* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_NON_UNIT); -* -* // Matrix info structure -* csrsm2Info_t info; -* hipsparseCreateCsrsm2Info(&info); -* -* // Obtain required buffer size -* size_t buffer_size; -* hipsparseDcsrsm2_bufferSizeExt(handle, -* 0, -* transA, -* transB, -* m, -* nrhs, -* nnz, -* &alpha, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* dB, -* ldb, -* info, -* solve_policy, -* &buffer_size); -* -* // Allocate temporary buffer -* void* dbuffer; -* hipMalloc(&dbuffer, buffer_size); -* -* // Perform analysis step -* hipsparseDcsrsm2_analysis(handle, -* 0, -* transA, -* transB, -* m, -* nrhs, -* nnz, -* &alpha, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* dB, -* ldb, -* info, -* solve_policy, -* dbuffer); -* -* // Call dcsrsm to perform lower triangular solve LB = B -* hipsparseDcsrsm2_solve(handle, -* 0, -* transA, -* transB, -* m, -* nrhs, -* nnz, -* &alpha, -* descr, -* dcsr_val, -* dcsr_row_ptr, -* dcsr_col_ind, -* dB, -* ldb, -* info, -* solve_policy, -* dbuffer); -* -* // Check for zero pivots -* int pivot; -* hipsparseStatus_t status = hipsparseXcsrsm2_zeroPivot(handle, info, &pivot); -* -* if(status == HIPSPARSE_STATUS_ZERO_PIVOT) -* { -* std::cout << "Found zero pivot in matrix row " << pivot << std::endl; -* } -* -* // Copy result back to host -* hipMemcpy(hB, dB, sizeof(double) * m * nrhs, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroyCsrsm2Info(info); -* hipsparseDestroyMatDescr(descr); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dcsr_row_ptr); -* hipFree(dcsr_col_ind); -* hipFree(dcsr_val); -* hipFree(dB); -* hipFree(dbuffer); -* \endcode -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrsm2_solve(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const float* alpha, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - float* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrsm2_solve(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const double* alpha, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - double* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrsm2_solve(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - hipComplex* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrsm2_solve(hipsparseHandle_t handle, - int algo, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int nrhs, - int nnz, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - hipDoubleComplex* B, - int ldb, - csrsm2Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup level3_module -* \brief Dense matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXgemmi multiplies the scalar \f$\alpha\f$ with a dense \f$m \times k\f$ -* matrix \f$A\f$ and the sparse \f$k \times n\f$ matrix \f$B\f$, defined in CSR -* storage format and adds the result to the dense \f$m \times n\f$ matrix \f$C\f$ that -* is multiplied by the scalar \f$\beta\f$, such that -* \f[ -* C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* and -* \f[ -* op(B) = \left\{ -* \begin{array}{ll} -* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgemmi(hipsparseHandle_t handle, - int m, - int n, - int k, - int nnz, - const float* alpha, - const float* A, - int lda, - const float* cscValB, - const int* cscColPtrB, - const int* cscRowIndB, - const float* beta, - float* C, - int ldc); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgemmi(hipsparseHandle_t handle, - int m, - int n, - int k, - int nnz, - const double* alpha, - const double* A, - int lda, - const double* cscValB, - const int* cscColPtrB, - const int* cscRowIndB, - const double* beta, - double* C, - int ldc); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgemmi(hipsparseHandle_t handle, - int m, - int n, - int k, - int nnz, - const hipComplex* alpha, - const hipComplex* A, - int lda, - const hipComplex* cscValB, - const int* cscColPtrB, - const int* cscRowIndB, - const hipComplex* beta, - hipComplex* C, - int ldc); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgemmi(hipsparseHandle_t handle, - int m, - int n, - int k, - int nnz, - const hipDoubleComplex* alpha, - const hipDoubleComplex* A, - int lda, - const hipDoubleComplex* cscValB, - const int* cscColPtrB, - const int* cscRowIndB, - const hipDoubleComplex* beta, - hipDoubleComplex* C, - int ldc); -/**@}*/ -#endif - -/* -* =========================================================================== -* extra SPARSE -* =========================================================================== -*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix addition using CSR storage format -* -* \details -* \p hipsparseXcsrgeamNnz computes the total CSR non-zero elements and the CSR row -* offsets, that point to the start of every row of the sparse CSR matrix, of the -* resulting matrix C. It is assumed that \p csr_row_ptr_C has been allocated with -* size \p m + 1. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* \note -* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsrgeamNnz(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr); - -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix addition using CSR storage format -* -* \details -* \p hipsparseXcsrgeam multiplies the scalar \f$\alpha\f$ with the sparse -* \f$m \times n\f$ matrix \f$A\f$, defined in CSR storage format, multiplies the -* scalar \f$\beta\f$ with the sparse \f$m \times n\f$ matrix \f$B\f$, defined in CSR -* storage format, and adds both resulting matrices to obtain the sparse -* \f$m \times n\f$ matrix \f$C\f$, defined in CSR storage format, such that -* \f[ -* C := \alpha \cdot A + \beta \cdot B. -* \f] -* -* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and -* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of -* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of -* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgeamNnz(). -* -* \note Both scalars \f$\alpha\f$ and \f$beta\f$ have to be valid. -* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -* \note This function is non blocking and executed asynchronously with respect to the -* host. It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrgeam(hipsparseHandle_t handle, - int m, - int n, - const float* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const float* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - float* csrValC, - int* csrRowPtrC, - int* csrColIndC); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrgeam(hipsparseHandle_t handle, - int m, - int n, - const double* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const double* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - double* csrValC, - int* csrRowPtrC, - int* csrColIndC); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrgeam(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipComplex* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipComplex* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - hipComplex* csrValC, - int* csrRowPtrC, - int* csrColIndC); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrgeam(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipDoubleComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipDoubleComplex* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipDoubleComplex* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* csrValC, - int* csrRowPtrC, - int* csrColIndC); -/**@}*/ -#endif - -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrgeam2_bufferSizeExt returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXcsrgeam2Nnz() and hipsparseXcsrgeam2(). The -* temporary storage buffer must be allocated by the user. -* -* \note -* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrgeam2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const float* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const float* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - const float* csrSortedValC, - const int* csrSortedRowPtrC, - const int* csrSortedColIndC, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrgeam2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const double* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const double* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - const double* csrSortedValC, - const int* csrSortedRowPtrC, - const int* csrSortedColIndC, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrgeam2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipComplex* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - const hipComplex* csrSortedValC, - const int* csrSortedRowPtrC, - const int* csrSortedColIndC, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrgeam2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipDoubleComplex* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - const hipDoubleComplex* csrSortedValC, - const int* csrSortedRowPtrC, - const int* csrSortedColIndC, - size_t* pBufferSizeInBytes); -/**@}*/ - -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix addition using CSR storage format -* -* \details -* \p hipsparseXcsrgeam2Nnz computes the total CSR non-zero elements and the CSR row -* offsets, that point to the start of every row of the sparse CSR matrix, of the -* resulting matrix C. It is assumed that \p csr_row_ptr_C has been allocated with -* size \p m + 1. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* \note -* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsrgeam2Nnz(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - int* csrSortedRowPtrC, - int* nnzTotalDevHostPtr, - void* workspace); - -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix addition using CSR storage format -* -* \details -* \p hipsparseXcsrgeam2 multiplies the scalar \f$\alpha\f$ with the sparse -* \f$m \times n\f$ matrix \f$A\f$, defined in CSR storage format, multiplies the -* scalar \f$\beta\f$ with the sparse \f$m \times n\f$ matrix \f$B\f$, defined in CSR -* storage format, and adds both resulting matrices to obtain the sparse -* \f$m \times n\f$ matrix \f$C\f$, defined in CSR storage format, such that -* \f[ -* C := \alpha \cdot A + \beta \cdot B. -* \f] -* -* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and -* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of -* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of -* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgeam2Nnz(). -* -* \note Both scalars \f$\alpha\f$ and \f$beta\f$ have to be valid. -* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -* \note This function is non blocking and executed asynchronously with respect to the -* host. It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrgeam2(hipsparseHandle_t handle, - int m, - int n, - const float* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const float* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const float* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - float* csrSortedValC, - int* csrSortedRowPtrC, - int* csrSortedColIndC, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrgeam2(hipsparseHandle_t handle, - int m, - int n, - const double* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const double* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const double* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - double* csrSortedValC, - int* csrSortedRowPtrC, - int* csrSortedColIndC, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrgeam2(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipComplex* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipComplex* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - hipComplex* csrSortedValC, - int* csrSortedRowPtrC, - int* csrSortedColIndC, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrgeam2(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - const hipDoubleComplex* beta, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipDoubleComplex* csrSortedValB, - const int* csrSortedRowPtrB, - const int* csrSortedColIndB, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* csrSortedValC, - int* csrSortedRowPtrC, - int* csrSortedColIndC, - void* pBuffer); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrgemmNnz computes the total CSR non-zero elements and the CSR row -* offsets, that point to the start of every row of the sparse CSR matrix, of the -* resulting multiplied matrix C. It is assumed that \p csr_row_ptr_C has been allocated -* with size \p m + 1. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Please note, that for matrix products with more than 8192 intermediate products per -* row, additional temporary storage buffer is allocated by the algorithm. -* -* \note -* Currently, only \p trans_A == \p trans_B == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is -* supported. -* -* \note -* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsrgemmNnz(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr); - -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrgemm multiplies the sparse \f$m \times k\f$ matrix \f$A\f$, defined in -* CSR storage format with the sparse \f$k \times n\f$ matrix \f$B\f$, defined in CSR -* storage format, and stores the result in the sparse \f$m \times n\f$ matrix \f$C\f$, -* defined in CSR storage format, such that -* \f[ -* C := op(A) \cdot op(B), -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* and -* \f[ -* op(B) = \left\{ -* \begin{array}{ll} -* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* -* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and -* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of -* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of -* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgemmNnz(). -* -* \note Currently, only \p trans_A == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. -* \note Currently, only \p trans_B == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. -* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -* \note This function is non blocking and executed asynchronously with respect to the -* host. It may return before the actual computation has finished. -* \note Please note, that for matrix products with more than 4096 non-zero entries per -* row, additional temporary storage buffer is allocated by the algorithm. -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrgemm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - const hipsparseMatDescr_t descrA, - int nnzA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const float* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - float* csrValC, - const int* csrRowPtrC, - int* csrColIndC); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrgemm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - const hipsparseMatDescr_t descrA, - int nnzA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const double* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - double* csrValC, - const int* csrRowPtrC, - int* csrColIndC); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrgemm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipComplex* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - hipComplex* csrValC, - const int* csrRowPtrC, - int* csrColIndC); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrgemm(hipsparseHandle_t handle, - hipsparseOperation_t transA, - hipsparseOperation_t transB, - int m, - int n, - int k, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipDoubleComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipDoubleComplex* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* csrValC, - const int* csrRowPtrC, - int* csrColIndC); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrgemm2_bufferSizeExt returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXcsrgemm2Nnz() and hipsparseXcsrgemm2(). The -* temporary storage buffer must be allocated by the user. -* -* \note -* Please note, that for matrix products with more than 4096 non-zero entries per row, -* additional temporary storage buffer is allocated by the algorithm. -* -* \note -* Please note, that for matrix products with more than 8192 intermediate products per -* row, additional temporary storage buffer is allocated by the algorithm. -* -* \note -* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrgemm2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int k, - const float* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const float* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const int* csrRowPtrD, - const int* csrColIndD, - csrgemm2Info_t info, - size_t* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrgemm2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int k, - const double* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const double* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const int* csrRowPtrD, - const int* csrColIndD, - csrgemm2Info_t info, - size_t* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrgemm2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int k, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipComplex* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const int* csrRowPtrD, - const int* csrColIndD, - csrgemm2Info_t info, - size_t* pBufferSizeInBytes); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrgemm2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int k, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipDoubleComplex* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const int* csrRowPtrD, - const int* csrColIndD, - csrgemm2Info_t info, - size_t* pBufferSizeInBytes); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrgemm2Nnz computes the total CSR non-zero elements and the CSR row -* offsets, that point to the start of every row of the sparse CSR matrix, of the -* resulting multiplied matrix C. It is assumed that \p csr_row_ptr_C has been allocated -* with size \p m + 1. -* The required buffer size can be obtained by hipsparseXcsrgemm2_bufferSizeExt(). -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -* -* \note -* Please note, that for matrix products with more than 8192 intermediate products per -* row, additional temporary storage buffer is allocated by the algorithm. -* -* \note -* Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsrgemm2Nnz(hipsparseHandle_t handle, - int m, - int n, - int k, - const hipsparseMatDescr_t descrA, - int nnzA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipsparseMatDescr_t descrD, - int nnzD, - const int* csrRowPtrD, - const int* csrColIndD, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr, - const csrgemm2Info_t info, - void* pBuffer); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup extra_module -* \brief Sparse matrix sparse matrix multiplication using CSR storage format -* -* \details -* \p hipsparseXcsrgemm2 multiplies the scalar \f$\alpha\f$ with the sparse -* \f$m \times k\f$ matrix \f$A\f$, defined in CSR storage format, and the sparse -* \f$k \times n\f$ matrix \f$B\f$, defined in CSR storage format, and adds the result -* to the sparse \f$m \times n\f$ matrix \f$D\f$ that is multiplied by \f$\beta\f$. The -* final result is stored in the sparse \f$m \times n\f$ matrix \f$C\f$, defined in CSR -* storage format, such -* that -* \f[ -* C := \alpha \cdot A \cdot B + \beta \cdot D -* \f] -* -* It is assumed that \p csr_row_ptr_C has already been filled and that \p csr_val_C and -* \p csr_col_ind_C are allocated by the user. \p csr_row_ptr_C and allocation size of -* \p csr_col_ind_C and \p csr_val_C is defined by the number of non-zero elements of -* the sparse CSR matrix C. Both can be obtained by hipsparseXcsrgemm2Nnz(). The -* required buffer size for the computation can be obtained by -* hipsparseXcsrgemm2_bufferSizeExt(). -* -* \note If \f$\alpha == 0\f$, then \f$C = \beta \cdot D\f$ will be computed. -* \note If \f$\beta == 0\f$, then \f$C = \alpha \cdot A \cdot B\f$ will be computed. -* \note \f$\alpha == beta == 0\f$ is invalid. -* \note Currently, only \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported. -* \note This function is non blocking and executed asynchronously with respect to the -* host. It may return before the actual computation has finished. -* \note Please note, that for matrix products with more than 4096 non-zero entries per -* row, additional temporary storage buffer is allocated by the algorithm. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrgemm2(hipsparseHandle_t handle, - int m, - int n, - int k, - const float* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const float* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const float* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const float* csrValD, - const int* csrRowPtrD, - const int* csrColIndD, - const hipsparseMatDescr_t descrC, - float* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - const csrgemm2Info_t info, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrgemm2(hipsparseHandle_t handle, - int m, - int n, - int k, - const double* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const double* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const double* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const double* csrValD, - const int* csrRowPtrD, - const int* csrColIndD, - const hipsparseMatDescr_t descrC, - double* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - const csrgemm2Info_t info, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrgemm2(hipsparseHandle_t handle, - int m, - int n, - int k, - const hipComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipComplex* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipComplex* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const hipComplex* csrValD, - const int* csrRowPtrD, - const int* csrColIndD, - const hipsparseMatDescr_t descrC, - hipComplex* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - const csrgemm2Info_t info, - void* pBuffer); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrgemm2(hipsparseHandle_t handle, - int m, - int n, - int k, - const hipDoubleComplex* alpha, - const hipsparseMatDescr_t descrA, - int nnzA, - const hipDoubleComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const hipsparseMatDescr_t descrB, - int nnzB, - const hipDoubleComplex* csrValB, - const int* csrRowPtrB, - const int* csrColIndB, - const hipDoubleComplex* beta, - const hipsparseMatDescr_t descrD, - int nnzD, - const hipDoubleComplex* csrValD, - const int* csrRowPtrD, - const int* csrColIndD, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - const csrgemm2Info_t info, - void* pBuffer); -/**@}*/ -#endif - -/* -* =========================================================================== -* preconditioner SPARSE -* =========================================================================== -*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage - * format - * - * \details - * \p hipsparseXbsrilu02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a - * structural or numerical zero has been found during hipsparseXbsrilu02_analysis() or - * hipsparseXbsrilu02() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is - * stored in \p position, using same index base as the BSR matrix. - * - * \p position can be in host or device memory. If no zero pivot has been found, - * \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. - * - * \note - * If a zero pivot is found, \p position \f$=j\f$ means that either the diagonal block - * \f$A_{j,j}\f$ is missing (structural zero) or the diagonal block \f$A_{j,j}\f$ is not - * invertible (numerical zero). - * - * \note \p hipsparseXbsrilu02_zeroPivot is a blocking function. It might influence - * performance negatively. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXbsrilu02_zeroPivot(hipsparseHandle_t handle, bsrilu02Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage - * format - * - * \details - * \p hipsparseXbsrilu02_numericBoost enables the user to replace a numerical value in - * an incomplete LU factorization. \p tol is used to determine whether a numerical value - * is replaced by \p boost_val, such that \f$A_{j,j} = \text{boost_val}\f$ if - * \f$\text{tol} \ge \left|A_{j,j}\right|\f$. - * - * \note The boost value is enabled by setting \p enable_boost to 1 or disabled by - * setting \p enable_boost to 0. - * - * \note \p tol and \p boost_val can be in host or device memory. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrilu02_numericBoost( - hipsparseHandle_t handle, bsrilu02Info_t info, int enable_boost, double* tol, float* boost_val); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrilu02_numericBoost(hipsparseHandle_t handle, - bsrilu02Info_t info, - int enable_boost, - double* tol, - double* boost_val); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrilu02_numericBoost(hipsparseHandle_t handle, - bsrilu02Info_t info, - int enable_boost, - double* tol, - hipComplex* boost_val); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrilu02_numericBoost(hipsparseHandle_t handle, - bsrilu02Info_t info, - int enable_boost, - double* tol, - hipDoubleComplex* boost_val); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage - * format - * - * \details - * \p hipsparseXbsrilu02_bufferSize returns the size of the temporary storage buffer - * in bytes that is required by hipsparseXbsrilu02_analysis() and hipsparseXbsrilu02(). - * The temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrilu02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrilu02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrilu02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrilu02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage - * format - * - * \details - * \p hipsparseXbsrilu02_analysis performs the analysis step for hipsparseXbsrilu02(). - * - * \note - * If the matrix sparsity pattern changes, the gathered information will become invalid. - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrilu02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrilu02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrilu02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrilu02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrSortedValA, - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage - * format - * - * \details - * \p hipsparseXbsrilu02 computes the incomplete LU factorization with 0 fill-ins and no - * pivoting of a sparse \f$mb \times mb\f$ BSR matrix \f$A\f$, such that - * \f[ - * A \approx LU - * \f] - * - * \p hipsparseXbsrilu02 requires a user allocated temporary buffer. Its size is - * returned by hipsparseXbsrilu02_bufferSize(). Furthermore, analysis meta data is - * required. It can be obtained by hipsparseXbsrilu02_analysis(). \p hipsparseXbsrilu02 - * reports the first zero pivot (either numerical or structural zero). The zero pivot - * status can be obtained by calling hipsparseXbsrilu02_zeroPivot(). - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsrilu02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsrilu02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsrilu02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsrilu02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* bsrSortedRowPtrA, - const int* bsrSortedColIndA, - int blockDim, - bsrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsrilu02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a -* structural or numerical zero has been found during hipsparseXcsrilu02() computation. -* The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is stored in \p position, using same -* index base as the CSR matrix. -* -* \p position can be in host or device memory. If no zero pivot has been found, -* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. -* -* \note \p hipsparseXcsrilu02_zeroPivot is a blocking function. It might influence -* performance negatively. -*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXcsrilu02_zeroPivot(hipsparseHandle_t handle, csrilu02Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR storage - * format - * - * \details - * \p hipsparseXcsrilu02_numericBoost enables the user to replace a numerical value in - * an incomplete LU factorization. \p tol is used to determine whether a numerical value - * is replaced by \p boost_val, such that \f$A_{j,j} = \text{boost_val}\f$ if - * \f$\text{tol} \ge \left|A_{j,j}\right|\f$. - * - * \note The boost value is enabled by setting \p enable_boost to 1 or disabled by - * setting \p enable_boost to 0. - * - * \note \p tol and \p boost_val can be in host or device memory. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrilu02_numericBoost( - hipsparseHandle_t handle, csrilu02Info_t info, int enable_boost, double* tol, float* boost_val); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrilu02_numericBoost(hipsparseHandle_t handle, - csrilu02Info_t info, - int enable_boost, - double* tol, - double* boost_val); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrilu02_numericBoost(hipsparseHandle_t handle, - csrilu02Info_t info, - int enable_boost, - double* tol, - hipComplex* boost_val); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrilu02_numericBoost(hipsparseHandle_t handle, - csrilu02Info_t info, - int enable_boost, - double* tol, - hipDoubleComplex* boost_val); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsrilu02_bufferSize returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXcsrilu02_analysis() and hipsparseXcsrilu02_solve(). -* The temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrilu02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrilu02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrilu02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrilu02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -/*! \ingroup precond_module -* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsrilu02_bufferSizeExt returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXcsrilu02_analysis() and hipsparseXcsrilu02_solve(). -* The temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrilu02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrilu02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrilu02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrilu02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - size_t* pBufferSizeInBytes); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsrilu02_analysis performs the analysis step for hipsparseXcsrilu02(). -* -* \note -* If the matrix sparsity pattern changes, the gathered information will become invalid. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrilu02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrilu02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrilu02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrilu02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsrilu02 computes the incomplete LU factorization with 0 fill-ins and no -* pivoting of a sparse \f$m \times m\f$ CSR matrix \f$A\f$, such that -* \f[ -* A \approx LU -* \f] -* -* \p hipsparseXcsrilu02 requires a user allocated temporary buffer. Its size is returned -* by hipsparseXcsrilu02_bufferSize() or hipsparseXcsrilu02_bufferSizeExt(). Furthermore, -* analysis meta data is required. It can be obtained by hipsparseXcsrilu02_analysis(). -* \p hipsparseXcsrilu02 reports the first zero pivot (either numerical or structural -* zero). The zero pivot status can be obtained by calling hipsparseXcsrilu02_zeroPivot(). -* -* \note -* The sparse CSR matrix has to be sorted. This can be achieved by calling -* hipsparseXcsrsort(). -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrilu02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrilu02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrilu02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrilu02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csrilu02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR - * storage format - * - * \details - * \p hipsparseXbsric02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a - * structural or numerical zero has been found during hipsparseXbsric02_analysis() or - * hipsparseXbsric02() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is - * stored in \p position, using same index base as the BSR matrix. - * - * \p position can be in host or device memory. If no zero pivot has been found, - * \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. - * - * \note - * If a zero pivot is found, \p position=j means that either the diagonal block \p A(j,j) - * is missing (structural zero) or the diagonal block \p A(j,j) is not positive definite - * (numerical zero). - * - * \note \p hipsparseXbsric02_zeroPivot is a blocking function. It might influence - * performance negatively. - */ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXbsric02_zeroPivot(hipsparseHandle_t handle, bsric02Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR - * storage format - * - * \details - * \p hipsparseXbsric02_bufferSize returns the size of the temporary storage buffer - * in bytes that is required by hipsparseXbsric02_analysis() and hipsparseXbsric02(). - * The temporary storage buffer must be allocated by the user. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsric02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsric02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsric02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsric02_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR - * storage format - * - * \details - * \p hipsparseXbsric02_analysis performs the analysis step for hipsparseXbsric02(). - * - * \note - * If the matrix sparsity pattern changes, the gathered information will become invalid. - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsric02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsric02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsric02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsric02_analysis(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module - * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR - * storage format - * - * \details - * \p hipsparseXbsric02 computes the incomplete Cholesky factorization with 0 fill-ins - * and no pivoting of a sparse \f$mb \times mb\f$ BSR matrix \f$A\f$, such that - * \f[ - * A \approx LL^T - * \f] - * - * \p hipsparseXbsric02 requires a user allocated temporary buffer. Its size is returned - * by hipsparseXbsric02_bufferSize(). Furthermore, analysis meta data is required. It - * can be obtained by hipsparseXbsric02_analysis(). \p hipsparseXbsric02 reports the - * first zero pivot (either numerical or structural zero). The zero pivot status can be - * obtained by calling hipsparseXbsric02_zeroPivot(). - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsric02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsric02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsric02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsric02(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nnzb, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - bsric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsric02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a -* structural or numerical zero has been found during hipsparseXcsric02_analysis() or -* hipsparseXcsric02() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ -* is stored in \p position, using same index base as the CSR matrix. -* -* \p position can be in host or device memory. If no zero pivot has been found, -* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. -* -* \note \p hipsparseXcsric02_zeroPivot is a blocking function. It might influence -* performance negatively. -*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseXcsric02_zeroPivot(hipsparseHandle_t handle, csric02Info_t info, int* position); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsric02_bufferSize returns the size of the temporary storage buffer in bytes -* that is required by hipsparseXcsric02_analysis() and hipsparseXcsric02(). -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsric02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsric02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsric02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - int* pBufferSizeInBytes); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsric02_bufferSize(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - int* pBufferSizeInBytes); -/**@}*/ -#endif - -/*! \ingroup precond_module -* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsric02_bufferSizeExt returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXcsric02_analysis() and hipsparseXcsric02(). -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsric02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsric02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsric02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - size_t* pBufferSizeInBytes); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsric02_bufferSizeExt(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - size_t* pBufferSizeInBytes); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsric02_analysis performs the analysis step for hipsparseXcsric02(). -* -* \note -* If the matrix sparsity pattern changes, the gathered information will become invalid. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsric02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsric02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsric02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsric02_analysis(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup precond_module -* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR -* storage format -* -* \details -* \p hipsparseXcsric02 computes the incomplete Cholesky factorization with 0 fill-ins -* and no pivoting of a sparse \f$m \times m\f$ CSR matrix \f$A\f$, such that -* \f[ -* A \approx LL^T -* \f] -* -* \p hipsparseXcsric02 requires a user allocated temporary buffer. Its size is returned -* by hipsparseXcsric02_bufferSize() or hipsparseXcsric02_bufferSizeExt(). Furthermore, -* analysis meta data is required. It can be obtained by hipsparseXcsric02_analysis(). -* \p hipsparseXcsric02 reports the first zero pivot (either numerical or structural -* zero). The zero pivot status can be obtained by calling hipsparseXcsric02_zeroPivot(). -* -* \note -* The sparse CSR matrix has to be sorted. This can be achieved by calling -* hipsparseXcsrsort(). -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsric02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsric02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsric02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsric02(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrSortedValA_valM, - /* matrix A values are updated inplace - to be the preconditioner M values */ - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - csric02Info_t info, - hipsparseSolvePolicy_t policy, - void* pBuffer); -/**@}*/ -#endif - -/*! \ingroup precond_module -* \brief Tridiagonal solver with pivoting -* -* \details -* \p hipsparseXgtsv2_bufferSize returns the size of the temporary storage buffer -* in bytes that is required by hipsparseXgtsv2(). The temporary storage buffer must -* be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsv2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const float* dl, - const float* d, - const float* du, - const float* B, - int ldb, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsv2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const double* dl, - const double* d, - const double* du, - const double* B, - int db, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsv2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - const hipComplex* B, - int ldb, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsv2_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - const hipDoubleComplex* B, - int ldb, - size_t* pBufferSizeInBytes); -/**@}*/ - -/*! \ingroup precond_module -* \brief Tridiagonal solver with pivoting -* -* \details -* \p hipsparseXgtsv2 solves a tridiagonal system for multiple right hand sides using pivoting. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsv2(hipsparseHandle_t handle, - int m, - int n, - const float* dl, - const float* d, - const float* du, - float* B, - int ldb, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsv2(hipsparseHandle_t handle, - int m, - int n, - const double* dl, - const double* d, - const double* du, - double* B, - int ldb, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsv2(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - hipComplex* B, - int ldb, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsv2(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - hipDoubleComplex* B, - int ldb, - void* pBuffer); -/**@}*/ - -/*! \ingroup precond_module -* \brief Tridiagonal solver (no pivoting) -* -* \details -* \p hipsparseXgtsv2_nopivot_bufferSizeExt returns the size of the temporary storage -* buffer in bytes that is required by hipsparseXgtsv2_nopivot(). The temporary storage -* buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const float* dl, - const float* d, - const float* du, - const float* B, - int ldb, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const double* dl, - const double* d, - const double* du, - const double* B, - int db, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - const hipComplex* B, - int ldb, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - const hipDoubleComplex* B, - int ldb, - size_t* pBufferSizeInBytes); -/**@}*/ - -/*! \ingroup precond_module -* \brief Tridiagonal solver (no pivoting) -* -* \details -* \p hipsparseXgtsv2_nopivot solves a tridiagonal linear system for multiple right-hand sides -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsv2_nopivot(hipsparseHandle_t handle, - int m, - int n, - const float* dl, - const float* d, - const float* du, - float* B, - int ldb, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsv2_nopivot(hipsparseHandle_t handle, - int m, - int n, - const double* dl, - const double* d, - const double* du, - double* B, - int ldb, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsv2_nopivot(hipsparseHandle_t handle, - int m, - int n, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - hipComplex* B, - int ldb, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsv2_nopivot(hipsparseHandle_t handle, - int m, - int n, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - hipDoubleComplex* B, - int ldb, - void* pBuffer); -/**@}*/ - -/*! \ingroup precond_module -* \brief Strided Batch tridiagonal solver (no pivoting) -* -* \details -* \p hipsparseXgtsv2StridedBatch_bufferSizeExt returns the size of the temporary storage -* buffer in bytes that is required by hipsparseXgtsv2StridedBatch(). The temporary -* storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, - int m, - const float* dl, - const float* d, - const float* du, - const float* x, - int batchCount, - int batchStride, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, - int m, - const double* dl, - const double* d, - const double* du, - const double* x, - int batchCount, - int batchStride, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, - int m, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - const hipComplex* x, - int batchCount, - int batchStride, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, - int m, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - const hipDoubleComplex* x, - int batchCount, - int batchStride, - size_t* pBufferSizeInBytes); -/**@}*/ - -/*! \ingroup precond_module -* \brief Strided Batch tridiagonal solver (no pivoting) -* -* \details -* \p hipsparseXgtsv2StridedBatch solves a batched tridiagonal linear system -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsv2StridedBatch(hipsparseHandle_t handle, - int m, - const float* dl, - const float* d, - const float* du, - float* x, - int batchCount, - int batchStride, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsv2StridedBatch(hipsparseHandle_t handle, - int m, - const double* dl, - const double* d, - const double* du, - double* x, - int batchCount, - int batchStride, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsv2StridedBatch(hipsparseHandle_t handle, - int m, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - hipComplex* x, - int batchCount, - int batchStride, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsv2StridedBatch(hipsparseHandle_t handle, - int m, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - hipDoubleComplex* x, - int batchCount, - int batchStride, - void* pBuffer); -/**@}*/ - -/*! \ingroup precond_module -* \brief Interleaved Batch tridiagonal solver -* -* \details -* \p hipsparseXgtsvInterleavedBatch_bufferSizeExt returns the size of the temporary storage -* buffer in bytes that is required by hipsparseXgtsvInterleavedBatch(). The temporary storage -* buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const float* dl, - const float* d, - const float* du, - const float* x, - int batchCount, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const double* dl, - const double* d, - const double* du, - const double* x, - int batchCount, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - const hipComplex* x, - int batchCount, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - const hipDoubleComplex* x, - int batchCount, - size_t* pBufferSizeInBytes); -/**@}*/ - -/*! \ingroup precond_module -* \brief Interleaved Batch tridiagonal solver -* -* \details -* \p hipsparseXgtsvInterleavedBatch solves a batched tridiagonal linear system -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgtsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - float* dl, - float* d, - float* du, - float* x, - int batchCount, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgtsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - double* dl, - double* d, - double* du, - double* x, - int batchCount, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgtsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - hipComplex* dl, - hipComplex* d, - hipComplex* du, - hipComplex* x, - int batchCount, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgtsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - hipDoubleComplex* dl, - hipDoubleComplex* d, - hipDoubleComplex* du, - hipDoubleComplex* x, - int batchCount, - void* pBuffer); -/**@}*/ - -/*! \ingroup precond_module -* \brief Interleaved Batch pentadiagonal solver -* -* \details -* \p hipsparseXgpsvInterleavedBatch_bufferSizeExt returns the size of the temporary storage -* buffer in bytes that is required by hipsparseXgpsvInterleavedBatch(). The temporary -* storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const float* ds, - const float* dl, - const float* d, - const float* du, - const float* dw, - const float* x, - int batchCount, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const double* ds, - const double* dl, - const double* d, - const double* du, - const double* dw, - const double* x, - int batchCount, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const hipComplex* ds, - const hipComplex* dl, - const hipComplex* d, - const hipComplex* du, - const hipComplex* dw, - const hipComplex* x, - int batchCount, - size_t* pBufferSizeInBytes); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, - int algo, - int m, - const hipDoubleComplex* ds, - const hipDoubleComplex* dl, - const hipDoubleComplex* d, - const hipDoubleComplex* du, - const hipDoubleComplex* dw, - const hipDoubleComplex* x, - int batchCount, - size_t* pBufferSizeInBytes); - -/**@}*/ - -/*! \ingroup precond_module -* \brief Interleaved Batch pentadiagonal solver -* -* \details -* \p hipsparseXgpsvInterleavedBatch solves a batched pentadiagonal linear system -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgpsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - float* ds, - float* dl, - float* d, - float* du, - float* dw, - float* x, - int batchCount, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgpsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - double* ds, - double* dl, - double* d, - double* du, - double* dw, - double* x, - int batchCount, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgpsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - hipComplex* ds, - hipComplex* dl, - hipComplex* d, - hipComplex* du, - hipComplex* dw, - hipComplex* x, - int batchCount, - void* pBuffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgpsvInterleavedBatch(hipsparseHandle_t handle, - int algo, - int m, - hipDoubleComplex* ds, - hipDoubleComplex* dl, - hipDoubleComplex* d, - hipDoubleComplex* du, - hipDoubleComplex* dw, - hipDoubleComplex* x, - int batchCount, - void* pBuffer); - -/**@}*/ - -/* -* =========================================================================== -* Sparse Format Conversions -* =========================================================================== -*/ - -/*! \ingroup conv_module -* \brief -* This function computes the number of nonzero elements per row or column and the total -* number of nonzero elements in a dense matrix. -* -* \details -* The routine does support asynchronous execution if the pointer mode is set to device. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSnnz(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const float* A, - int lda, - int* nnzPerRowColumn, - int* nnzTotalDevHostPtr); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnnz(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const double* A, - int lda, - int* nnzPerRowColumn, - int* nnzTotalDevHostPtr); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCnnz(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipComplex* A, - int lda, - int* nnzPerRowColumn, - int* nnzTotalDevHostPtr); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZnnz(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* A, - int lda, - int* nnzPerRowColumn, - int* nnzTotalDevHostPtr); -/**@}*/ - -/*! \ingroup conv_module -* \brief -* This function converts the matrix A in dense format into a sparse matrix in CSR format. -* All the parameters are assumed to have been pre-allocated by the user and the arrays -* are filled in based on nnz_per_row, which can be pre-computed with hipsparseXnnz(). -* It is executed asynchronously with respect to the host and may return control to the -* application on the host before the entire result is ready. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSdense2csr(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const float* A, - int ld, - const int* nnz_per_rows, - float* csr_val, - int* csr_row_ptr, - int* csr_col_ind); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDdense2csr(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const double* A, - int ld, - const int* nnz_per_rows, - double* csr_val, - int* csr_row_ptr, - int* csr_col_ind); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCdense2csr(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipComplex* A, - int ld, - const int* nnz_per_rows, - hipComplex* csr_val, - int* csr_row_ptr, - int* csr_col_ind); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZdense2csr(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipDoubleComplex* A, - int ld, - const int* nnz_per_rows, - hipDoubleComplex* csr_val, - int* csr_row_ptr, - int* csr_col_ind); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function computes the the size of the user allocated temporary storage buffer used when converting and pruning -* a dense matrix to a CSR matrix. -* -* \details -* \p hipsparseXpruneDense2csr_bufferSizeExt returns the size of the temporary storage buffer -* that is required by hipsparseXpruneDense2csrNnz() and hipsparseXpruneDense2csr(). The -* temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csr_bufferSize(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - const float* threshold, - const hipsparseMatDescr_t descr, - const float* csrVal, - const int* csrRowPtr, - const int* csrColInd, - size_t* bufferSize); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csr_bufferSize(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - const double* threshold, - const hipsparseMatDescr_t descr, - const double* csrVal, - const int* csrRowPtr, - const int* csrColInd, - size_t* bufferSize); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - const float* threshold, - const hipsparseMatDescr_t descr, - const float* csrVal, - const int* csrRowPtr, - const int* csrColInd, - size_t* bufferSize); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - const double* threshold, - const hipsparseMatDescr_t descr, - const double* csrVal, - const int* csrRowPtr, - const int* csrColInd, - size_t* bufferSize); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function computes the number of nonzero elements per row and the total number of -* nonzero elements in a dense matrix once elements less than the threshold are pruned -* from the matrix. -* -* \details -* The routine does support asynchronous execution if the pointer mode is set to device. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csrNnz(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - const float* threshold, - const hipsparseMatDescr_t descr, - int* csrRowPtr, - int* nnzTotalDevHostPtr, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csrNnz(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - const double* threshold, - const hipsparseMatDescr_t descr, - int* csrRowPtr, - int* nnzTotalDevHostPtr, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function converts the matrix A in dense format into a sparse matrix in CSR format -* while pruning values that are less than the threshold. All the parameters are assumed -* to have been pre-allocated by the user. -* -* \details -* The user first allocates \p csrRowPtr to have \p m+1 elements and then calls -* hipsparseXpruneDense2csrNnz() which fills in the \p csrRowPtr array and stores the -* number of elements that are larger than the pruning threshold in \p nnzTotalDevHostPtr. -* The user then allocates \p csrColInd and \p csrVal to have size \p nnzTotalDevHostPtr -* and completes the conversion by calling hipsparseXpruneDense2csr(). A temporary storage -* buffer is used by both hipsparseXpruneDense2csrNnz() and hipsparseXpruneDense2csr() and -* must be allocated by the user and whose size is determined by -* hipsparseXpruneDense2csr_bufferSizeExt(). The routine hipsparseXpruneDense2csr() is -* executed asynchronously with respect to the host and may return control to the -* application on the host before the entire result is ready. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csr(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - const float* threshold, - const hipsparseMatDescr_t descr, - float* csrVal, - const int* csrRowPtr, - int* csrColInd, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csr(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - const double* threshold, - const hipsparseMatDescr_t descr, - double* csrVal, - const int* csrRowPtr, - int* csrColInd, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function computes the size of the user allocated temporary storage buffer used -* when converting and pruning by percentage a dense matrix to a CSR matrix. -* -* \details -* When converting and pruning a dense matrix A to a CSR matrix by percentage the -* following steps are performed. First the user calls -* \p hipsparseXpruneDense2csrByPercentage_bufferSize which determines the size of the -* temporary storage buffer. Once determined, this buffer must be allocated by the user. -* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls -* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion -* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value -* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. -* -* The pruning by percentage works by first sorting the absolute values of the dense -* matrix \p A. We then determine a position in this sorted array by -* \f[ -* pos = ceil(m*n*(percentage/100)) - 1 -* pos = min(pos, m*n-1) -* pos = max(pos, 0) -* threshold = sorted_A[pos] -* \f] -* Once we have this threshold we prune values in the dense matrix \p A as in -* \p hipsparseXpruneDense2csr. It is executed asynchronously with respect to the host -* and may return control to the application on the host before the entire result is -* ready. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csrByPercentage_bufferSize(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - float percentage, - const hipsparseMatDescr_t descr, - const float* csrVal, - const int* csrRowPtr, - const int* csrColInd, - pruneInfo_t info, - size_t* bufferSize); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csrByPercentage_bufferSize(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - double percentage, - const hipsparseMatDescr_t descr, - const double* csrVal, - const int* csrRowPtr, - const int* csrColInd, - pruneInfo_t info, - size_t* bufferSize); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function computes the size of the user allocated temporary storage buffer used -* when converting and pruning by percentage a dense matrix to a CSR matrix. -* -* \details -* When converting and pruning a dense matrix A to a CSR matrix by percentage the -* following steps are performed. First the user calls -* \p hipsparseXpruneDense2csrByPercentage_bufferSizeExt which determines the size of the -* temporary storage buffer. Once determined, this buffer must be allocated by the user. -* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls -* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion -* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value -* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. -* -* The pruning by percentage works by first sorting the absolute values of the dense -* matrix \p A. We then determine a position in this sorted array by -* \f[ -* pos = ceil(m*n*(percentage/100)) - 1 -* pos = min(pos, m*n-1) -* pos = max(pos, 0) -* threshold = sorted_A[pos] -* \f] -* Once we have this threshold we prune values in the dense matrix \p A as in -* \p hipsparseXpruneDense2csr. It is executed asynchronously with respect to the host -* and may return control to the application on the host before the entire result is -* ready. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseSpruneDense2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - float percentage, - const hipsparseMatDescr_t descr, - const float* csrVal, - const int* csrRowPtr, - const int* csrColInd, - pruneInfo_t info, - size_t* bufferSize); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t - hipsparseDpruneDense2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - double percentage, - const hipsparseMatDescr_t descr, - const double* csrVal, - const int* csrRowPtr, - const int* csrColInd, - pruneInfo_t info, - size_t* bufferSize); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function computes the number of nonzero elements per row and the total number of -* nonzero elements in a dense matrix when converting and pruning by percentage a dense -* matrix to a CSR matrix. -* -* \details -* When converting and pruning a dense matrix A to a CSR matrix by percentage the -* following steps are performed. First the user calls -* \p hipsparseXpruneDense2csrByPercentage_bufferSize which determines the size of the -* temporary storage buffer. Once determined, this buffer must be allocated by the user. -* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls -* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion -* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value -* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. -* -* The pruning by percentage works by first sorting the absolute values of the dense -* matrix \p A. We then determine a position in this sorted array by -* \f[ -* pos = ceil(m*n*(percentage/100)) - 1 -* pos = min(pos, m*n-1) -* pos = max(pos, 0) -* threshold = sorted_A[pos] -* \f] -* Once we have this threshold we prune values in the dense matrix \p A as in -* \p hipsparseXpruneDense2csr. The routine does support asynchronous execution if the -* pointer mode is set to device. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csrNnzByPercentage(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - float percentage, - const hipsparseMatDescr_t descr, - int* csrRowPtr, - int* nnzTotalDevHostPtr, - pruneInfo_t info, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csrNnzByPercentage(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - double percentage, - const hipsparseMatDescr_t descr, - int* csrRowPtr, - int* nnzTotalDevHostPtr, - pruneInfo_t info, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function computes the number of nonzero elements per row and the total number of -* nonzero elements in a dense matrix when converting and pruning by percentage a dense -* matrix to a CSR matrix. -* -* \details -* When converting and pruning a dense matrix A to a CSR matrix by percentage the -* following steps are performed. First the user calls -* \p hipsparseXpruneDense2csrByPercentage_bufferSize which determines the size of the -* temporary storage buffer. Once determined, this buffer must be allocated by the user. -* Next the user allocates the csr_row_ptr array to have \p m+1 elements and calls -* \p hipsparseXpruneDense2csrNnzByPercentage. Finally the user finishes the conversion -* by allocating the csr_col_ind and csr_val arrays (whos size is determined by the value -* at nnz_total_dev_host_ptr) and calling \p hipsparseXpruneDense2csrByPercentage. -* -* The pruning by percentage works by first sorting the absolute values of the dense -* matrix \p A. We then determine a position in this sorted array by -* \f[ -* pos = ceil(m*n*(percentage/100)) - 1 -* pos = min(pos, m*n-1) -* pos = max(pos, 0) -* threshold = sorted_A[pos] -* \f] -* Once we have this threshold we prune values in the dense matrix \p A as in -* \p hipsparseXpruneDense2csr. The routine does support asynchronous execution if the -* pointer mode is set to device. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneDense2csrByPercentage(hipsparseHandle_t handle, - int m, - int n, - const float* A, - int lda, - float percentage, - const hipsparseMatDescr_t descr, - float* csrVal, - const int* csrRowPtr, - int* csrColInd, - pruneInfo_t info, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneDense2csrByPercentage(hipsparseHandle_t handle, - int m, - int n, - const double* A, - int lda, - double percentage, - const hipsparseMatDescr_t descr, - double* csrVal, - const int* csrRowPtr, - int* csrColInd, - pruneInfo_t info, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup conv_module -* \brief -* -* This function converts the matrix A in dense format into a sparse matrix in CSC format. -* All the parameters are assumed to have been pre-allocated by the user and the arrays are filled in based on nnz_per_columns, which can be pre-computed with hipsparseXnnz(). -* It is executed asynchronously with respect to the host and may return control to the application on the host before the entire result is ready. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSdense2csc(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const float* A, - int ld, - const int* nnz_per_columns, - float* csc_val, - int* csc_row_ind, - int* csc_col_ptr); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDdense2csc(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const double* A, - int ld, - const int* nnz_per_columns, - double* csc_val, - int* csc_row_ind, - int* csc_col_ptr); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCdense2csc(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipComplex* A, - int ld, - const int* nnz_per_columns, - hipComplex* csc_val, - int* csc_row_ind, - int* csc_col_ptr); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZdense2csc(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipDoubleComplex* A, - int ld, - const int* nnz_per_columns, - hipDoubleComplex* csc_val, - int* csc_row_ind, - int* csc_col_ptr); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup conv_module -* \brief -* This function converts the sparse matrix in CSR format into a dense matrix. -* It is executed asynchronously with respect to the host and may return control to the application on the host before the entire result is ready. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const float* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - float* A, - int ld); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const double* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - double* A, - int ld); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipComplex* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - hipComplex* A, - int ld); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipDoubleComplex* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - hipDoubleComplex* A, - int ld); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) -/*! \ingroup conv_module -* \brief -* This function converts the sparse matrix in CSC format into a dense matrix. -* It is executed asynchronously with respect to the host and may return control to the application on the host before the entire result is ready. -*/ -/**@{*/ -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsc2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const float* csc_val, - const int* csc_row_ind, - const int* csc_col_ptr, - float* A, - int ld); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsc2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const double* csc_val, - const int* csc_row_ind, - const int* csc_col_ptr, - double* A, - int ld); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsc2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipComplex* csc_val, - const int* csc_row_ind, - const int* csc_col_ptr, - hipComplex* A, - int ld); -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsc2dense(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descr, - const hipDoubleComplex* csc_val, - const int* csc_row_ind, - const int* csc_col_ptr, - hipDoubleComplex* A, - int ld); -/**@}*/ -#endif - -/*! \ingroup conv_module -* \brief -* This function computes the number of nonzero block columns per row and the total number of nonzero blocks in a sparse -* BSR matrix given a sparse CSR matrix as input. -* -* \details -* The routine does support asynchronous execution if the pointer mode is set to device. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsr2bsrNnz(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const int* csrRowPtrA, - const int* csrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - int* bsrRowPtrC, - int* bsrNnzb); - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* Given a sparse CSR matrix and a non-negative tolerance, this function computes how many entries would be left -* in each row of the matrix if elements less than the tolerance were removed. It also computes the total number -* of remaining elements in the matrix. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSnnz_compress(hipsparseHandle_t handle, - int m, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - int* nnzPerRow, - int* nnzC, - float tol); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnnz_compress(hipsparseHandle_t handle, - int m, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - int* nnzPerRow, - int* nnzC, - double tol); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCnnz_compress(hipsparseHandle_t handle, - int m, - const hipsparseMatDescr_t descrA, - const hipComplex* csrValA, - const int* csrRowPtrA, - int* nnzPerRow, - int* nnzC, - hipComplex tol); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZnnz_compress(hipsparseHandle_t handle, - int m, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrValA, - const int* csrRowPtrA, - int* nnzPerRow, - int* nnzC, - hipDoubleComplex tol); -/**@}*/ -#endif - -/*! \ingroup conv_module -* \brief Convert a sparse CSR matrix into a sparse COO matrix -* -* \details -* \p hipsparseXcsr2coo converts the CSR array containing the row offsets, that point -* to the start of every row, into a COO array of row indices. -* -* \note -* It can also be used to convert a CSC array containing the column offsets into a COO -* array of column indices. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsr2coo(hipsparseHandle_t handle, - const int* csrRowPtr, - int nnz, - int m, - int* cooRowInd, - hipsparseIndexBase_t idxBase); - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup conv_module -* \brief Convert a sparse CSR matrix into a sparse CSC matrix -* -* \details -* \p hipsparseXcsr2csc converts a CSR matrix into a CSC matrix. \p hipsparseXcsr2csc -* can also be used to convert a CSC matrix into a CSR matrix. \p copy_values decides -* whether \p csc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) -* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). -* -* \note -* The resulting matrix can also be seen as the transpose of the input matrix. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2csc(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const float* csrSortedVal, - const int* csrSortedRowPtr, - const int* csrSortedColInd, - float* cscSortedVal, - int* cscSortedRowInd, - int* cscSortedColPtr, - hipsparseAction_t copyValues, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2csc(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const double* csrSortedVal, - const int* csrSortedRowPtr, - const int* csrSortedColInd, - double* cscSortedVal, - int* cscSortedRowInd, - int* cscSortedColPtr, - hipsparseAction_t copyValues, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2csc(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipComplex* csrSortedVal, - const int* csrSortedRowPtr, - const int* csrSortedColInd, - hipComplex* cscSortedVal, - int* cscSortedRowInd, - int* cscSortedColPtr, - hipsparseAction_t copyValues, - hipsparseIndexBase_t idxBase); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2csc(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipDoubleComplex* csrSortedVal, - const int* csrSortedRowPtr, - const int* csrSortedColInd, - hipDoubleComplex* cscSortedVal, - int* cscSortedRowInd, - int* cscSortedColPtr, - hipsparseAction_t copyValues, - hipsparseIndexBase_t idxBase); -/**@}*/ -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse csr2csc algorithms. - * - * \details - * This is a list of the \ref hipsparseCsr2CscAlg_t algorithms that can be used by the hipSPARSE - * library routines \ref hipsparseCsr2cscEx2_bufferSize and \ref hipsparseCsr2cscEx2. - */ -#if(!defined(CUDART_VERSION)) -typedef enum -{ - HIPSPARSE_CSR2CSC_ALG_DEFAULT = 0, - HIPSPARSE_CSR2CSC_ALG1 = 1, - HIPSPARSE_CSR2CSC_ALG2 = 2 -} hipsparseCsr2CscAlg_t; -#else -#if(CUDART_VERSION >= 12000) -typedef enum -{ - HIPSPARSE_CSR2CSC_ALG_DEFAULT = 0, - HIPSPARSE_CSR2CSC_ALG1 = 1 -} hipsparseCsr2CscAlg_t; -#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 12000) -typedef enum -{ - HIPSPARSE_CSR2CSC_ALG1 = 1, - HIPSPARSE_CSR2CSC_ALG2 = 2 -} hipsparseCsr2CscAlg_t; -#endif -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -/*! \ingroup conv_module -* \brief This function computes the size of the user allocated temporary storage buffer used -* when converting a sparse CSR matrix into a sparse CSC matrix. -* -* \details -* \p hipsparseCsr2cscEx2_bufferSize calculates the required user allocated temporary buffer needed -* by \p hipsparseCsr2cscEx2 to convert a CSR matrix into a CSC matrix. \p hipsparseCsr2cscEx2 -* can also be used to convert a CSC matrix into a CSR matrix. \p copy_values decides -* whether \p csc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) -* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). -* -* \note -* The resulting matrix can also be seen as the transpose of the input matrix. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCsr2cscEx2_bufferSize(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const void* csrVal, - const int* csrRowPtr, - const int* csrColInd, - void* cscVal, - int* cscColPtr, - int* cscRowInd, - hipDataType valType, - hipsparseAction_t copyValues, - hipsparseIndexBase_t idxBase, - hipsparseCsr2CscAlg_t alg, - size_t* bufferSize); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -/*! \ingroup conv_module -* \brief Convert a sparse CSR matrix into a sparse CSC matrix -* -* \details -* \p hipsparseCsr2cscEx2 converts a CSR matrix into a CSC matrix. \p hipsparseCsr2cscEx2 -* can also be used to convert a CSC matrix into a CSR matrix. \p copy_values decides -* whether \p csc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) -* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). -* -* \note -* The resulting matrix can also be seen as the transpose of the input matrix. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCsr2cscEx2(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const void* csrVal, - const int* csrRowPtr, - const int* csrColInd, - void* cscVal, - int* cscColPtr, - int* cscRowInd, - hipDataType valType, - hipsparseAction_t copyValues, - hipsparseIndexBase_t idxBase, - hipsparseCsr2CscAlg_t alg, - void* buffer); -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup conv_module -* \brief Convert a sparse CSR matrix into a sparse HYB matrix -* -* \details -* \p hipsparseXcsr2hyb converts a CSR matrix into a HYB matrix. It is assumed -* that \p hyb has been initialized with hipsparseCreateHybMat(). -* -* \note -* This function requires a significant amount of storage for the HYB matrix, -* depending on the matrix structure. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2hyb(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const float* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - hipsparseHybMat_t hybA, - int userEllWidth, - hipsparseHybPartition_t partitionType); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2hyb(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const double* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - hipsparseHybMat_t hybA, - int userEllWidth, - hipsparseHybPartition_t partitionType); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2hyb(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - hipsparseHybMat_t hybA, - int userEllWidth, - hipsparseHybPartition_t partitionType); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2hyb(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrSortedValA, - const int* csrSortedRowPtrA, - const int* csrSortedColIndA, - hipsparseHybMat_t hybA, - int userEllWidth, - hipsparseHybPartition_t partitionType); -/**@}*/ -#endif - -/*! \ingroup conv_module -* \brief Convert a sparse GEneral BSR matrix into a sparse GEneral BSC matrix -* -* \details -* \p hipsparseXgebsr2gebsc_bufferSize returns the size of the temporary storage buffer -* required by hipsparseXgebsr2gebsc(). -* The temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgebsr2gebsc_bufferSize(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const float* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgebsr2gebsc_bufferSize(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const double* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgebsr2gebsc_bufferSize(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const hipComplex* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgebsr2gebsc_bufferSize(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const hipDoubleComplex* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); -/**@}*/ - -/*! \ingroup conv_module -* \brief Convert a sparse GEneral BSR matrix into a sparse GEneral BSC matrix -* -* \details -* \p hipsparseXgebsr2gebsc converts a GEneral BSR matrix into a GEneral BSC matrix. \p hipsparseXgebsr2gebsc -* can also be used to convert a GEneral BSC matrix into a GEneral BSR matrix. \p copy_values decides -* whether \p bsc_val is being filled during conversion (\ref HIPSPARSE_ACTION_NUMERIC) -* or not (\ref HIPSPARSE_ACTION_SYMBOLIC). -* -* \p hipsparseXgebsr2gebsc requires extra temporary storage buffer that has to be allocated -* by the user. Storage buffer size can be determined by hipsparseXgebsr2gebsc_bufferSize(). -* -* \note -* The resulting matrix can also be seen as the transpose of the input matrix. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgebsr2gebsc(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const float* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - float* bsc_val, - int* bsc_row_ind, - int* bsc_col_ptr, - hipsparseAction_t copy_values, - hipsparseIndexBase_t idx_base, - void* temp_buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgebsr2gebsc(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const double* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - double* bsc_val, - int* bsc_row_ind, - int* bsc_col_ptr, - hipsparseAction_t copy_values, - hipsparseIndexBase_t idx_base, - void* temp_buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgebsr2gebsc(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const hipComplex* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - hipComplex* bsc_val, - int* bsc_row_ind, - int* bsc_col_ptr, - hipsparseAction_t copy_values, - hipsparseIndexBase_t idx_base, - void* temp_buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgebsr2gebsc(hipsparseHandle_t handle, - int mb, - int nb, - int nnzb, - const hipDoubleComplex* bsr_val, - const int* bsr_row_ptr, - const int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - hipDoubleComplex* bsc_val, - int* bsc_row_ind, - int* bsc_col_ptr, - hipsparseAction_t copy_values, - hipsparseIndexBase_t idx_base, - void* temp_buffer); -/**@}*/ - -/*! \ingroup conv_module -* \brief - * \details - * \p hipsparseXcsr2gebsr_bufferSize returns the size of the temporary buffer that - * is required by \p hipsparseXcsr2gebcsrNnz and \p hipsparseXcsr2gebcsr. - * The temporary storage buffer must be allocated by the user. - * -* This function computes the number of nonzero block columns per row and the total number of nonzero blocks in a sparse -* GEneral BSR matrix given a sparse CSR matrix as input. -* -* \details -* The routine does support asynchronous execution if the pointer mode is set to device. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const float* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const double* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const hipComplex* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const hipDoubleComplex* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - int row_block_dim, - int col_block_dim, - size_t* p_buffer_size); -/**@}*/ - -/*! \ingroup conv_module -* \brief -* This function computes the number of nonzero block columns per row and the total number of nonzero blocks in a sparse -* GEneral BSR matrix given a sparse CSR matrix as input. -* -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsr2gebsrNnz(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const int* csr_row_ptr, - const int* csr_col_ind, - const hipsparseMatDescr_t bsr_descr, - int* bsr_row_ptr, - int row_block_dim, - int col_block_dim, - int* bsr_nnz_devhost, - void* p_buffer); - -/*! \ingroup conv_module -* \brief Convert a sparse CSR matrix into a sparse GEneral BSR matrix -* -* \details -* \p hipsparseXcsr2gebsr converts a CSR matrix into a GEneral BSR matrix. It is assumed, -* that \p bsr_val, \p bsr_col_ind and \p bsr_row_ptr are allocated. Allocation size -* for \p bsr_row_ptr is computed as \p mb+1 where \p mb is the number of block rows in -* the GEneral BSR matrix. Allocation size for \p bsr_val and \p bsr_col_ind is computed using -* \p csr2gebsr_nnz() which also fills in \p bsr_row_ptr. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const float* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - const hipsparseMatDescr_t bsr_descr, - float* bsr_val, - int* bsr_row_ptr, - int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - void* p_buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const double* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - const hipsparseMatDescr_t bsr_descr, - double* bsr_val, - int* bsr_row_ptr, - int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - void* p_buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const hipComplex* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - const hipsparseMatDescr_t bsr_descr, - hipComplex* bsr_val, - int* bsr_row_ptr, - int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - void* p_buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dir, - int m, - int n, - const hipsparseMatDescr_t csr_descr, - const hipDoubleComplex* csr_val, - const int* csr_row_ptr, - const int* csr_col_ind, - const hipsparseMatDescr_t bsr_descr, - hipDoubleComplex* bsr_val, - int* bsr_row_ptr, - int* bsr_col_ind, - int row_block_dim, - int col_block_dim, - void* p_buffer); -/**@}*/ - -/*! \ingroup conv_module -* \brief Convert a sparse CSR matrix into a sparse BSR matrix -* -* \details -* \p hipsparseXcsr2bsr converts a CSR matrix into a BSR matrix. It is assumed, -* that \p bsr_val, \p bsr_col_ind and \p bsr_row_ptr are allocated. Allocation size -* for \p bsr_row_ptr is computed as \p mb+1 where \p mb is the number of block rows in -* the BSR matrix. Allocation size for \p bsr_val and \p bsr_col_ind is computed using -* \p csr2bsr_nnz() which also fills in \p bsr_row_ptr. -* -* \p hipsparseXcsr2bsr requires extra temporary storage that is allocated internally if -* \p block_dim>16 -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2bsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - float* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2bsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - double* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2bsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - hipComplex* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2bsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC); -/**@}*/ - -/*! \ingroup conv_module -* \brief Convert a sparse BSR matrix into a sparse CSR matrix -* -* \details -* \p hipsparseXbsr2csr converts a BSR matrix into a CSR matrix. It is assumed, -* that \p csr_val, \p csr_col_ind and \p csr_row_ptr are allocated. Allocation size -* for \p csr_row_ptr is computed by the number of block rows multiplied by the block -* dimension plus one. Allocation for \p csr_val and \p csr_col_ind is computed by the -* the number of blocks in the BSR matrix multiplied by the block dimension squared. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSbsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - float* csrValC, - int* csrRowPtrC, - int* csrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDbsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - double* csrValC, - int* csrRowPtrC, - int* csrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCbsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - hipComplex* csrValC, - int* csrRowPtrC, - int* csrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZbsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int blockDim, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* csrValC, - int* csrRowPtrC, - int* csrColIndC); -/**@}*/ - -/*! \ingroup conv_module -* \brief Convert a sparse general BSR matrix into a sparse CSR matrix -* -* \details -* \p hipsparseXgebsr2csr converts a BSR matrix into a CSR matrix. It is assumed, -* that \p csr_val, \p csr_col_ind and \p csr_row_ptr are allocated. Allocation size -* for \p csr_row_ptr is computed by the number of block rows multiplied by the block -* dimension plus one. Allocation for \p csr_val and \p csr_col_ind is computed by the -* the number of blocks in the BSR matrix multiplied by the product of the block dimensions. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgebsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDim, - int colBlockDim, - const hipsparseMatDescr_t descrC, - float* csrValC, - int* csrRowPtrC, - int* csrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgebsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDim, - int colBlockDim, - const hipsparseMatDescr_t descrC, - double* csrValC, - int* csrRowPtrC, - int* csrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgebsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDim, - int colBlockDim, - const hipsparseMatDescr_t descrC, - hipComplex* csrValC, - int* csrRowPtrC, - int* csrColIndC); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgebsr2csr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDim, - int colBlockDim, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* csrValC, - int* csrRowPtrC, - int* csrColIndC); -/**@}*/ - -/*! \ingroup conv_module - * \brief Convert a sparse CSR matrix into a compressed sparse CSR matrix - * - * \details - * \p hipsparseXcsr2csr_compress converts a CSR matrix into a compressed CSR matrix by - * removing entries in the input CSR matrix that are below a non-negative threshold \p tol - * - * \note - * In the case of complex matrices only the magnitude of the real part of \p tol is used. - */ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2csr_compress(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrColIndA, - const int* csrRowPtrA, - int nnzA, - const int* nnzPerRow, - float* csrValC, - int* csrColIndC, - int* csrRowPtrC, - float tol); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2csr_compress(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrColIndA, - const int* csrRowPtrA, - int nnzA, - const int* nnzPerRow, - double* csrValC, - int* csrColIndC, - int* csrRowPtrC, - double tol); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2csr_compress(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipComplex* csrValA, - const int* csrColIndA, - const int* csrRowPtrA, - int nnzA, - const int* nnzPerRow, - hipComplex* csrValC, - int* csrColIndC, - int* csrRowPtrC, - hipComplex tol); -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2csr_compress(hipsparseHandle_t handle, - int m, - int n, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrValA, - const int* csrColIndA, - const int* csrRowPtrA, - int nnzA, - const int* nnzPerRow, - hipDoubleComplex* csrValC, - int* csrColIndC, - int* csrRowPtrC, - hipDoubleComplex tol); -/**@}*/ - -/*! \ingroup conv_module - * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXpruneCsr2csr_bufferSize returns the size of the temporary buffer that - * is required by \p hipsparseXpruneCsr2csrNnz and hipsparseXpruneCsr2csr. The - * temporary storage buffer must be allocated by the user. - */ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csr_bufferSize(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* threshold, - const hipsparseMatDescr_t descrC, - const float* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - size_t* bufferSize); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csr_bufferSize(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* threshold, - const hipsparseMatDescr_t descrC, - const double* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - size_t* bufferSize); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXpruneCsr2csr_bufferSizeExt returns the size of the temporary buffer that - * is required by \p hipsparseXpruneCsr2csrNnz and hipsparseXpruneCsr2csr. The - * temporary storage buffer must be allocated by the user. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* threshold, - const hipsparseMatDescr_t descrC, - const float* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - size_t* bufferSize); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* threshold, - const hipsparseMatDescr_t descrC, - const double* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - size_t* bufferSize); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXpruneCsr2csrNnz computes the number of nonzero elements per row and the total - * number of nonzero elements in a sparse CSR matrix once elements less than the threshold are - * pruned from the matrix. - * - * \note The routine does support asynchronous execution if the pointer mode is set to device. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csrNnz(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* threshold, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csrNnz(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* threshold, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune sparse CSR matrix into a sparse CSR matrix - * - * \details - * This function converts the sparse CSR matrix A into a sparse CSR matrix C by pruning values in A - * that are less than the threshold. All the parameters are assumed to have been pre-allocated by the user. - * The user first calls hipsparseXpruneCsr2csr_bufferSize() to determine the size of the buffer used - * by hipsparseXpruneCsr2csrNnz() and hipsparseXpruneCsr2csr() which the user then allocates. The user then - * allocates \p csr_row_ptr_C to have \p m+1 elements and then calls hipsparseXpruneCsr2csrNnz() which fills - * in the \p csr_row_ptr_C array stores then number of elements that are larger than the pruning threshold - * in \p nnz_total_dev_host_ptr. The user then calls hipsparseXpruneCsr2csr() to complete the conversion. It - * is executed asynchronously with respect to the host and may return control to the application on the host - * before the entire result is ready. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csr(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* threshold, - const hipsparseMatDescr_t descrC, - float* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csr(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* threshold, - const hipsparseMatDescr_t descrC, - double* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXpruneCsr2csrByPercentage_bufferSize returns the size of the temporary buffer that - * is required by \p hipsparseXpruneCsr2csrNnzByPercentage. - * The temporary storage buffer must be allocated by the user. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csrByPercentage_bufferSize(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - float percentage, - const hipsparseMatDescr_t descrC, - const float* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - pruneInfo_t info, - size_t* bufferSize); -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage_bufferSize(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - double percentage, - const hipsparseMatDescr_t descrC, - const double* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - pruneInfo_t info, - size_t* bufferSize); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXpruneCsr2csrByPercentage_bufferSizeExt returns the size of the temporary buffer that - * is required by \p hipsparseXpruneCsr2csrNnzByPercentage. - * The temporary storage buffer must be allocated by the user. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - float percentage, - const hipsparseMatDescr_t descrC, - const float* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - pruneInfo_t info, - size_t* bufferSize); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - double percentage, - const hipsparseMatDescr_t descrC, - const double* csrValC, - const int* csrRowPtrC, - const int* csrColIndC, - pruneInfo_t info, - size_t* bufferSize); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXpruneCsr2csrNnzByPercentage computes the number of nonzero elements per row and the total - * number of nonzero elements in a sparse CSR matrix once elements less than the threshold are - * pruned from the matrix. - * - * \note The routine does support asynchronous execution if the pointer mode is set to device. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csrNnzByPercentage(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - float percentage, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr, - pruneInfo_t info, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csrNnzByPercentage(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - double percentage, - const hipsparseMatDescr_t descrC, - int* csrRowPtrC, - int* nnzTotalDevHostPtr, - pruneInfo_t info, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module - * \brief Convert and prune by percentage a sparse CSR matrix into a sparse CSR matrix - * - * \details - * This function converts the sparse CSR matrix A into a sparse CSR matrix C by pruning values in A - * that are less than the threshold. All the parameters are assumed to have been pre-allocated by the user. - * The user first calls hipsparseXpruneCsr2csr_bufferSize() to determine the size of the buffer used - * by hipsparseXpruneCsr2csrNnz() and hipsparseXpruneCsr2csr() which the user then allocates. The user then - * allocates \p csr_row_ptr_C to have \p m+1 elements and then calls hipsparseXpruneCsr2csrNnz() which fills - * in the \p csr_row_ptr_C array stores then number of elements that are larger than the pruning threshold - * in \p nnz_total_dev_host_ptr. The user then calls hipsparseXpruneCsr2csr() to complete the conversion. It - * is executed asynchronously with respect to the host and may return control to the application on the host - * before the entire result is ready. - */ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpruneCsr2csrByPercentage(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - float percentage, - const hipsparseMatDescr_t descrC, - float* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - pruneInfo_t info, - void* buffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage(hipsparseHandle_t handle, - int m, - int n, - int nnzA, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - double percentage, - const hipsparseMatDescr_t descrC, - double* csrValC, - const int* csrRowPtrC, - int* csrColIndC, - pruneInfo_t info, - void* buffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) -/*! \ingroup conv_module -* \brief Convert a sparse HYB matrix into a sparse CSR matrix -* -* \details -* \p hipsparseXhyb2csr converts a HYB matrix into a CSR matrix. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -/**@{*/ -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseShyb2csr(hipsparseHandle_t handle, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - float* csrSortedValA, - int* csrSortedRowPtrA, - int* csrSortedColIndA); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDhyb2csr(hipsparseHandle_t handle, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - double* csrSortedValA, - int* csrSortedRowPtrA, - int* csrSortedColIndA); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseChyb2csr(hipsparseHandle_t handle, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - hipComplex* csrSortedValA, - int* csrSortedRowPtrA, - int* csrSortedColIndA); -DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZhyb2csr(hipsparseHandle_t handle, - const hipsparseMatDescr_t descrA, - const hipsparseHybMat_t hybA, - hipDoubleComplex* csrSortedValA, - int* csrSortedRowPtrA, - int* csrSortedColIndA); -/**@}*/ -#endif - -/*! \ingroup conv_module - * \brief Convert a sparse COO matrix into a sparse CSR matrix - * - * \details - * \p hipsparseXcoo2csr converts the COO array containing the row indices into a - * CSR array of row offsets, that point to the start of every row. - * It is assumed that the COO row index array is sorted. - * - * \note It can also be used, to convert a COO array containing the column indices into - * a CSC array of column offsets, that point to the start of every column. Then, it is - * assumed that the COO column index array is sorted, instead. - * - * \note - * This function is non blocking and executed asynchronously with respect to the host. - * It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcoo2csr(hipsparseHandle_t handle, - const int* cooRowInd, - int nnz, - int m, - int* csrRowPtr, - hipsparseIndexBase_t idxBase); - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief Create the identity map -* -* \details -* \p hipsparseCreateIdentityPermutation stores the identity map in \p p, such that -* \f$p = 0:1:(n-1)\f$. -* -* \code{.c} -* for(i = 0; i < n; ++i) -* { -* p[i] = i; -* } -* \endcode -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateIdentityPermutation(hipsparseHandle_t handle, int n, int* p); -#endif - -/*! \ingroup conv_module -* \brief Sort a sparse CSR matrix -* -* \details -* \p hipsparseXcsrsort_bufferSizeExt returns the size of the temporary storage buffer -* in bytes required by hipsparseXcsrsort(). The temporary storage buffer must be allocated by -* the user. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsrsort_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const int* csrRowPtr, - const int* csrColInd, - size_t* pBufferSizeInBytes); - -/*! \ingroup conv_module -* \brief Sort a sparse CSR matrix -* -* \details -* \p hipsparseXcsrsort sorts a matrix in CSR format. The sorted permutation vector -* \p perm can be used to obtain sorted \p csr_val array. In this case, \p perm must be -* initialized as the identity permutation, see hipsparseCreateIdentityPermutation(). -* -* \p hipsparseXcsrsort requires extra temporary storage buffer that has to be allocated by -* the user. Storage buffer size can be determined by hipsparseXcsrsort_bufferSizeExt(). -* -* \note -* \p perm can be \p NULL if a sorted permutation vector is not required. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcsrsort(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - const int* csrRowPtr, - int* csrColInd, - int* P, - void* pBuffer); - -/*! \ingroup conv_module -* \brief Sort a sparse CSC matrix -* -* \details -* \p hipsparseXcscsort_bufferSizeExt returns the size of the temporary storage buffer -* in bytes required by hipsparseXcscsort(). The temporary storage buffer must be -* allocated by the user. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcscsort_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const int* cscColPtr, - const int* cscRowInd, - size_t* pBufferSizeInBytes); - -/*! \ingroup conv_module -* \brief Sort a sparse CSC matrix -* -* \details -* \p hipsparseXcscsort sorts a matrix in CSC format. The sorted permutation vector -* \p perm can be used to obtain sorted \p csc_val array. In this case, \p perm must be -* initialized as the identity permutation, see hipsparseCreateIdentityPermutation(). -* -* \p hipsparseXcscsort requires extra temporary storage buffer that has to be allocated by -* the user. Storage buffer size can be determined by hipsparseXcscsort_bufferSizeExt(). -* -* \note -* \p perm can be \p NULL if a sorted permutation vector is not required. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcscsort(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - const int* cscColPtr, - int* cscRowInd, - int* P, - void* pBuffer); - -/*! \ingroup conv_module -* \brief Sort a sparse COO matrix -* -* \details -* \p hipsparseXcoosort_bufferSizeExt returns the size of the temporary storage buffer -* in bytes required by hipsparseXcoosort(). The temporary storage buffer must be -* allocated by the user. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcoosort_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const int* cooRows, - const int* cooCols, - size_t* pBufferSizeInBytes); - -/*! \ingroup conv_module -* \brief Sort a sparse COO matrix by row -* -* \details -* \p hipsparseXcoosortByRow sorts a matrix in COO format by row. The sorted -* permutation vector \p perm can be used to obtain sorted \p coo_val array. In this -* case, \p perm must be initialized as the identity permutation, see -* hipsparseCreateIdentityPermutation(). -* -* \p hipsparseXcoosortByRow requires extra temporary storage buffer that has to be -* allocated by the user. Storage buffer size can be determined by -* hipsparseXcoosort_bufferSizeExt(). -* -* \note -* \p perm can be \p NULL if a sorted permutation vector is not required. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcoosortByRow(hipsparseHandle_t handle, - int m, - int n, - int nnz, - int* cooRows, - int* cooCols, - int* P, - void* pBuffer); - -/*! \ingroup conv_module -* \brief Sort a sparse COO matrix by column -* -* \details -* \p hipsparseXcoosortByColumn sorts a matrix in COO format by column. The sorted -* permutation vector \p perm can be used to obtain sorted \p coo_val array. In this -* case, \p perm must be initialized as the identity permutation, see -* hipsparseCreateIdentityPermutation(). -* -* \p hipsparseXcoosortByColumn requires extra temporary storage buffer that has to be -* allocated by the user. Storage buffer size can be determined by -* hipsparseXcoosort_bufferSizeExt(). -* -* \note -* \p perm can be \p NULL if a sorted permutation vector is not required. -* -* \note -* This function is non blocking and executed asynchronously with respect to the host. -* It may return before the actual computation has finished. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXcoosortByColumn(hipsparseHandle_t handle, - int m, - int n, - int nnz, - int* cooRows, - int* cooCols, - int* P, - void* pBuffer); - -/*! \ingroup conv_module -* \brief -* This function computes the the size of the user allocated temporary storage buffer used when converting a sparse -* general BSR matrix to another sparse general BSR matrix. -* -* \details -* \p hipsparseXgebsr2gebsr_bufferSize returns the size of the temporary storage buffer -* that is required by hipsparseXgebsr2gebsrNnz() and hipsparseXgebsr2gebsr(). -* The temporary storage buffer must be allocated by the user. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgebsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - int rowBlockDimC, - int colBlockDimC, - int* bufferSize); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgebsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - int rowBlockDimC, - int colBlockDimC, - int* bufferSize); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgebsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - int rowBlockDimC, - int colBlockDimC, - int* bufferSize); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgebsr2gebsr_bufferSize(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - int rowBlockDimC, - int colBlockDimC, - int* bufferSize); -/**@}*/ - -/*! \ingroup conv_module -* \brief This function is used when converting a general BSR sparse matrix \p A to another general BSR sparse matrix \p C. -* Specifically, this function determines the number of non-zero blocks that will exist in \p C (stored using either a host -* or device pointer), and computes the row pointer array for \p C. -* -* \details -* The routine does support asynchronous execution. -*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseXgebsr2gebsrNnz(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - const hipsparseMatDescr_t descrC, - int* bsrRowPtrC, - int rowBlockDimC, - int colBlockDimC, - int* nnzTotalDevHostPtr, - void* buffer); - -/*! \ingroup conv_module -* \brief -* This function converts the general BSR sparse matrix \p A to another general BSR sparse matrix \p C. -* -* \details -* The conversion uses three steps. First, the user calls hipsparseXgebsr2gebsr_bufferSize() to determine the size of -* the required temporary storage buffer. The user then allocates this buffer. Secondly, the user then allocates \p mb_C+1 -* integers for the row pointer array for \p C where \p mb_C=(m+row_block_dim_C-1)/row_block_dim_C. The user then calls -* hipsparseXgebsr2gebsrNnz() to fill in the row pointer array for \p C ( \p bsr_row_ptr_C ) and determine the number of -* non-zero blocks that will exist in \p C. Finally, the user allocates space for the colimn indices array of \p C to have -* \p nnzb_C elements and space for the values array of \p C to have \p nnzb_C*roc_block_dim_C*col_block_dim_C and then calls -* hipsparseXgebsr2gebsr() to complete the conversion. -*/ -/**@{*/ -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSgebsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const float* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - const hipsparseMatDescr_t descrC, - float* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC, - int rowBlockDimC, - int colBlockDimC, - void* buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDgebsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const double* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - const hipsparseMatDescr_t descrC, - double* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC, - int rowBlockDimC, - int colBlockDimC, - void* buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCgebsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - const hipsparseMatDescr_t descrC, - hipComplex* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC, - int rowBlockDimC, - int colBlockDimC, - void* buffer); - -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZgebsr2gebsr(hipsparseHandle_t handle, - hipsparseDirection_t dirA, - int mb, - int nb, - int nnzb, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* bsrValA, - const int* bsrRowPtrA, - const int* bsrColIndA, - int rowBlockDimA, - int colBlockDimA, - const hipsparseMatDescr_t descrC, - hipDoubleComplex* bsrValC, - int* bsrRowPtrC, - int* bsrColIndC, - int rowBlockDimC, - int colBlockDimC, - void* buffer); -/**@}*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function calculates the amount of temporary storage in bytes required for -* hipsparseXcsru2csr() and hipsparseXcsr2csru(). -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsru2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - float* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - size_t* pBufferSizeInBytes); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsru2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - double* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - size_t* pBufferSizeInBytes); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsru2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - hipComplex* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - size_t* pBufferSizeInBytes); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsru2csr_bufferSizeExt(hipsparseHandle_t handle, - int m, - int n, - int nnz, - hipDoubleComplex* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - size_t* pBufferSizeInBytes); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function converts unsorted CSR format to sorted CSR format. The required -* temporary storage has to be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsru2csr(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsru2csr(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsru2csr(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsru2csr(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); -/**@}*/ -#endif - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup conv_module -* \brief -* This function converts sorted CSR format to unsorted CSR format. The required -* temporary storage has to be allocated by the user. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsr2csru(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - float* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsr2csru(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - double* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsr2csru(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - hipComplex* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsr2csru(hipsparseHandle_t handle, - int m, - int n, - int nnz, - const hipsparseMatDescr_t descrA, - hipDoubleComplex* csrVal, - const int* csrRowPtr, - int* csrColInd, - csru2csrInfo_t info, - void* pBuffer); -/**@}*/ -#endif - -/* -* =========================================================================== -* reordering SPARSE -* =========================================================================== -*/ - -#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) -/*! \ingroup reordering_module -* \brief Coloring of the adjacency graph of the matrix \f$A\f$ stored in the CSR format. -* -* \details -* \p hipsparseXcsrcolor performs the coloring of the undirected graph represented by the (symmetric) sparsity pattern of the matrix \f$A\f$ stored in CSR format. Graph coloring is a way of coloring the nodes of a graph such that no two adjacent nodes are of the same color. The \p fraction_to_color is a parameter to only color a given percentage of the graph nodes, the remaining uncolored nodes receive distinct new colors. The optional \p reordering array is a permutation array such that unknowns of the same color are grouped. The matrix \f$A\f$ must be stored as a general matrix with a symmetric sparsity pattern, and if the matrix \f$A\f$ is non-symmetric then the user is responsible to provide the symmetric part \f$\frac{A+A^T}{2}\f$. -*/ -/**@{*/ -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScsrcolor(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const float* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* fractionToColor, - int* ncolors, - int* coloring, - int* reordering, - hipsparseColorInfo_t info); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDcsrcolor(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const double* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* fractionToColor, - int* ncolors, - int* coloring, - int* reordering, - hipsparseColorInfo_t info); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCcsrcolor(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const float* fractionToColor, - int* ncolors, - int* coloring, - int* reordering, - hipsparseColorInfo_t info); - -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseZcsrcolor(hipsparseHandle_t handle, - int m, - int nnz, - const hipsparseMatDescr_t descrA, - const hipDoubleComplex* csrValA, - const int* csrRowPtrA, - const int* csrColIndA, - const double* fractionToColor, - int* ncolors, - int* coloring, - int* reordering, - hipsparseColorInfo_t info); -/**@}*/ -#endif - -/* -* =========================================================================== -* generic SPARSE -* =========================================================================== -*/ - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a sparse vector - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information for a sparse vector. It must - * be initialized using hipsparseCreateSpVec() and the returned descriptor - * is used in hipSPARSE generic API's involving sparse vectors. It should be destroyed at the end using - * hipsparseDestroySpVec(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -typedef void* hipsparseSpVecDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a dense vector - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information for a dense vector. It must - * be initialized using hipsparseCreateDnVec() and the returned descriptor - * is used in hipSPARSE generic API's involving dense vectors. It should be destroyed at the end using - * hipsparseDestroyDnVec(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -typedef void* hipsparseDnVecDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a sparse matrix - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information for a sparse matrix. It must - * be initialized using hipsparseCreateSpMat() and the returned descriptor - * is used in hipSPARSE generic API's involving sparse matrices. It should be destroyed at the end using - * hipsparseDestroySpMat(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -typedef void* hipsparseSpMatDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a dense matrix - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information for a dense matrix. It must - * be initialized using hipsparseCreateDnMat() and the returned descriptor - * is used in hipSPARSE generic API's involving dense matrices. It should be destroyed at the end using - * hipsparseDestroyDnMat(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -typedef void* hipsparseDnMatDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a sparse vector - * - * \details - * The hipSPARSE (const) descriptor is an opaque structure holding information for a sparse vector. It must - * be initialized using hipsparseCreateConstSpVec() and the returned descriptor - * is used in hipSPARSE generic API's involving sparse vectors. It should be destroyed at the end using - * hipsparseDestroySpVec(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -typedef void const* hipsparseConstSpVecDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a dense vector - * - * \details - * The hipSPARSE (const) descriptor is an opaque structure holding information for a dense vector. It must - * be initialized using hipsparseCreateConstDnVec() and the returned descriptor - * is used in hipSPARSE generic API's involving dense vectors. It should be destroyed at the end using - * hipsparseDestroyDnVec(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -typedef void const* hipsparseConstDnVecDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a sparse matrix - * - * \details - * The hipSPARSE (const) descriptor is an opaque structure holding information for a sparse matrix. It must - * be initialized using hipsparseCreateConstSpMat() and the returned descriptor - * is used in hipSPARSE generic API's involving sparse matrices. It should be destroyed at the end using - * hipsparseDestroySpMat(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -typedef void const* hipsparseConstSpMatDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a dense matrix - * - * \details - * The hipSPARSE (const) descriptor is an opaque structure holding information for a dense matrix. It must - * be initialized using hipsparseCreateConstDnMat() and the returned descriptor - * is used in hipSPARSE generic API's involving dense matrices. It should be destroyed at the end using - * hipsparseDestroyDnMat(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -typedef void const* hipsparseConstDnMatDescr_t; -#endif - -/// \cond DO_NOT_DOCUMENT -// Forward declarations -struct hipsparseSpGEMMDescr; -struct hipsparseSpSVDescr; -struct hipsparseSpSMDescr; -/// \endcond - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a SpGEMM calculations - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information that is used in hipsparseSpGEMM_workEstimation(), - * hipsparseSpGEMMreuse_workEstimation(), hipsparseSpGEMMreuse_nnz(), hipsparseSpGEMM_compute(), - * hipsparseSpGEMMreuse_compute(), hipsparseSpGEMM_copy(), and hipsparseSpGEMMreuse_copy(). It must - * be initialized using hipsparseSpGEMM_createDescr(). It should be destroyed at the end using - * hipsparseSpGEMM_destroyDescr(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) -typedef struct hipsparseSpGEMMDescr* hipsparseSpGEMMDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a SpSV calculations - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information that is used in hipsparseSpSV_bufferSize(), - * hipsparseSpSV_analysis(), and hipsparseSpSV_solve(). It must be initialized using hipsparseSpSV_createDescr(). - * It should be destroyed at the end using hipsparseSpSV_destroyDescr(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) -typedef struct hipsparseSpSVDescr* hipsparseSpSVDescr_t; -#endif - -/*! \ingroup types_module - * \brief Generic API opaque structure holding information for a SpSM calculations - * - * \details - * The hipSPARSE descriptor is an opaque structure holding information that is used in hipsparseSpSM_bufferSize(), - * hipsparseSpSM_analysis(), and hipsparseSpSM_solve(). It must be initialized using hipsparseSpSM_createDescr(). - * It should be destroyed at the end using hipsparseSpSM_destroyDescr(). - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) -typedef struct hipsparseSpSMDescr* hipsparseSpSMDescr_t; -#endif - -/* Generic API types */ - -/*! \ingroup generic_module - * \brief List of hipsparse sparse matrix formats. - * - * \details - * This is a list of the \ref hipsparseFormat_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION)) -typedef enum -{ - HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ - HIPSPARSE_FORMAT_CSC = 2, /* Compressed Sparse Column */ - HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ - HIPSPARSE_FORMAT_COO_AOS = 4, /* Coordinate - Array of Structures */ - HIPSPARSE_FORMAT_BLOCKED_ELL = 5 /* Blocked ELL */ -} hipsparseFormat_t; -#else -#if(CUDART_VERSION >= 12000) -typedef enum -{ - HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ - HIPSPARSE_FORMAT_CSC = 2, /* Compressed Sparse Column */ - HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ - HIPSPARSE_FORMAT_BLOCKED_ELL = 5 /* Blocked ELL */ -} hipsparseFormat_t; -#elif(CUDART_VERSION >= 11021 && CUDART_VERSION < 12000) -typedef enum -{ - HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ - HIPSPARSE_FORMAT_CSC = 2, /* Compressed Sparse Column */ - HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ - HIPSPARSE_FORMAT_COO_AOS = 4, /* Coordinate - Array of Structures */ - HIPSPARSE_FORMAT_BLOCKED_ELL = 5 /* Blocked ELL */ -} hipsparseFormat_t; -#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 11021) -typedef enum -{ - HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ - HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ - HIPSPARSE_FORMAT_COO_AOS = 4, /* Coordinate - Array of Structures */ -} hipsparseFormat_t; -#endif -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse dense matrix memory layout ordering. - * - * \details - * This is a list of the \ref hipsparseOrder_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION)) -typedef enum -{ - HIPSPARSE_ORDER_COLUMN HIPSPARSE_DEPRECATED_MSG("Please use HIPSPARSE_ORDER_COL instead") - = 1, /**< Column major */ - HIPSPARSE_ORDER_COL = 1, /**< Column major */ - HIPSPARSE_ORDER_ROW = 2 /**< Row major */ -} hipsparseOrder_t; -#else -#if(CUDART_VERSION >= 11000) -typedef enum -{ - HIPSPARSE_ORDER_COLUMN HIPSPARSE_DEPRECATED_MSG("Please use HIPSPARSE_ORDER_COL instead") - = 1, /**< Column major */ - HIPSPARSE_ORDER_COL = 1, /**< Column major */ - HIPSPARSE_ORDER_ROW = 2 /**< Row major */ -} hipsparseOrder_t; -#elif(CUDART_VERSION >= 10010) -typedef enum -{ - HIPSPARSE_ORDER_COLUMN HIPSPARSE_DEPRECATED_MSG("Please use HIPSPARSE_ORDER_COL instead") - = 1, /**< Column major */ - HIPSPARSE_ORDER_COL = 1 /**< Column major */ -} hipsparseOrder_t; -#endif -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse index type used by sparse matrix indices. - * - * \details - * This is a list of the \ref hipsparseIndexType_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -typedef enum -{ - HIPSPARSE_INDEX_16U = 1, /**< 16 bit unsigned integer indices */ - HIPSPARSE_INDEX_32I = 2, /**< 32 bit signed integer indices */ - HIPSPARSE_INDEX_64I = 3 /**< 64 bit signed integer indices */ -} hipsparseIndexType_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SpMV algorithms. - * - * \details - * This is a list of the \ref hipsparseSpMVAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION)) -typedef enum -{ - HIPSPARSE_MV_ALG_DEFAULT = 0, - HIPSPARSE_COOMV_ALG = 1, - HIPSPARSE_CSRMV_ALG1 = 2, - HIPSPARSE_CSRMV_ALG2 = 3, - HIPSPARSE_SPMV_ALG_DEFAULT = 0, - HIPSPARSE_SPMV_COO_ALG1 = 1, - HIPSPARSE_SPMV_CSR_ALG1 = 2, - HIPSPARSE_SPMV_CSR_ALG2 = 3, - HIPSPARSE_SPMV_COO_ALG2 = 4 -} hipsparseSpMVAlg_t; -#else -#if(CUDART_VERSION >= 12000) -typedef enum -{ - HIPSPARSE_SPMV_ALG_DEFAULT = 0, - HIPSPARSE_SPMV_COO_ALG1 = 1, - HIPSPARSE_SPMV_CSR_ALG1 = 2, - HIPSPARSE_SPMV_CSR_ALG2 = 3, - HIPSPARSE_SPMV_COO_ALG2 = 4 -} hipsparseSpMVAlg_t; -#elif(CUDART_VERSION >= 11021 && CUDART_VERSION < 12000) -typedef enum -{ - HIPSPARSE_MV_ALG_DEFAULT = 0, - HIPSPARSE_COOMV_ALG = 1, - HIPSPARSE_CSRMV_ALG1 = 2, - HIPSPARSE_CSRMV_ALG2 = 3, - HIPSPARSE_SPMV_ALG_DEFAULT = 0, - HIPSPARSE_SPMV_COO_ALG1 = 1, - HIPSPARSE_SPMV_CSR_ALG1 = 2, - HIPSPARSE_SPMV_CSR_ALG2 = 3, - HIPSPARSE_SPMV_COO_ALG2 = 4 -} hipsparseSpMVAlg_t; -#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 11021) -typedef enum -{ - HIPSPARSE_MV_ALG_DEFAULT = 0, - HIPSPARSE_COOMV_ALG = 1, - HIPSPARSE_CSRMV_ALG1 = 2, - HIPSPARSE_CSRMV_ALG2 = 3 -} hipsparseSpMVAlg_t; -#endif -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SpMM algorithms. - * - * \details - * This is a list of the \ref hipsparseSpMMAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION)) -typedef enum -{ - HIPSPARSE_MM_ALG_DEFAULT = 0, - HIPSPARSE_COOMM_ALG1 = 1, - HIPSPARSE_COOMM_ALG2 = 2, - HIPSPARSE_COOMM_ALG3 = 3, - HIPSPARSE_CSRMM_ALG1 = 4, - HIPSPARSE_SPMM_ALG_DEFAULT = 0, - HIPSPARSE_SPMM_COO_ALG1 = 1, - HIPSPARSE_SPMM_COO_ALG2 = 2, - HIPSPARSE_SPMM_COO_ALG3 = 3, - HIPSPARSE_SPMM_COO_ALG4 = 5, - HIPSPARSE_SPMM_CSR_ALG1 = 4, - HIPSPARSE_SPMM_CSR_ALG2 = 6, - HIPSPARSE_SPMM_CSR_ALG3 = 12, - HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 -} hipsparseSpMMAlg_t; -#else -#if(CUDART_VERSION >= 12000) -typedef enum -{ - HIPSPARSE_SPMM_ALG_DEFAULT = 0, - HIPSPARSE_SPMM_COO_ALG1 = 1, - HIPSPARSE_SPMM_COO_ALG2 = 2, - HIPSPARSE_SPMM_COO_ALG3 = 3, - HIPSPARSE_SPMM_COO_ALG4 = 5, - HIPSPARSE_SPMM_CSR_ALG1 = 4, - HIPSPARSE_SPMM_CSR_ALG2 = 6, - HIPSPARSE_SPMM_CSR_ALG3 = 12, - HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 -} hipsparseSpMMAlg_t; -#elif(CUDART_VERSION >= 11021 && CUDART_VERSION < 12000) -typedef enum -{ - HIPSPARSE_MM_ALG_DEFAULT = 0, - HIPSPARSE_COOMM_ALG1 = 1, - HIPSPARSE_COOMM_ALG2 = 2, - HIPSPARSE_COOMM_ALG3 = 3, - HIPSPARSE_CSRMM_ALG1 = 4, - HIPSPARSE_SPMM_ALG_DEFAULT = 0, - HIPSPARSE_SPMM_COO_ALG1 = 1, - HIPSPARSE_SPMM_COO_ALG2 = 2, - HIPSPARSE_SPMM_COO_ALG3 = 3, - HIPSPARSE_SPMM_COO_ALG4 = 5, - HIPSPARSE_SPMM_CSR_ALG1 = 4, - HIPSPARSE_SPMM_CSR_ALG2 = 6, - HIPSPARSE_SPMM_CSR_ALG3 = 12, - HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 -} hipsparseSpMMAlg_t; -#elif(CUDART_VERSION >= 11003 && CUDART_VERSION < 11021) -typedef enum -{ - HIPSPARSE_MM_ALG_DEFAULT = 0, - HIPSPARSE_COOMM_ALG1 = 1, - HIPSPARSE_COOMM_ALG2 = 2, - HIPSPARSE_COOMM_ALG3 = 3, - HIPSPARSE_CSRMM_ALG1 = 4, - HIPSPARSE_SPMM_ALG_DEFAULT = 0, - HIPSPARSE_SPMM_COO_ALG1 = 1, - HIPSPARSE_SPMM_COO_ALG2 = 2, - HIPSPARSE_SPMM_COO_ALG3 = 3, - HIPSPARSE_SPMM_COO_ALG4 = 5, - HIPSPARSE_SPMM_CSR_ALG1 = 4, - HIPSPARSE_SPMM_CSR_ALG2 = 6, - HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 -} hipsparseSpMMAlg_t; -#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 11003) -typedef enum -{ - HIPSPARSE_MM_ALG_DEFAULT = 0, - HIPSPARSE_COOMM_ALG1 = 1, - HIPSPARSE_COOMM_ALG2 = 2, - HIPSPARSE_COOMM_ALG3 = 3, - HIPSPARSE_CSRMM_ALG1 = 4 -} hipsparseSpMMAlg_t; -#endif -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SparseToDense algorithms. - * - * \details - * This is a list of the \ref hipsparseSparseToDenseAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11020) -typedef enum -{ - HIPSPARSE_SPARSETODENSE_ALG_DEFAULT = 0, -} hipsparseSparseToDenseAlg_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse DenseToSparse algorithms. - * - * \details - * This is a list of the \ref hipsparseDenseToSparseAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11020) -typedef enum -{ - HIPSPARSE_DENSETOSPARSE_ALG_DEFAULT = 0, -} hipsparseDenseToSparseAlg_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SDDMM algorithms. - * - * \details - * This is a list of the \ref hipsparseSDDMMAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11022) -typedef enum -{ - HIPSPARSE_SDDMM_ALG_DEFAULT = 0 -} hipsparseSDDMMAlg_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SpSV algorithms. - * - * \details - * This is a list of the \ref hipsparseSpSVAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) -typedef enum -{ - HIPSPARSE_SPSV_ALG_DEFAULT = 0 -} hipsparseSpSVAlg_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SpSM algorithms. - * - * \details - * This is a list of the \ref hipsparseSpSMAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) -typedef enum -{ - HIPSPARSE_SPSM_ALG_DEFAULT = 0 -} hipsparseSpSMAlg_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse attributes. - * - * \details - * This is a list of the \ref hipsparseSpMatAttribute_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) -typedef enum -{ - HIPSPARSE_SPMAT_FILL_MODE = 0, /**< Fill mode attribute */ - HIPSPARSE_SPMAT_DIAG_TYPE = 1 /**< Diag type attribute */ -} hipsparseSpMatAttribute_t; -#endif - -/*! \ingroup generic_module - * \brief List of hipsparse SpGEMM algorithms. - * - * \details - * This is a list of the \ref hipsparseSpGEMMAlg_t types that are used by the hipSPARSE - * library. - */ -#if(!defined(CUDART_VERSION)) -typedef enum -{ - HIPSPARSE_SPGEMM_DEFAULT = 0, - HIPSPARSE_SPGEMM_CSR_ALG_DETERMINISTIC = 1, - HIPSPARSE_SPGEMM_CSR_ALG_NONDETERMINISTIC = 2, - HIPSPARSE_SPGEMM_ALG1 = 3, - HIPSPARSE_SPGEMM_ALG2 = 4, - HIPSPARSE_SPGEMM_ALG3 = 5 -} hipsparseSpGEMMAlg_t; -#else -#if(CUDART_VERSION >= 12000) -typedef enum -{ - HIPSPARSE_SPGEMM_DEFAULT = 0, - HIPSPARSE_SPGEMM_CSR_ALG_DETERMINISTIC = 1, - HIPSPARSE_SPGEMM_CSR_ALG_NONDETERMINISTIC = 2, - HIPSPARSE_SPGEMM_ALG1 = 3, - HIPSPARSE_SPGEMM_ALG2 = 4, - HIPSPARSE_SPGEMM_ALG3 = 5 -} hipsparseSpGEMMAlg_t; -#elif(CUDART_VERSION >= 11031 && CUDART_VERSION < 12000) -typedef enum -{ - HIPSPARSE_SPGEMM_DEFAULT = 0, - HIPSPARSE_SPGEMM_CSR_ALG_DETERMINISTIC = 1, - HIPSPARSE_SPGEMM_CSR_ALG_NONDETERMINISTIC = 2, -} hipsparseSpGEMMAlg_t; -#elif(CUDART_VERSION >= 11000) -typedef enum -{ - HIPSPARSE_SPGEMM_DEFAULT = 0 -} hipsparseSpGEMMAlg_t; -#endif -#endif - -/* Sparse vector API */ - -/*! \ingroup generic_module -* \brief Description: Create a sparse vector. -* -* \details -* \p hipsparseCreateSpVec creates a sparse vector descriptor. It should be -* destroyed at the end using hipsparseDestroySpVec(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateSpVec(hipsparseSpVecDescr_t* spVecDescr, - int64_t size, - int64_t nnz, - void* indices, - void* values, - hipsparseIndexType_t idxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a const sparse vector. -* -* \details -* \p hipsparseCreateConstSpVec creates a const sparse vector descriptor. It should be -* destroyed at the end using hipsparseDestroySpVec(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstSpVec(hipsparseConstSpVecDescr_t* spVecDescr, - int64_t size, - int64_t nnz, - const void* indices, - const void* values, - hipsparseIndexType_t idxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Destroy a sparse vector. -* -* \details -* \p hipsparseDestroySpVec destroys a sparse vector descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroySpVec(hipsparseConstSpVecDescr_t spVecDescr); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroySpVec(hipsparseSpVecDescr_t spVecDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the fields of the sparse vector descriptor. -* -* \details -* \p hipsparseSpVecGet gets the fields of the sparse vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVecGet(const hipsparseSpVecDescr_t spVecDescr, - int64_t* size, - int64_t* nnz, - void** indices, - void** values, - hipsparseIndexType_t* idxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the fields of the const sparse vector descriptor. -* -* \details -* \p hipsparseConstSpVecGet gets the fields of the const sparse vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstSpVecGet(hipsparseConstSpVecDescr_t spVecDescr, - int64_t* size, - int64_t* nnz, - const void** indices, - const void** values, - hipsparseIndexType_t* idxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get index base of a sparse vector. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVecGetIndexBase(const hipsparseConstSpVecDescr_t spVecDescr, - hipsparseIndexBase_t* idxBase); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVecGetIndexBase(const hipsparseSpVecDescr_t spVecDescr, - hipsparseIndexBase_t* idxBase); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointer to a sparse vector data array. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVecGetValues(const hipsparseSpVecDescr_t spVecDescr, void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointer to a sparse vector data array. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstSpVecGetValues(hipsparseConstSpVecDescr_t spVecDescr, - const void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Set pointer of a sparse vector data array. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVecSetValues(hipsparseSpVecDescr_t spVecDescr, void* values); -#endif - -/* Sparse matrix API */ - -/*! \ingroup generic_module -* \brief Description: Create a sparse COO matrix descriptor -* \details -* \p hipsparseCreateCoo creates a sparse COO matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCoo(hipsparseSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - void* cooRowInd, - void* cooColInd, - void* cooValues, - hipsparseIndexType_t cooIdxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse COO matrix descriptor -* \details -* \p hipsparseCreateConstCoo creates a sparse COO matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstCoo(hipsparseConstSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - const void* cooRowInd, - const void* cooColInd, - const void* cooValues, - hipsparseIndexType_t cooIdxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse COO (AoS) matrix descriptor -* \details -* \p hipsparseCreateCooAoS creates a sparse COO (AoS) matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 10010 && CUDART_VERSION < 12000)) -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCooAoS(hipsparseSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - void* cooInd, - void* cooValues, - hipsparseIndexType_t cooIdxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse CSR matrix descriptor -* \details -* \p hipsparseCreateCsr creates a sparse CSR matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsr(hipsparseSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - void* csrRowOffsets, - void* csrColInd, - void* csrValues, - hipsparseIndexType_t csrRowOffsetsType, - hipsparseIndexType_t csrColIndType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse CSR matrix descriptor -* \details -* \p hipsparseCreateConstCsr creates a sparse CSR matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstCsr(hipsparseConstSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - const void* csrRowOffsets, - const void* csrColInd, - const void* csrValues, - hipsparseIndexType_t csrRowOffsetsType, - hipsparseIndexType_t csrColIndType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse CSC matrix descriptor -* \details -* \p hipsparseCreateCsr creates a sparse CSC matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11020) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateCsc(hipsparseSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - void* cscColOffsets, - void* cscRowInd, - void* cscValues, - hipsparseIndexType_t cscColOffsetsType, - hipsparseIndexType_t cscRowIndType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse CSC matrix descriptor -* \details -* \p hipsparseCreateConstCsc creates a sparse CSC matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstCsc(hipsparseConstSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t nnz, - const void* cscColOffsets, - const void* cscRowInd, - const void* cscValues, - hipsparseIndexType_t cscColOffsetsType, - hipsparseIndexType_t cscRowIndType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse Blocked ELL matrix descriptor -* \details -* \p hipsparseCreateCsr creates a sparse Blocked ELL matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11021) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateBlockedEll(hipsparseSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t ellBlockSize, - int64_t ellCols, - void* ellColInd, - void* ellValue, - hipsparseIndexType_t ellIdxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create a sparse Blocked ELL matrix descriptor -* \details -* \p hipsparseCreateConstBlockedEll creates a sparse Blocked ELL matrix descriptor. It should be -* destroyed at the end using \p hipsparseDestroySpMat. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstBlockedEll(hipsparseConstSpMatDescr_t* spMatDescr, - int64_t rows, - int64_t cols, - int64_t ellBlockSize, - int64_t ellCols, - const void* ellColInd, - const void* ellValue, - hipsparseIndexType_t ellIdxType, - hipsparseIndexBase_t idxBase, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Destroy a sparse matrix descriptor -* \details -* \p hipsparseDestroySpMat destroys a sparse matrix descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroySpMat(hipsparseConstSpMatDescr_t spMatDescr); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroySpMat(hipsparseSpMatDescr_t spMatDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse COO matrix -* \details -* \p hipsparseCooGet gets the fields of the sparse COO matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCooGet(const hipsparseSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - void** cooRowInd, - void** cooColInd, - void** cooValues, - hipsparseIndexType_t* idxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse COO matrix -* \details -* \p hipsparseConstCooGet gets the fields of the sparse COO matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstCooGet(hipsparseConstSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - const void** cooRowInd, - const void** cooColInd, - const void** cooValues, - hipsparseIndexType_t* idxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse COO (AoS) matrix -* \details -* \p hipsparseCooAoSGet gets the fields of the sparse COO (AoS) matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 10010 && CUDART_VERSION < 12000)) -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCooAoSGet(const hipsparseSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - void** cooInd, - void** cooValues, - hipsparseIndexType_t* idxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse CSR matrix -* \details -* \p hipsparseCsrGet gets the fields of the sparse CSR matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCsrGet(const hipsparseSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - void** csrRowOffsets, - void** csrColInd, - void** csrValues, - hipsparseIndexType_t* csrRowOffsetsType, - hipsparseIndexType_t* csrColIndType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse CSR matrix -* \details -* \p hipsparseConstCsrGet gets the fields of the sparse CSR matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstCsrGet(hipsparseConstSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - const void** csrRowOffsets, - const void** csrColInd, - const void** csrValues, - hipsparseIndexType_t* csrRowOffsetsType, - hipsparseIndexType_t* csrColIndType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse CSC matrix -* \details -* \p hipsparseCscGet gets the fields of the sparse CSC matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCscGet(const hipsparseSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - void** cscColOffsets, - void** cscRowInd, - void** cscValues, - hipsparseIndexType_t* cscColOffsetsType, - hipsparseIndexType_t* cscRowIndType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse CSC matrix -* \details -* \p hipsparseConstCscGet gets the fields of the sparse CSC matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstCscGet(hipsparseConstSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz, - const void** cscColOffsets, - const void** cscRowInd, - const void** cscValues, - hipsparseIndexType_t* cscColOffsetsType, - hipsparseIndexType_t* cscRowIndType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse blocked ELL matrix -* \details -* \p hipsparseBlockedEllGet gets the fields of the sparse blocked ELL matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11021) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseBlockedEllGet(const hipsparseSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* ellBlockSize, - int64_t* ellCols, - void** ellColInd, - void** ellValue, - hipsparseIndexType_t* ellIdxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get pointers of a sparse blocked ELL matrix -* \details -* \p hipsparseConstBlockedEllGet gets the fields of the sparse blocked ELL matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstBlockedEllGet(hipsparseConstSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* ellBlockSize, - int64_t* ellCols, - const void** ellColInd, - const void** ellValue, - hipsparseIndexType_t* ellIdxType, - hipsparseIndexBase_t* idxBase, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Set pointers of a sparse CSR matrix -* \details -* \p hipsparseCsrSetPointers sets the fields of the sparse CSR matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCsrSetPointers(hipsparseSpMatDescr_t spMatDescr, - void* csrRowOffsets, - void* csrColInd, - void* csrValues); -#endif - -/*! \ingroup generic_module -* \brief Description: Set pointers of a sparse CSC matrix -* \details -* \p hipsparseCscSetPointers sets the fields of the sparse CSC matrix descriptor -*/ -#if(!defined(CUDART_VERSION)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCscSetPointers(hipsparseSpMatDescr_t spMatDescr, - void* cscColOffsets, - void* cscRowInd, - void* cscValues); -#endif - -/*! \ingroup generic_module -* \brief Description: Set pointers of a sparse COO matrix -* \details -* \p hipsparseCooSetPointers sets the fields of the sparse COO matrix descriptor -*/ -#if(!defined(CUDART_VERSION)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCooSetPointers(hipsparseSpMatDescr_t spMatDescr, - void* cooRowInd, - void* cooColInd, - void* cooValues); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the sizes of a sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetSize(hipsparseConstSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetSize(hipsparseSpMatDescr_t spMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* nnz); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the format of a sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetFormat(hipsparseConstSpMatDescr_t spMatDescr, - hipsparseFormat_t* format); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetFormat(const hipsparseSpMatDescr_t spMatDescr, - hipsparseFormat_t* format); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the index base of a sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetIndexBase(hipsparseConstSpMatDescr_t spMatDescr, - hipsparseIndexBase_t* idxBase); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetIndexBase(const hipsparseSpMatDescr_t spMatDescr, - hipsparseIndexBase_t* idxBase); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the pointer of the values array of a sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetValues(hipsparseSpMatDescr_t spMatDescr, void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the pointer of the values array of a sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstSpMatGetValues(hipsparseConstSpMatDescr_t spMatDescr, - const void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Set the pointer of the values array of a sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatSetValues(hipsparseSpMatDescr_t spMatDescr, void* values); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the batch count of the sparse matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetStridedBatch(hipsparseConstSpMatDescr_t spMatDescr, - int* batchCount); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetStridedBatch(hipsparseSpMatDescr_t spMatDescr, int* batchCount); -#endif - -/*! \ingroup generic_module -* \brief Description: Set the batch count of the sparse matrix -*/ -#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 10010 && CUDART_VERSION < 12000)) -DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatSetStridedBatch(hipsparseSpMatDescr_t spMatDescr, int batchCount); -#endif - -/*! \ingroup generic_module -* \brief Description: Set the batch count and stride of the sparse COO matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCooSetStridedBatch(hipsparseSpMatDescr_t spMatDescr, - int batchCount, - int64_t batchStride); -#endif - -/*! \ingroup generic_module -* \brief Description: Set the batch count and stride of the sparse CSR matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCsrSetStridedBatch(hipsparseSpMatDescr_t spMatDescr, - int batchCount, - int64_t offsetsBatchStride, - int64_t columnsValuesBatchStride); -#endif - -/*! \ingroup generic_module -* \brief Description: Get attribute from sparse matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetAttribute(hipsparseConstSpMatDescr_t spMatDescr, - hipsparseSpMatAttribute_t attribute, - void* data, - size_t dataSize); -#elif(CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatGetAttribute(hipsparseSpMatDescr_t spMatDescr, - hipsparseSpMatAttribute_t attribute, - void* data, - size_t dataSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Set attribute in sparse matrix descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMatSetAttribute(hipsparseSpMatDescr_t spMatDescr, - hipsparseSpMatAttribute_t attribute, - const void* data, - size_t dataSize); -#endif - -/* Dense vector API */ - -/*! \ingroup generic_module -* \brief Description: Create dense vector -* \details -* \p hipsparseCreateDnVec creates a dense vector descriptor. It should be -* destroyed at the end using hipsparseDestroyDnVec(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateDnVec(hipsparseDnVecDescr_t* dnVecDescr, - int64_t size, - void* values, - hipDataType valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Create dense vector -* \details -* \p hipsparseCreateConstDnVec creates a dense vector descriptor. It should be -* destroyed at the end using hipsparseDestroyDnVec(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstDnVec(hipsparseConstDnVecDescr_t* dnVecDescr, - int64_t size, - const void* values, - hipDataType valueType); -#endif - -/* Description: Destroy dense vector */ - -/*! \ingroup generic_module -* \brief Description: Destroy dense vector -* \details -* \p hipsparseDestroyDnVec destroys a dense vector descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyDnVec(hipsparseConstDnVecDescr_t dnVecDescr); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyDnVec(hipsparseDnVecDescr_t dnVecDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the fields from a dense vector -* \details -* \p hipsparseDnVecGet gets the fields of the dense vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnVecGet(const hipsparseDnVecDescr_t dnVecDescr, - int64_t* size, - void** values, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the fields from a dense vector -* \details -* \p hipsparseConstDnVecGet gets the fields of the dense vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstDnVecGet(hipsparseConstDnVecDescr_t dnVecDescr, - int64_t* size, - const void** values, - hipDataType* valueType); -#endif - -/*! \ingroup generic_module -* \brief Description: Get value pointer from a dense vector -* \details -* \p hipsparseDnVecGetValues gets the fields of the dense vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnVecGetValues(const hipsparseDnVecDescr_t dnVecDescr, void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Get value pointer from a dense vector -* \details -* \p hipsparseConstDnVecGetValues gets the fields of the dense vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstDnVecGetValues(hipsparseConstDnVecDescr_t dnVecDescr, - const void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Set value pointer of a dense vector -* \details -* \p hipsparseDnVecSetValues sets the fields of the dense vector descriptor -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ - || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnVecSetValues(hipsparseDnVecDescr_t dnVecDescr, void* values); -#endif - -/* Dense matrix API */ - -/* Description: Create dense matrix */ - -/*! \ingroup generic_module -* \brief Description: Create dense matrix -* \details -* \p hipsparseCreateDnMat creates a dense matrix descriptor. It should be -* destroyed at the end using hipsparseDestroyDnMat(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateDnMat(hipsparseDnMatDescr_t* dnMatDescr, - int64_t rows, - int64_t cols, - int64_t ld, - void* values, - hipDataType valueType, - hipsparseOrder_t order); -#endif - -/*! \ingroup generic_module -* \brief Description: Create dense matrix -* \details -* \p hipsparseCreateConstDnMat creates a dense matrix descriptor. It should be -* destroyed at the end using hipsparseDestroyDnMat(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseCreateConstDnMat(hipsparseConstDnMatDescr_t* dnMatDescr, - int64_t rows, - int64_t cols, - int64_t ld, - const void* values, - hipDataType valueType, - hipsparseOrder_t order); -#endif - -/*! \ingroup generic_module -* \brief Description: Destroy dense matrix -* \details -* \p hipsparseDestroyDnMat destroys a dense matrix descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyDnMat(hipsparseConstDnMatDescr_t dnMatDescr); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDestroyDnMat(hipsparseDnMatDescr_t dnMatDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Get fields from a dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnMatGet(const hipsparseDnMatDescr_t dnMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* ld, - void** values, - hipDataType* valueType, - hipsparseOrder_t* order); -#endif - -/*! \ingroup generic_module -* \brief Description: Get fields from a dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstDnMatGet(hipsparseConstDnMatDescr_t dnMatDescr, - int64_t* rows, - int64_t* cols, - int64_t* ld, - const void** values, - hipDataType* valueType, - hipsparseOrder_t* order); -#endif - -/*! \ingroup generic_module -* \brief Description: Get value pointer from a dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnMatGetValues(const hipsparseDnMatDescr_t dnMatDescr, void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Get value pointer from a dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseConstDnMatGetValues(hipsparseConstDnMatDescr_t dnMatDescr, - const void** values); -#endif - -/*! \ingroup generic_module -* \brief Description: Set value pointer of a dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnMatSetValues(hipsparseDnMatDescr_t dnMatDescr, void* values); -#endif - -/*! \ingroup generic_module -* \brief Description: Get the batch count and batch stride of the dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnMatGetStridedBatch(hipsparseConstDnMatDescr_t dnMatDescr, - int* batchCount, - int64_t* batchStride); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnMatGetStridedBatch(hipsparseDnMatDescr_t dnMatDescr, - int* batchCount, - int64_t* batchStride); -#endif - -/*! \ingroup generic_module -* \brief Description: Set the batch count and batch stride of the dense matrix -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDnMatSetStridedBatch(hipsparseDnMatDescr_t dnMatDescr, - int batchCount, - int64_t batchStride); -#endif - -/* Generic API functions */ - -/*! \ingroup generic_module -* \brief Description: Scale a sparse vector and add it to a scaled dense vector. -* -* \details -* \ref hipsparseAxpby multiplies the sparse vector \f$x\f$ with scalar \f$\alpha\f$ and -* adds the result to the dense vector \f$y\f$ that is multiplied with scalar -* \f$\beta\f$, such that -* -* \f[ -* y := \alpha \cdot x + \beta \cdot y -* \f] -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* y[x_ind[i]] = alpha * x_val[i] + beta * y[x_ind[i]] -* } -* \endcode -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Size of sparse and dense vector -* int size = 9; -* -* // Sparse index vector -* std::vector hx_ind = {0, 3, 5}; -* -* // Sparse value vector -* std::vector hx_val = {1.0f, 2.0f, 3.0f}; -* -* // Dense vector -* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // Scalar alpha -* float alpha = 3.7f; -* -* // Scalar beta -* float beta = 1.2f; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * size); -* -* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Create sparse vector X -* hipsparseSpVecDescr_t vecX; -* hipsparseCreateSpVec(&vecX, -* size, -* nnz, -* dx_ind, -* dx_val, -* HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, -* HIP_R_32F); -* -* // Create dense vector Y -* hipsparseDnVecDescr_t vecY; -* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); -* -* // Call axpby to perform y = beta * y + alpha * x -* hipsparseAxpby(handle, &alpha, vecX, &beta, vecY); -* -* hipsparseDnVecGetValues(vecY, (void**)&dy); -* -* // Copy result back to host -* hipMemcpy(hy.data(), dy, sizeof(float) * size, hipMemcpyDeviceToHost); -* -* -* // Clear hipSPARSE -* hipsparseDestroySpVec(vecX); -* hipsparseDestroyDnVec(vecY); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, - const void* alpha, - hipsparseConstSpVecDescr_t vecX, - const void* beta, - hipsparseDnVecDescr_t vecY); -#elif(CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, - const void* alpha, - hipsparseSpVecDescr_t vecX, - const void* beta, - hipsparseDnVecDescr_t vecY); -#endif - -/*! \ingroup generic_module -* \brief Description: Gather elements from a dense vector and store them into a sparse vector. -* -* \details -* \ref hipsparseGather gathers the elements from the dense vector \f$y\f$ and stores -* them in the sparse vector \f$x\f$. -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* x_val[i] = y[x_ind[i]]; -* } -* \endcode -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Size of sparse and dense vector -* int size = 9; -* -* // Sparse index vector -* std::vector hx_ind = {0, 3, 5}; -* -* // Dense vector -* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * size); -* -* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Create sparse vector X -* hipsparseSpVecDescr_t vecX; -* hipsparseCreateSpVec(&vecX, -* size, -* nnz, -* dx_ind, -* dx_val, -* HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, -* HIP_R_32F); -* -* // Create dense vector Y -* hipsparseDnVecDescr_t vecY; -* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); -* -* // Perform gather -* hipsparseGather(handle, vecY, vecX); -* -* hipsparseSpVecGetValues(vecX, (void**)&dx_val); -* -* // Copy result back to host -* std::vector hx_val(nnz, 0.0f); -* hipMemcpy(hx_val.data(), dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroySpVec(vecX); -* hipsparseDestroyDnVec(vecY); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, - hipsparseConstDnVecDescr_t vecY, - hipsparseSpVecDescr_t vecX); -#elif(CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, - hipsparseDnVecDescr_t vecY, - hipsparseSpVecDescr_t vecX); -#endif - -/*! \ingroup generic_module -* \brief Description: Scatter elements from a sparse vector into a dense vector. -* -* \details -* \ref hipsparseScatter scatters the elements from the sparse vector \f$x\f$ in the dense -* vector \f$y\f$. -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* y[x_ind[i]] = x_val[i]; -* } -* \endcode -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Size of sparse and dense vector -* int size = 9; -* -* // Sparse index vector -* std::vector hx_ind = {0, 3, 5}; -* -* // Sparse value vector -* std::vector hx_val = {1.0f, 2.0f, 3.0f}; -* -* // Dense vector -* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * size); -* -* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Create sparse vector X -* hipsparseSpVecDescr_t vecX; -* hipsparseCreateSpVec(&vecX, -* size, -* nnz, -* dx_ind, -* dx_val, -* HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, -* HIP_R_32F); -* -* // Create dense vector Y -* hipsparseDnVecDescr_t vecY; -* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); -* -* // Perform scatter -* hipsparseScatter(handle, vecX, vecY); -* -* hipsparseDnVecGetValues(vecY, (void**)&dy); -* -* // Copy result back to host -* hipMemcpy(hy.data(), dy, sizeof(float) * size, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroySpVec(vecX); -* hipsparseDestroyDnVec(vecY); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, - hipsparseConstSpVecDescr_t vecX, - hipsparseDnVecDescr_t vecY); -#elif(CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, - hipsparseSpVecDescr_t vecX, - hipsparseDnVecDescr_t vecY); -#endif - -/*! \ingroup generic_module -* \brief Description: Apply Givens rotation to a dense and a sparse vector. -* -* \details -* \ref hipsparseRot applies the Givens rotation matrix \f$G\f$ to the sparse vector -* \f$x\f$ and the dense vector \f$y\f$, where -* \f[ -* G = \begin{pmatrix} c & s \\ -s & c \end{pmatrix} -* \f] -* -* \code{.c} -* for(i = 0; i < nnz; ++i) -* { -* x_tmp = x_val[i]; -* y_tmp = y[x_ind[i]]; -* -* x_val[i] = c * x_tmp + s * y_tmp; -* y[x_ind[i]] = c * y_tmp - s * x_tmp; -* } -* \endcode -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Size of sparse and dense vector -* int size = 9; -* -* // Sparse index vector -* std::vector hx_ind = {0, 3, 5}; -* -* // Sparse value vector -* std::vector hx_val = {1.0f, 2.0f, 3.0f}; -* -* // Dense vector -* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // Scalar c -* float c = 3.7f; -* -* // Scalar s -* float s = 1.2f; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * size); -* -* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Create sparse vector X -* hipsparseSpVecDescr_t vecX; -* hipsparseCreateSpVec(&vecX, -* size, -* nnz, -* dx_ind, -* dx_val, -* HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, -* HIP_R_32F); -* -* // Create dense vector Y -* hipsparseDnVecDescr_t vecY; -* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); -* -* // Call rot -* hipsparseRot(handle, (void*)&c, (void*)&s, vecX, vecY); -* -* hipsparseSpVecGetValues(vecX, (void**)&dx_val); -* hipsparseDnVecGetValues(vecY, (void**)&dy); -* -* // Copy result back to host -* hipMemcpy(hx_val.data(), dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); -* hipMemcpy(hy.data(), dy, sizeof(float) * size, hipMemcpyDeviceToHost); -* -* // Clear hipSPARSE -* hipsparseDestroySpVec(vecX); -* hipsparseDestroyDnVec(vecY); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 11000 && CUDART_VERSION < 13000)) -DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseRot(hipsparseHandle_t handle, - const void* c_coeff, - const void* s_coeff, - hipsparseSpVecDescr_t vecX, - hipsparseDnVecDescr_t vecY); -#endif - -/*! \ingroup generic_module -* \brief Description: Sparse matrix to dense matrix conversion -* -* \details -* \p hipsparseSparseToDense_bufferSize computes the required user allocated buffer size needed when converting -* a sparse matrix to a dense matrix. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSparseToDense_bufferSize(hipsparseHandle_t handle, - hipsparseConstSpMatDescr_t matA, - hipsparseDnMatDescr_t matB, - hipsparseSparseToDenseAlg_t alg, - size_t* bufferSize); -#elif(CUDART_VERSION >= 11020) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSparseToDense_bufferSize(hipsparseHandle_t handle, - hipsparseSpMatDescr_t matA, - hipsparseDnMatDescr_t matB, - hipsparseSparseToDenseAlg_t alg, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Sparse matrix to dense matrix conversion -* -* \details -* \p hipsparseSparseToDense converts a sparse matrix to a dense matrix. This routine takes a user allocated buffer -* whose size must first be computed by calling \p hipsparseSparseToDense_bufferSize -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, - hipsparseConstSpMatDescr_t matA, - hipsparseDnMatDescr_t matB, - hipsparseSparseToDenseAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION >= 11020) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, - hipsparseSpMatDescr_t matA, - hipsparseDnMatDescr_t matB, - hipsparseSparseToDenseAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Dense matrix to sparse matrix conversion -* -* \details -* \p hipsparseDenseToSparse_bufferSize computes the required user allocated buffer size needed when converting -* a dense matrix to a sparse matrix. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDenseToSparse_bufferSize(hipsparseHandle_t handle, - hipsparseConstDnMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseDenseToSparseAlg_t alg, - size_t* bufferSize); -#elif(CUDART_VERSION >= 11020) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDenseToSparse_bufferSize(hipsparseHandle_t handle, - hipsparseDnMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseDenseToSparseAlg_t alg, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Dense matrix to sparse matrix conversion -* -* \details -* \p hipsparseDenseToSparse_analysis performs analysis that is later used in \p hipsparseDenseToSparse_convert when -* converting a dense matrix to sparse matrix. This routine takes a user allocated buffer whose size must first be computed -* using \p hipsparseDenseToSparse_bufferSize. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDenseToSparse_analysis(hipsparseHandle_t handle, - hipsparseConstDnMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseDenseToSparseAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION >= 11020) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDenseToSparse_analysis(hipsparseHandle_t handle, - hipsparseDnMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseDenseToSparseAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Dense matrix to sparse matrix conversion -* -* \details -* \p hipsparseDenseToSparse_convert converts a dense matrix to a sparse matrix. This routine requires a user allocated buffer -* whose size must be determined by first calling \p hipsparseDenseToSparse_bufferSize. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t handle, - hipsparseConstDnMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseDenseToSparseAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION >= 11020) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t handle, - hipsparseDnMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseDenseToSparseAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Compute the inner dot product of a sparse vector with a dense vector -* -* \details -* \p hipsparseSpVV_bufferSize computes the required user allocated buffer size needed when computing the -* inner dot product of a sparse vector with a dense vector -* -* See full example below -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVV_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opX, - hipsparseConstSpVecDescr_t vecX, - hipsparseConstDnVecDescr_t vecY, - void* result, - hipDataType computeType, - size_t* bufferSize); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVV_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opX, - hipsparseSpVecDescr_t vecX, - hipsparseDnVecDescr_t vecY, - void* result, - hipDataType computeType, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Compute the inner dot product of a sparse vector with a dense vector -* -* \details -* \p hipsparseSpVV computes the inner dot product of a sparse vector with a dense vector. This routine takes a user -* allocated buffer whose size must first be computed by calling \p hipsparseSpVV_bufferSize -* -* \par Example -* \code{.c} -* // Number of non-zeros of the sparse vector -* int nnz = 3; -* -* // Size of sparse and dense vector -* int size = 9; -* -* // Sparse index vector -* std::vector hx_ind = {0, 3, 5}; -* -* // Sparse value vector -* std::vector hx_val = {1.0f, 2.0f, 3.0f}; -* -* // Dense vector -* std::vector hy = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; -* -* // Offload data to device -* int* dx_ind; -* float* dx_val; -* float* dy; -* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); -* hipMalloc((void**)&dx_val, sizeof(float) * nnz); -* hipMalloc((void**)&dy, sizeof(float) * size); -* -* hipMemcpy(dx_ind, hx_ind.data(), sizeof(int) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dx_val, hx_val.data(), sizeof(float) * nnz, hipMemcpyHostToDevice); -* hipMemcpy(dy, hy.data(), sizeof(float) * size, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* // Create sparse vector X -* hipsparseSpVecDescr_t vecX; -* hipsparseCreateSpVec(&vecX, -* size, -* nnz, -* dx_ind, -* dx_val, -* HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, -* HIP_R_32F); -* -* // Create dense vector Y -* hipsparseDnVecDescr_t vecY; -* hipsparseCreateDnVec(&vecY, size, dy, HIP_R_32F); -* -* // Obtain buffer size -* float hresult = 0.0f; -* size_t buffer_size; -* hipsparseSpVV_bufferSize(handle, -* HIPSPARSE_OPERATION_NON_TRANSPOSE, -* vecX, -* vecY, -* &hresult, -* HIP_R_32F, -* &buffer_size); -* -* void* temp_buffer; -* hipMalloc(&temp_buffer, buffer_size); -* -* // SpVV -* hipsparseSpVV(handle, -* HIPSPARSE_OPERATION_NON_TRANSPOSE, -* vecX, -* vecY, -* &hresult, -* HIP_R_32F, -* temp_buffer); -* -* hipDeviceSynchronize(); -* -* std::cout << "hresult: " << hresult << std::endl; -* -* // Clear hipSPARSE -* hipsparseDestroySpVec(vecX); -* hipsparseDestroyDnVec(vecY); -* hipsparseDestroy(handle); -* -* // Clear device memory -* hipFree(dx_ind); -* hipFree(dx_val); -* hipFree(dy); -* hipFree(temp_buffer); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, - hipsparseOperation_t opX, - hipsparseConstSpVecDescr_t vecX, - hipsparseConstDnVecDescr_t vecY, - void* result, - hipDataType computeType, - void* externalBuffer); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, - hipsparseOperation_t opX, - hipsparseSpVecDescr_t vecX, - hipsparseDnVecDescr_t vecY, - void* result, - hipDataType computeType, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Buffer size step of the sparse matrix multiplication with a dense vector -* -* \details -* \p hipsparseSpMV_bufferSize computes the required user allocated buffer size needed when computing the -* sparse matrix multiplication with a dense vector -* -* See full example below -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMV_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnVecDescr_t vecX, - const void* beta, - const hipsparseDnVecDescr_t vecY, - hipDataType computeType, - hipsparseSpMVAlg_t alg, - size_t* bufferSize); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMV_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnVecDescr_t vecX, - const void* beta, - const hipsparseDnVecDescr_t vecY, - hipDataType computeType, - hipsparseSpMVAlg_t alg, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Preprocess step of the sparse matrix multiplication with a dense vector (optional) -* -* \details -* \p hipsparseSpMV_preprocess performs the optional preprocess used when computing the -* sparse matrix multiplication with a dense vector. This step is optional but if used may -* results in better performance. -* -* See full example below -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMV_preprocess(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnVecDescr_t vecX, - const void* beta, - const hipsparseDnVecDescr_t vecY, - hipDataType computeType, - hipsparseSpMVAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMV_preprocess(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnVecDescr_t vecX, - const void* beta, - const hipsparseDnVecDescr_t vecY, - hipDataType computeType, - hipsparseSpMVAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Compute the sparse matrix multiplication with a dense vector -* -* \details -* \p hipsparseSpMV computes sparse matrix multiplication with a dense vector -* -* \par Example -* \code{.c} -* // A, x, and y are m×k, k×1, and m×1 -* int m = 3, k = 4; -* int nnz_A = 8; -* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* -* // alpha and beta -* float alpha = 0.5f; -* float beta = 0.25f; -* -* std::vector hcsr_row_ptr = {0, 3, 5, 8}; -* std::vector hcsr_col_ind = {0, 1, 3, 1, 2, 0, 2, 3}; -* std::vector hcsr_val = {1, 2, 3, 4, 5, 6, 7, 8}; -* -* std::vector hx(k, 1.0f); -* std::vector hy(m, 1.0f); -* -* int *dcsr_row_ptr; -* int *dcsr_col_ind; -* float *dcsr_val; -* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz_A); -* hipMalloc((void**)&dcsr_val, sizeof(float) * nnz_A); -* -* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr.data(), sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_ind, hcsr_col_ind.data(), sizeof(int) * nnz_A, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_val, hcsr_val.data(), sizeof(float) * nnz_A, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* hipsparseSpMatDescr_t matA; -* hipsparseCreateCsr(&matA, m, k, nnz_A, -* dcsr_row_ptr, dcsr_col_ind, dcsr_val, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* -* // Allocate memory for the vector x -* float* dx; -* hipMalloc((void**)&dx, sizeof(float) * k); -* hipMemcpy(dx, hx.data(), sizeof(float) * k, hipMemcpyHostToDevice); -* -* hipsparseDnVecDescr_t vecX; -* hipsparseCreateDnVec(&vecX, k, dx, HIP_R_32F); -* -* // Allocate memory for the resulting vector y -* float* dy; -* hipMalloc((void**)&dy, sizeof(float) * m); -* hipMemcpy(dy, hy.data(), sizeof(float) * m, hipMemcpyHostToDevice); -* -* hipsparseDnMatDescr_t vecY; -* hipsparseCreateDnVec(&vecY, m, dy, HIP_R_32F); -* -* // Compute buffersize -* size_t bufferSize; -* hipsparseSpMV_bufferSize(handle, -* transA, -* &alpha, -* matA, -* vecX, -* &beta, -* vecY, -* HIP_R_32F, -* HIPSPARSE_MV_ALG_DEFAULT, -* &bufferSize); -* -* void* buffer; -* hipMalloc(&buffer, bufferSize); -* -* // Preprocess operation (Optional) -* hipsparseSpMV_preprocess(handle, -* transA, -* &alpha, -* matA, -* vecX, -* &beta, -* vecY, -* HIP_R_32F, -* HIPSPARSE_MV_ALG_DEFAULT, -* &buffer); -* -* // Perform operation -* hipsparseSpMV(handle, -* transA, -* &alpha, -* matA, -* vecX, -* &beta, -* vecY, -* HIP_R_32F, -* HIPSPARSE_MV_ALG_DEFAULT, -* &buffer); -* -* // Copy device to host -* hipMemcpy(hy.data(), dy, sizeof(float) * m, hipMemcpyDeviceToHost); -* -* // Destroy matrix descriptors and handles -* hipsparseDestroySpMat(matA); -* hipsparseDestroyDnVec(vecX); -* hipsparseDestroyDnVec(vecY); -* hipsparseDestroy(handle); -* -* hipFree(buffer); -* hipFree(dcsr_row_ptr); -* hipFree(dcsr_col_ind); -* hipFree(dcsr_val); -* hipFree(dx); -* hipFree(dy); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnVecDescr_t vecX, - const void* beta, - const hipsparseDnVecDescr_t vecY, - hipDataType computeType, - hipsparseSpMVAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnVecDescr_t vecX, - const void* beta, - const hipsparseDnVecDescr_t vecY, - hipDataType computeType, - hipsparseSpMVAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Calculate the buffer size required for the sparse matrix multiplication with a dense matrix -* -* \details -* \p hipsparseSpMM_bufferSize computes the required user allocated buffer size needed when computing the -* sparse matrix multiplication with a dense matrix -* -* See full example below -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMM_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnMatDescr_t matB, - const void* beta, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpMMAlg_t alg, - size_t* bufferSize); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMM_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnMatDescr_t matB, - const void* beta, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpMMAlg_t alg, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Preprocess step of the sparse matrix multiplication with a dense matrix. -* -* \details -* \p hipsparseSpMM_preprocess performs the required preprocessing used when computing the -* sparse matrix multiplication with a dense matrix -* -* See full example below -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMM_preprocess(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnMatDescr_t matB, - const void* beta, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpMMAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION >= 11021) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMM_preprocess(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnMatDescr_t matB, - const void* beta, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpMMAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Compute the sparse matrix multiplication with a dense matrix -* -* \details -* \p hipsparseSpMM computes sparse matrix multiplication with a dense matrix -* -* \par Example -* \code{.c} -* // A, B, and C are m×k, k×n, and m×n -* int m = 3, n = 5, k = 4; -* int ldb = n, ldc = n; -* int nnz_A = 8, nnz_B = 20, nnz_C = 15; -* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseOperation_t transB = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseOperation_t transC = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseOrder_t order = HIPSPARSE_ORDER_ROW; -* -* // alpha and beta -* float alpha = 0.5f; -* float beta = 0.25f; -* -* std::vector hcsr_row_ptr = {0, 3, 5, 8}; -* std::vector hcsr_col_ind = {0, 1, 3, 1, 2, 0, 2, 3}; -* std::vector hcsr_val = {1, 2, 3, 4, 5, 6, 7, 8}; -* -* std::vector hB(nnz_B, 1.0f); -* std::vector hC(nnz_C, 1.0f); -* -* int *dcsr_row_ptr; -* int *dcsr_col_ind; -* float *dcsr_val; -* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); -* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz_A); -* hipMalloc((void**)&dcsr_val, sizeof(float) * nnz_A); -* -* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr.data(), sizeof(int) * (m + 1), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_ind, hcsr_col_ind.data(), sizeof(int) * nnz_A, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_val, hcsr_val.data(), sizeof(float) * nnz_A, hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle; -* hipsparseCreate(&handle); -* -* hipsparseSpMatDescr_t matA; -* hipsparseCreateCsr(&matA, m, k, nnz_A, -* dcsr_row_ptr, dcsr_col_ind, dcsr_val, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* -* // Allocate memory for the matrix B -* float* dB; -* hipMalloc((void**)&dB, sizeof(float) * nnz_B); -* hipMemcpy(dB, hB.data(), sizeof(float) * nnz_B, hipMemcpyHostToDevice); -* -* hipsparseDnMatDescr_t matB; -* hipsparseCreateDnMat(&matB, k, n, ldb, dB, HIP_R_32F, order); -* -* // Allocate memory for the resulting matrix C -* float* dC; -* hipMalloc((void**)&dC, sizeof(float) * nnz_C); -* hipMemcpy(dC, hC.data(), sizeof(float) * nnz_C, hipMemcpyHostToDevice); -* -* hipsparseDnMatDescr_t matC; -* hipsparseCreateDnMat(&matC, m, n, ldc, dC, HIP_R_32F, HIPSPARSE_ORDER_ROW); -* -* // Compute buffersize -* size_t bufferSize; -* hipsparseSpMM_bufferSize(handle, -* transA, -* transB, -* &alpha, -* matA, -* matB, -* &beta, -* matC, -* HIP_R_32F, -* HIPSPARSE_MM_ALG_DEFAULT, -* &bufferSize); -* -* void* buffer; -* hipMalloc(&buffer, bufferSize); -* -* // Preprocess operation (Optional) -* hipsparseSpMM_preprocess(handle, -* transA, -* transB, -* &alpha, -* matA, -* matB, -* &beta, -* matC, -* HIP_R_32F, -* HIPSPARSE_MM_ALG_DEFAULT, -* &buffer); -* -* // Perform operation -* hipsparseSpMM(handle, -* transA, -* transB, -* &alpha, -* matA, -* matB, -* &beta, -* matC, -* HIP_R_32F, -* HIPSPARSE_MM_ALG_DEFAULT, -* &buffer); -* -* // Copy device to host -* hipMemcpy(hC.data(), dC, sizeof(float) * nnz_C, hipMemcpyDeviceToHost); -* -* // Destroy matrix descriptors and handles -* hipsparseDestroySpMat(matA); -* hipsparseDestroyDnMat(matB); -* hipsparseDestroyDnMat(matC); -* hipsparseDestroy(handle); -* -* hipFree(buffer); -* hipFree(dcsr_row_ptr); -* hipFree(dcsr_col_ind); -* hipFree(dcsr_val); -* hipFree(dB); -* hipFree(dC); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnMatDescr_t matB, - const void* beta, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpMMAlg_t alg, - void* externalBuffer); -#elif(CUDART_VERSION >= 10010) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnMatDescr_t matB, - const void* beta, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpMMAlg_t alg, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Create sparse matrix sparse matrix product descriptor -* \details -* \p hipsparseSpGEMM_createDescr creates a sparse matrix sparse matrix product descriptor. It should be -* destroyed at the end using hipsparseSpGEMM_destroyDescr(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_createDescr(hipsparseSpGEMMDescr_t* descr); -#endif - -/*! \ingroup generic_module -* \brief Description: Destroy sparse matrix sparse matrix product descriptor -* \details -* \p hipsparseSpGEMM_destroyDescr destroys a sparse matrix sparse matrix product descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_destroyDescr(hipsparseSpGEMMDescr_t descr); -#endif - -/*! \ingroup generic_module -* \brief Description: Work estimation step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C -* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. -* -* \details -* \p hipsparseSpGEMM_workEstimation is called twice. We call it to compute the size of the first required user allocated -* buffer. After this buffer size is determined, the user allocates it and calls \p hipsparseSpGEMM_workEstimation -* a second time with the newly allocated buffer passed in. This second call inspects the matrices A and B to -* determine the number of intermediate products that will result from multipltying A and B together. -* -* \par Example (See full example below) -* \code{.c} -* void* dBuffer1 = NULL; -* size_t bufferSize1 = 0; -* -* hipsparseSpGEMMDescr_t spgemmDesc; -* hipsparseSpGEMM_createDescr(&spgemmDesc); -* -* size_t bufferSize1 = 0; -* hipsparseSpGEMM_workEstimation(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize1, NULL); -* hipMalloc((void**) &dBuffer1, bufferSize1); -* -* // Determine number of intermediate product when computing A * B -* hipsparseSpGEMM_workEstimation(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize1, dBuffer1); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_workEstimation(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize1, - void* externalBuffer1); -#elif(CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_workEstimation(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize1, - void* externalBuffer1); -#endif - -/*! \ingroup generic_module -* \brief Description: Compute step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C -* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. -* -* \details -* \p hipsparseSpGEMM_compute is called twice. First to compute the size of the second required user allocated -* buffer. After this buffer size is determined, the user allocates it and calls \p hipsparseSpGEMM_compute -* a second time with the newly allocated buffer passed in. This second call performs the actual computation -* of C' = alpha * A * B (the result is stored in the temporary buffers). -* -* \par Example (See full example below) -* \code{.c} -* void* dBuffer2 = NULL; -* size_t bufferSize2 = 0; -* -* size_t bufferSize2 = 0; -* hipsparseSpGEMM_compute(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize2, NULL); -* hipMalloc((void**) &dBuffer2, bufferSize2); -* -* // compute the intermediate product of A * B -* hipsparseSpGEMM_compute(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize2, dBuffer2); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_compute(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize2, - void* externalBuffer2); -#elif(CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_compute(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize2, - void* externalBuffer2); -#endif - -/*! \ingroup generic_module -* \brief Description: Copy step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C -* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. -* -* \details -* \p hipsparseSpGEMM_copy is called once to copy the results (that are currently stored in the temporary arrays) -* to the output sparse matrix. If beta != 0, then the beta * C portion of the computation: C' = alpha * A * B + beta * C -* is handled. This is possible because C' and C must have the same sparsity pattern. -* -* \note The two user allocated temporary buffers can only be freed after the call to \p hipsparseSpGEMM_copy -* -* \par Example (Full example) -* \code{.c} -* hipsparseHandle_t handle = NULL; -* hipsparseSpMatDescr_t matA, matB, matC; -* void* dBuffer1 = NULL; -* void* dBuffer2 = NULL; -* size_t bufferSize1 = 0; -* size_t bufferSize2 = 0; -* -* hipsparseCreate(&handle); -* -* // Create sparse matrix A in CSR format -* hipsparseCreateCsr(&matA, m, k, nnzA, -* dcsr_row_ptrA, dcsr_col_indA, dcsr_valA, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* hipsparseCreateCsr(&matB, k, n, nnzB, -* dcsr_row_ptrB, dcsr_col_indB, dcsr_valB, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* hipsparseCreateCsr(&matC, m, n, 0, -* dcsr_row_ptrC, NULL, NULL, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* -* hipsparseSpGEMMDescr_t spgemmDesc; -* hipsparseSpGEMM_createDescr(&spgemmDesc); -* -* // Determine size of first user allocated buffer -* hipsparseSpGEMM_workEstimation(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize1, NULL); -* hipMalloc((void**) &dBuffer1, bufferSize1); -* -* // Inspect the matrices A and B to determine the number of intermediate product in -* // C = alpha * A * B -* hipsparseSpGEMM_workEstimation(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize1, dBuffer1); -* -* // Determine size of second user allocated buffer -* hipsparseSpGEMM_compute(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize2, NULL); -* hipMalloc((void**) &dBuffer2, bufferSize2); -* -* // Compute C = alpha * A * B and store result in temporary buffers -* hipsparseSpGEMM_compute(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc, &bufferSize2, dBuffer2); -* -* // Get matrix C non-zero entries C_nnz1 -* int64_t C_num_rows1, C_num_cols1, C_nnz1; -* hipsparseSpMatGetSize(matC, &C_num_rows1, &C_num_cols1, &C_nnz1); -* -* // Allocate the CSR structures for the matrix C -* hipMalloc((void**) &dcsr_col_indC, C_nnz1 * sizeof(int)); -* hipMalloc((void**) &dcsr_valC, C_nnz1 * sizeof(float)); -* -* // Update matC with the new pointers -* hipsparseCsrSetPointers(matC, dcsr_row_ptrC, dcsr_col_indC, dcsr_valC); -* -* // Copy the final products to the matrix C -* hipsparseSpGEMM_copy(handle, opA, opB, -* &alpha, matA, matB, &beta, matC, -* computeType, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc); -* -* // Destroy matrix descriptors and handles -* hipsparseSpGEMM_destroyDescr(spgemmDesc); -* hipsparseDestroySpMat(matA); -* hipsparseDestroySpMat(matB); -* hipsparseDestroySpMat(matC); -* hipsparseDestroy(handle); -* -* // Free device memory -* hipFree(dBuffer1); -* hipFree(dBuffer2); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr); -#elif(CUDART_VERSION >= 11000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Work estimation step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C -* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. -* -* \details -* \p hipsparseSpGEMMreuse_workEstimation is called twice. We call it to compute the size of the first required user allocated -* buffer. After this buffer size is determined, the user allocates it and calls \p hipsparseSpGEMMreuse_workEstimation -* a second time with the newly allocated buffer passed in. This second call inspects the matrices A and B to -* determine the number of intermediate products that will result from multipltying A and B together. -* -* \par Example (See full example below) -* \code{.c} -* void* dBuffer1 = NULL; -* size_t bufferSize1 = 0; -* -* hipsparseSpGEMMDescr_t spgemmDesc; -* hipsparseSpGEMM_createDescr(&spgemmDesc); -* -* size_t bufferSize1 = 0; -* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize1, NULL); -* hipMalloc((void**) &dBuffer1, bufferSize1); -* -* // Determine number of intermediate product when computing A * B -* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize1, dBuffer1); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_workEstimation(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - hipsparseSpMatDescr_t matC, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize1, - void* externalBuffer1); -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_workEstimation(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseSpMatDescr_t matC, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize1, - void* externalBuffer1); -#endif - -/*! \ingroup generic_module -* \brief Description: Nnz calculation step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C -* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. -* -* \par Example (See full example below) -* \code{.c} -* // Determine size of second, third, and fourth user allocated buffer -* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, -* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize2, NULL, &bufferSize3, NULL, -* &bufferSize4, NULL); -* -* hipMalloc((void**) &dBuffer2, bufferSize2); -* hipMalloc((void**) &dBuffer3, bufferSize3); -* hipMalloc((void**) &dBuffer4, bufferSize4); -* -* // COmpute sparsity pattern of C matrix and store in temporary buffers -* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, -* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize2, dBuffer2, &bufferSize3, dBuffer3, -* &bufferSize4, dBuffer4); -* -* // We can now free buffer 1 and 2 -* hipFree(dBuffer1); -* hipFree(dBuffer2); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_nnz(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - hipsparseSpMatDescr_t matC, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize2, - void* externalBuffer2, - size_t* bufferSize3, - void* externalBuffer3, - size_t* bufferSize4, - void* externalBuffer4); - -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_nnz(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseSpMatDescr_t matC, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize2, - void* externalBuffer2, - size_t* bufferSize3, - void* externalBuffer3, - size_t* bufferSize4, - void* externalBuffer4); - -#endif - -/*! \ingroup generic_module -* \brief Description: Copy step of the sparse matrix sparse matrix product C' = alpha * A * B + beta * C -* where C', A, B, C are sparse matrices and C' and C have the same sparsity pattern. -* -* \par Example (See full example below) -* \code{.c} -* // Get matrix C non-zero entries nnzC -* int64_t rowsC, colsC, nnzC; -* hipsparseSpMatGetSize(matC, &rowsC, &colsC, &nnzC); -* -* // Allocate matrix C -* hipMalloc((void**) &dcsr_col_indC, sizeof(int) * nnzC); -* hipMalloc((void**) &dcsr_valC, sizeof(float) * nnzC); -* -* // Update matC with the new pointers. The C values array can be filled with data here -* // which is used if beta != 0. -* hipsparseCsrSetPointers(matC, dcsr_row_ptrC, dcsr_col_indC, dcsr_valC); -* -* // Determine size of fifth user allocated buffer -* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize5, NULL); -* -* hipMalloc((void**) &dBuffer5, bufferSize5); -* -* // Copy data from temporary buffers to the newly allocated C matrix -* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize5, dBuffer5); -* -* // We can now free buffer 3 -* hipFree(dBuffer3); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_copy(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - hipsparseSpMatDescr_t matC, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize5, - void* externalBuffer5); -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_copy(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - hipsparseSpMatDescr_t matC, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr, - size_t* bufferSize5, - void* externalBuffer5); -#endif - -/*! \ingroup generic_module -* \brief Description: Compute step of the sparse matrix sparse matrix product. -* -* \par Full example -* \code{.c} -* int m = 2; -* int k = 2; -* int n = 3; -* int nnzA = 4; -* int nnzB = 4; -* -* float alpha{1.0f}; -* float beta{0.0f}; -* -* hipsparseOperation_t opA = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipsparseOperation_t opB = HIPSPARSE_OPERATION_NON_TRANSPOSE; -* hipDataType computeType = HIP_R_32F; -* -* // A, B, and C are m×k, k×n, and m×n -* -* // A -* std::vector hcsr_row_ptrA = {0, 2, 4}; -* std::vector hcsr_col_indA = {0, 1, 0, 1}; -* std::vector hcsr_valA = {1.0f, 2.0f, 3.0f, 4.0f}; -* -* // B -* std::vector hcsr_row_ptrB = {0, 2, 4}; -* std::vector hcsr_col_indB = {1, 2, 0, 2}; -* std::vector hcsr_valB = {5.0f , 6.0f, 7.0f, 8.0f}; -* -* // Device memory management: Allocate and copy A, B -* int* dcsr_row_ptrA; -* int* dcsr_col_indA; -* float* dcsr_valA; -* int* dcsr_row_ptrB; -* int* dcsr_col_indB; -* float* dcsr_valB; -* int* dcsr_row_ptrC; -* int* dcsr_col_indC; -* float* dcsr_valC; -* hipMalloc((void**)&dcsr_row_ptrA, (m + 1) * sizeof(int)); -* hipMalloc((void**)&dcsr_col_indA, nnzA * sizeof(int)); -* hipMalloc((void**)&dcsr_valA, nnzA * sizeof(float)); -* hipMalloc((void**)&dcsr_row_ptrB, (k + 1) * sizeof(int)); -* hipMalloc((void**)&dcsr_col_indB, nnzB * sizeof(int)); -* hipMalloc((void**)&dcsr_valB, nnzB * sizeof(float)); -* hipMalloc((void**)&dcsr_row_ptrC, (m + 1) * sizeof(int)); -* -* hipMemcpy(dcsr_row_ptrA, hcsr_row_ptrA.data(), (m + 1) * sizeof(int), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_indA, hcsr_col_indA.data(), nnzA * sizeof(int), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_valA, hcsr_valA.data(), nnzA * sizeof(float), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_row_ptrB, hcsr_row_ptrB.data(), (k + 1) * sizeof(int), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_col_indB, hcsr_col_indB.data(), nnzB * sizeof(int), hipMemcpyHostToDevice); -* hipMemcpy(dcsr_valB, hcsr_valB.data(), nnzB * sizeof(float), hipMemcpyHostToDevice); -* -* hipsparseHandle_t handle = NULL; -* hipsparseSpMatDescr_t matA, matB, matC; -* void* dBuffer1 = NULL; -* void* dBuffer2 = NULL; -* void* dBuffer3 = NULL; -* void* dBuffer4 = NULL; -* void* dBuffer5 = NULL; -* size_t bufferSize1 = 0; -* size_t bufferSize2 = 0; -* size_t bufferSize3 = 0; -* size_t bufferSize4 = 0; -* size_t bufferSize5 = 0; -* -* hipsparseCreate(&handle); -* -* // Create sparse matrix A in CSR format -* hipsparseCreateCsr(&matA, m, k, nnzA, -* dcsr_row_ptrA, dcsr_col_indA, dcsr_valA, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* hipsparseCreateCsr(&matB, k, n, nnzB, -* dcsr_row_ptrB, dcsr_col_indB, dcsr_valB, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* hipsparseCreateCsr(&matC, m, n, 0, -* dcsr_row_ptrC, NULL, NULL, -* HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, -* HIPSPARSE_INDEX_BASE_ZERO, HIP_R_32F); -* -* hipsparseSpGEMMDescr_t spgemmDesc; -* hipsparseSpGEMM_createDescr(&spgemmDesc); -* -* // Determine size of first user allocated buffer -* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize1, NULL); -* -* hipMalloc((void**) &dBuffer1, bufferSize1); -* -* // Inspect the matrices A and B to determine the number of intermediate product in -* // C = alpha * A * B -* hipsparseSpGEMMreuse_workEstimation(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize1, dBuffer1); -* -* // Determine size of second, third, and fourth user allocated buffer -* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, -* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize2, NULL, &bufferSize3, NULL, -* &bufferSize4, NULL); -* -* hipMalloc((void**) &dBuffer2, bufferSize2); -* hipMalloc((void**) &dBuffer3, bufferSize3); -* hipMalloc((void**) &dBuffer4, bufferSize4); -* -* // COmpute sparsity pattern of C matrix and store in temporary buffers -* hipsparseSpGEMMreuse_nnz(handle, opA, opB, matA, matB, -* matC, HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize2, dBuffer2, &bufferSize3, dBuffer3, -* &bufferSize4, dBuffer4); -* -* // We can now free buffer 1 and 2 -* hipFree(dBuffer1); -* hipFree(dBuffer2); -* -* // Get matrix C non-zero entries nnzC -* int64_t rowsC, colsC, nnzC; -* hipsparseSpMatGetSize(matC, &rowsC, &colsC, &nnzC); -* -* // Allocate matrix C -* hipMalloc((void**) &dcsr_col_indC, sizeof(int) * nnzC); -* hipMalloc((void**) &dcsr_valC, sizeof(float) * nnzC); -* -* // Update matC with the new pointers. The C values array can be filled with data here -* // which is used if beta != 0. -* hipsparseCsrSetPointers(matC, dcsr_row_ptrC, dcsr_col_indC, dcsr_valC); -* -* // Determine size of fifth user allocated buffer -* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize5, NULL); -* -* hipMalloc((void**) &dBuffer5, bufferSize5); -* -* // Copy data from temporary buffers to the newly allocated C matrix -* hipsparseSpGEMMreuse_copy(handle, opA, opB, matA, matB, matC, -* HIPSPARSE_SPGEMM_DEFAULT, spgemmDesc, -* &bufferSize5, dBuffer5); -* -* // We can now free buffer 3 -* hipFree(dBuffer3); -* -* // Compute C' = alpha * A * B + beta * C -* hipsparseSpGEMMreuse_compute(handle, opA, opB, &alpha, matA, matB, &beta, -* matC, computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc); -* -* // Copy results back to host if required using hipsparseCsrGet... -* -* // Update dcsr_valA, dcsr_valB with new values -* for(size_t i = 0; i < hcsr_valA.size(); i++){ hcsr_valA[i] = 1.0f; } -* for(size_t i = 0; i < hcsr_valB.size(); i++){ hcsr_valB[i] = 2.0f; } -* -* hipMemcpy(dcsr_valA, hcsr_valA.data(), sizeof(float) * nnzA, hipMemcpyHostToDevice); -* hipMemcpy(dcsr_valB, hcsr_valB.data(), sizeof(float) * nnzB, hipMemcpyHostToDevice); -* -* // Compute C' = alpha * A * B + beta * C again with the new A and B values -* hipsparseSpGEMMreuse_compute(handle, opA, opB, &alpha, matA, matB, &beta, -* matC, computeType, HIPSPARSE_SPGEMM_DEFAULT, -* spgemmDesc); -* -* // Copy results back to host if required using hipsparseCsrGet... -* -* // Destroy matrix descriptors and handles -* hipsparseSpGEMM_destroyDescr(spgemmDesc); -* hipsparseDestroySpMat(matA); -* hipsparseDestroySpMat(matB); -* hipsparseDestroySpMat(matC); -* hipsparseDestroy(handle); -* -* // Free device memory -* hipFree(dBuffer4); -* hipFree(dBuffer5); -* hipFree(dcsr_row_ptrA); -* hipFree(dcsr_col_indA); -* hipFree(dcsr_valA); -* hipFree(dcsr_row_ptrB); -* hipFree(dcsr_col_indB); -* hipFree(dcsr_valB); -* hipFree(dcsr_row_ptrC); -* hipFree(dcsr_col_indC); -* hipFree(dcsr_valC); -* \endcode -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_compute(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr); -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpGEMMreuse_compute(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseSpMatDescr_t matA, - hipsparseSpMatDescr_t matB, - const void* beta, - hipsparseSpMatDescr_t matC, - hipDataType computeType, - hipsparseSpGEMMAlg_t alg, - hipsparseSpGEMMDescr_t spgemmDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Calculate the buffer size required for the sampled dense dense matrix multiplication -* -* \details -* \p hipsparseSDDMM_bufferSize computes the required user allocated buffer size needed when computing the -* sampled dense dense matrix multiplication -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSDDMM_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstDnMatDescr_t A, - hipsparseConstDnMatDescr_t B, - const void* beta, - hipsparseSpMatDescr_t C, - hipDataType computeType, - hipsparseSDDMMAlg_t alg, - size_t* bufferSize); -#elif(CUDART_VERSION >= 11022) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSDDMM_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseDnMatDescr_t A, - const hipsparseDnMatDescr_t B, - const void* beta, - hipsparseSpMatDescr_t C, - hipDataType computeType, - hipsparseSDDMMAlg_t alg, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Preprocess step of the sampled dense dense matrix multiplication. -* -* \details -* \p hipsparseSDDMM_preprocess performs the required preprocessing used when computing the -* sampled dense dense matrix multiplication -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSDDMM_preprocess(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstDnMatDescr_t A, - hipsparseConstDnMatDescr_t B, - const void* beta, - hipsparseSpMatDescr_t C, - hipDataType computeType, - hipsparseSDDMMAlg_t alg, - void* tempBuffer); -#elif(CUDART_VERSION >= 11022) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSDDMM_preprocess(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseDnMatDescr_t A, - const hipsparseDnMatDescr_t B, - const void* beta, - hipsparseSpMatDescr_t C, - hipDataType computeType, - hipsparseSDDMMAlg_t alg, - void* tempBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Sampled Dense-Dense Matrix Multiplication. -* -* \details -* \ref hipsparseSDDMM multiplies the scalar \f$\alpha\f$ with the dense -* \f$m \times k\f$ matrix \f$A\f$, the dense \f$k \times n\f$ matrix \f$B\f$, filtered by the sparsity pattern of the \f$m \times n\f$ sparse matrix \f$C\f$ and -* adds the result to \f$C\f$ scaled by -* \f$\beta\f$. The final result is stored in the sparse \f$m \times n\f$ matrix \f$C\f$, -* such that -* \f[ -* C := \alpha ( opA(A) \cdot opB(B) ) \cdot spy(C) + \beta C, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if opA == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if opA == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* \end{array} -* \right. -* \f], -* \f[ -* op(B) = \left\{ -* \begin{array}{ll} -* B, & \text{if opB == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* B^T, & \text{if opB == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* \end{array} -* \right. -* \f] -* and -* \f[ -* spy(C)_ij = \left\{ -* \begin{array}{ll} -* 1 \text{if i == j}, & 0 \text{if i != j} \\ -* \end{array} -* \right. -* \f] -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstDnMatDescr_t A, - hipsparseConstDnMatDescr_t B, - const void* beta, - hipsparseSpMatDescr_t C, - hipDataType computeType, - hipsparseSDDMMAlg_t alg, - void* tempBuffer); -#elif(CUDART_VERSION >= 11022) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseDnMatDescr_t A, - const hipsparseDnMatDescr_t B, - const void* beta, - hipsparseSpMatDescr_t C, - hipDataType computeType, - hipsparseSDDMMAlg_t alg, - void* tempBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Create sparse matrix triangular solve descriptor -* \details -* \p hipsparseSpGEMM_createDescr creates a sparse matrix triangular solve descriptor. It should be -* destroyed at the end using hipsparseSpSV_destroyDescr(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_createDescr(hipsparseSpSVDescr_t* descr); -#endif - -/*! \ingroup generic_module -* \brief Description: Destroy sparse matrix triangular solve descriptor -* \details -* \p hipsparseSpSV_destroyDescr destroys a sparse matrix triangular solve descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_destroyDescr(hipsparseSpSVDescr_t descr); -#endif - -/*! \ingroup generic_module -* \brief Description: Buffer size step of solution of triangular linear system op(A) * Y = alpha * X, -* where A is a sparse matrix in CSR storage format, x and Y are dense vectors. -* -* \details -* \p hipsparseSpSV_bufferSize computes the required user allocated buffer size needed when computing the -* solution of triangular linear system op(A) * Y = alpha * X, where A is a sparse matrix in CSR storage -* format, x and Y are dense vectors. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnVecDescr_t x, - const hipsparseDnVecDescr_t y, - hipDataType computeType, - hipsparseSpSVAlg_t alg, - hipsparseSpSVDescr_t spsvDescr, - size_t* bufferSize); -#elif(CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnVecDescr_t x, - const hipsparseDnVecDescr_t y, - hipDataType computeType, - hipsparseSpSVAlg_t alg, - hipsparseSpSVDescr_t spsvDescr, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Analysis step of solution of triangular linear system op(A) * Y = alpha * X, -* where A is a sparse matrix in CSR storage format, x and Y are dense vectors. -* -* \details -* \p hipsparseSpSV_analysis performs the required analysis used when computing the -* solution of triangular linear system op(A) * Y = alpha * X, -* where A is a sparse matrix in CSR storage format, x and Y are dense vectors. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_analysis(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnVecDescr_t x, - const hipsparseDnVecDescr_t y, - hipDataType computeType, - hipsparseSpSVAlg_t alg, - hipsparseSpSVDescr_t spsvDescr, - void* externalBuffer); -#elif(CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_analysis(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnVecDescr_t x, - const hipsparseDnVecDescr_t y, - hipDataType computeType, - hipsparseSpSVAlg_t alg, - hipsparseSpSVDescr_t spsvDescr, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Sparse triangular solve -* -* \details -* \p hipsparseSpSV_solve solves a sparse triangular linear system of a sparse -* \f$m \times m\f$ matrix, defined in CSR or COO storage format, a dense solution vector -* \f$y\f$ and the right-hand side \f$x\f$ that is multiplied by \f$\alpha\f$, such that -* \f[ -* op(A) \cdot y = \alpha \cdot x, -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnVecDescr_t x, - const hipsparseDnVecDescr_t y, - hipDataType computeType, - hipsparseSpSVAlg_t alg, - hipsparseSpSVDescr_t spsvDescr); -#elif(CUDART_VERSION >= 11030) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, - hipsparseOperation_t opA, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnVecDescr_t x, - const hipsparseDnVecDescr_t y, - hipDataType computeType, - hipsparseSpSVAlg_t alg, - hipsparseSpSVDescr_t spsvDescr); -#endif - -/*! \ingroup generic_module -* \brief Description: Create sparse matrix triangular solve with multiple rhs descriptor -* \details -* \p hipsparseSpSM_createDescr creates a sparse matrix triangular solve with multiple rhs descriptor. It should be -* destroyed at the end using hipsparseSpSM_destroyDescr(). -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_createDescr(hipsparseSpSMDescr_t* descr); -#endif - -/*! \ingroup generic_module -* \brief Description: Destroy sparse matrix triangular solve with multiple rhs descriptor -* \details -* \p hipsparseSpSM_destroyDescr destroys a sparse matrix triangular solve with multiple rhs descriptor and releases all -* resources used by the descriptor. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_destroyDescr(hipsparseSpSMDescr_t descr); -#endif - -/*! \ingroup generic_module -* \brief Description: Buffer size step of solution of triangular linear system op(A) * C = alpha * op(B), -* where A is a sparse matrix in CSR storage format, B and C are dense matrices. -* -* \details -* \p hipsparseSpSV_bufferSize computes the required user allocated buffer size needed when computing the -* solution of triangular linear system op(A) * C = alpha * op(B), where A is a sparse matrix in CSR storage -* format, B and C are dense matrices. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnMatDescr_t matB, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpSMAlg_t alg, - hipsparseSpSMDescr_t spsmDescr, - size_t* bufferSize); -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_bufferSize(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnMatDescr_t matB, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpSMAlg_t alg, - hipsparseSpSMDescr_t spsmDescr, - size_t* bufferSize); -#endif - -/*! \ingroup generic_module -* \brief Description: Analysis step of solution of triangular linear system op(A) * C = alpha * op(B), -* where A is a sparse matrix in CSR storage format, B and C are dense vectors. -* -* \details -* \p hipsparseSpSV_analysis performs the required analysis used when computing the -* solution of triangular linear system op(A) * C = alpha * op(B), -* where A is a sparse matrix in CSR storage format, B and C are dense vectors. -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_analysis(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnMatDescr_t matB, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpSMAlg_t alg, - hipsparseSpSMDescr_t spsmDescr, - void* externalBuffer); -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_analysis(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnMatDescr_t matB, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpSMAlg_t alg, - hipsparseSpSMDescr_t spsmDescr, - void* externalBuffer); -#endif - -/*! \ingroup generic_module -* \brief Description: Sparse triangular system solve -* -* \details -* \p hipsparseSpSM_solve solves a sparse triangular linear system of a sparse -* \f$m \times m\f$ matrix, defined in CSR or COO storage format, a dense solution matrix -* \f$C\f$ and the right-hand side \f$B\f$ that is multiplied by \f$\alpha\f$, such that -* \f[ -* op(A) \cdot C = \alpha \cdot op(B), -* \f] -* with -* \f[ -* op(A) = \left\{ -* \begin{array}{ll} -* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -* and -* \f[ -* op(B) = \left\{ -* \begin{array}{ll} -* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ -* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ -* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} -* \end{array} -* \right. -* \f] -*/ -#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - hipsparseConstSpMatDescr_t matA, - hipsparseConstDnMatDescr_t matB, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpSMAlg_t alg, - hipsparseSpSMDescr_t spsmDescr, - void* externalBuffer); -#elif(CUDART_VERSION >= 11031) -HIPSPARSE_EXPORT -hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, - hipsparseOperation_t opA, - hipsparseOperation_t opB, - const void* alpha, - const hipsparseSpMatDescr_t matA, - const hipsparseDnMatDescr_t matB, - const hipsparseDnMatDescr_t matC, - hipDataType computeType, - hipsparseSpSMAlg_t alg, - hipsparseSpSMDescr_t spsmDescr, - void* externalBuffer); -#endif - -#ifdef __cplusplus -} -#endif +/* Generic API functions */ +#include "generic/hipsparse_axpby.h" +#include "generic/hipsparse_gather.h" +#include "generic/hipsparse_scatter.h" +#include "generic/hipsparse_rot.h" +#include "generic/hipsparse_sparse2dense.h" +#include "generic/hipsparse_dense2sparse.h" +#include "generic/hipsparse_spvv.h" +#include "generic/hipsparse_spmv.h" +#include "generic/hipsparse_spmm.h" +#include "generic/hipsparse_spgemm.h" +#include "generic/hipsparse_spgemm_reuse.h" +#include "generic/hipsparse_sddmm.h" +#include "generic/hipsparse_spsv.h" +#include "generic/hipsparse_spsm.h" #endif // HIPSPARSE_H diff --git a/library/include/hipsparse_auxiliary.h b/library/include/hipsparse_auxiliary.h new file mode 100644 index 00000000..79d1af30 --- /dev/null +++ b/library/include/hipsparse_auxiliary.h @@ -0,0 +1,589 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup aux_module + * \brief Create a hipsparse handle + * + * \details + * \p hipsparseCreate creates the hipSPARSE library context. It must be + * initialized before any other hipSPARSE API function is invoked and must be passed to + * all subsequent library function calls. The handle should be destroyed at the end + * using hipsparseDestroy(). + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreate(hipsparseHandle_t* handle); + +/*! \ingroup aux_module + * \brief Destroy a hipsparse handle + * + * \details + * \p hipsparseDestroy destroys the hipSPARSE library context and releases all + * resources used by the hipSPARSE library. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroy(hipsparseHandle_t handle); + +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10000) +/*! \ingroup aux_module + * \brief Return the string representation of a hipSPARSE status's matching backend status enum name + * + * \details + * \p hipsparseGetErrorName takes a hipSPARSE status as input and first converts it to the matching backend + * status (either rocsparse_status or cusparseStatus_t). It then returns the string representation of this status + * enum name. If the status is not recognized, the function returns "Unrecognized status code". + * + * For example, hipsparseGetErrorName(HIPSPARSE_STATUS_SUCCESS) on a system with a rocSPARSE backend will + * return "rocsparse_status_success". On a system with a cuSPARSE backend this function would return + * "CUSPARSE_STATUS_SUCCESS". + */ +HIPSPARSE_EXPORT +const char* hipsparseGetErrorName(hipsparseStatus_t status); + +/*! \ingroup aux_module + * \brief Return the hipSPARSE status's matching backend status description as a string + * + * \details + * \p hipsparseGetErrorString takes a hipSPARSE status as input and first converts it to the matching backend + * status (either rocsparse_status or cusparseStatus_t). It then returns the string description of this status. + * If the status is not recognized, the function returns "Unrecognized status code". + */ +HIPSPARSE_EXPORT +const char* hipsparseGetErrorString(hipsparseStatus_t status); +#endif + +/*! \ingroup aux_module + * \brief Get hipSPARSE version + * + * \details + * \p hipsparseGetVersion gets the hipSPARSE library version number. + * - patch = version % 100 + * - minor = version / 100 % 1000 + * - major = version / 100000 + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseGetVersion(hipsparseHandle_t handle, int* version); + +/*! \ingroup aux_module + * \brief Get hipSPARSE git revision + * + * \details + * \p hipsparseGetGitRevision gets the hipSPARSE library git commit revision (SHA-1). + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseGetGitRevision(hipsparseHandle_t handle, char* rev); + +/*! \ingroup aux_module + * \brief Specify user defined HIP stream + * + * \details + * \p hipsparseSetStream specifies the stream to be used by the hipSPARSE library + * context and all subsequent function calls. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSetStream(hipsparseHandle_t handle, hipStream_t streamId); + +/*! \ingroup aux_module + * \brief Get current stream from library context + * + * \details + * \p hipsparseGetStream gets the hipSPARSE library context stream which is currently + * used for all subsequent function calls. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseGetStream(hipsparseHandle_t handle, hipStream_t* streamId); + +/*! \ingroup aux_module + * \brief Specify pointer mode + * + * \details + * \p hipsparseSetPointerMode specifies the pointer mode to be used by the hipSPARSE + * library context and all subsequent function calls. By default, all values are passed + * by reference on the host. Valid pointer modes are \ref HIPSPARSE_POINTER_MODE_HOST + * or \ref HIPSPARSE_POINTER_MODE_DEVICE. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSetPointerMode(hipsparseHandle_t handle, hipsparsePointerMode_t mode); + +/*! \ingroup aux_module + * \brief Get current pointer mode from library context + * + * \details + * \p hipsparseGetPointerMode gets the hipSPARSE library context pointer mode which + * is currently used for all subsequent function calls. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseGetPointerMode(hipsparseHandle_t handle, hipsparsePointerMode_t* mode); + +/*! \ingroup aux_module + * \brief Create a matrix descriptor + * \details + * \p hipsparseCreateMatDescr creates a matrix descriptor. It initializes + * \ref hipsparseMatrixType_t to \ref HIPSPARSE_MATRIX_TYPE_GENERAL and + * \ref hipsparseIndexBase_t to \ref HIPSPARSE_INDEX_BASE_ZERO. It should be destroyed + * at the end using hipsparseDestroyMatDescr(). + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateMatDescr(hipsparseMatDescr_t* descrA); + +/*! \ingroup aux_module + * \brief Destroy a matrix descriptor + * + * \details + * \p hipsparseDestroyMatDescr destroys a matrix descriptor and releases all + * resources used by the descriptor. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyMatDescr(hipsparseMatDescr_t descrA); + +/*! \ingroup aux_module + * \brief Copy a matrix descriptor + * \details + * \p hipsparseCopyMatDescr copies a matrix descriptor. Both, source and destination + * matrix descriptors must be initialized prior to calling \p hipsparseCopyMatDescr. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCopyMatDescr(hipsparseMatDescr_t dest, const hipsparseMatDescr_t src); + +/*! \ingroup aux_module + * \brief Specify the matrix type of a matrix descriptor + * + * \details + * \p hipsparseSetMatType sets the matrix type of a matrix descriptor. Valid + * matrix types are \ref HIPSPARSE_MATRIX_TYPE_GENERAL, + * \ref HIPSPARSE_MATRIX_TYPE_SYMMETRIC, \ref HIPSPARSE_MATRIX_TYPE_HERMITIAN or + * \ref HIPSPARSE_MATRIX_TYPE_TRIANGULAR. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSetMatType(hipsparseMatDescr_t descrA, hipsparseMatrixType_t type); + +/*! \ingroup aux_module + * \brief Get the matrix type of a matrix descriptor + * + * \details + * \p hipsparseGetMatType returns the matrix type of a matrix descriptor. + */ +HIPSPARSE_EXPORT +hipsparseMatrixType_t hipsparseGetMatType(const hipsparseMatDescr_t descrA); + +/*! \ingroup aux_module + * \brief Specify the matrix fill mode of a matrix descriptor + * + * \details + * \p hipsparseSetMatFillMode sets the matrix fill mode of a matrix descriptor. + * Valid fill modes are \ref HIPSPARSE_FILL_MODE_LOWER or + * \ref HIPSPARSE_FILL_MODE_UPPER. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSetMatFillMode(hipsparseMatDescr_t descrA, hipsparseFillMode_t fillMode); + +/*! \ingroup aux_module + * \brief Get the matrix fill mode of a matrix descriptor + * + * \details + * \p hipsparseGetMatFillMode returns the matrix fill mode of a matrix descriptor. + */ +HIPSPARSE_EXPORT +hipsparseFillMode_t hipsparseGetMatFillMode(const hipsparseMatDescr_t descrA); + +/*! \ingroup aux_module + * \brief Specify the matrix diagonal type of a matrix descriptor + * + * \details + * \p hipsparseSetMatDiagType sets the matrix diagonal type of a matrix + * descriptor. Valid diagonal types are \ref HIPSPARSE_DIAG_TYPE_UNIT or + * \ref HIPSPARSE_DIAG_TYPE_NON_UNIT. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSetMatDiagType(hipsparseMatDescr_t descrA, hipsparseDiagType_t diagType); + +/*! \ingroup aux_module + * \brief Get the matrix diagonal type of a matrix descriptor + * + * \details + * \p hipsparseGetMatDiagType returns the matrix diagonal type of a matrix + * descriptor. + */ +HIPSPARSE_EXPORT +hipsparseDiagType_t hipsparseGetMatDiagType(const hipsparseMatDescr_t descrA); + +/*! \ingroup aux_module + * \brief Specify the index base of a matrix descriptor + * + * \details + * \p hipsparseSetMatIndexBase sets the index base of a matrix descriptor. Valid + * options are \ref HIPSPARSE_INDEX_BASE_ZERO or \ref HIPSPARSE_INDEX_BASE_ONE. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSetMatIndexBase(hipsparseMatDescr_t descrA, hipsparseIndexBase_t base); + +/*! \ingroup aux_module + * \brief Get the index base of a matrix descriptor + * + * \details + * \p hipsparseGetMatIndexBase returns the index base of a matrix descriptor. + */ +HIPSPARSE_EXPORT +hipsparseIndexBase_t hipsparseGetMatIndexBase(const hipsparseMatDescr_t descrA); + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup aux_module + * \brief Create a \p HYB matrix structure + * + * \details + * \p hipsparseCreateHybMat creates a structure that holds the matrix in \p HYB + * storage format. It should be destroyed at the end using hipsparseDestroyHybMat(). + */ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateHybMat(hipsparseHybMat_t* hybA); + +/*! \ingroup aux_module + * \brief Destroy a \p HYB matrix structure + * + * \details + * \p hipsparseDestroyHybMat destroys a \p HYB structure. + */ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyHybMat(hipsparseHybMat_t hybA); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a bsrsv2 info structure + * + * \details + * \p hipsparseCreateBsrsv2Info creates a structure that holds the bsrsv2 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyBsrsv2Info(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateBsrsv2Info(bsrsv2Info_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a bsrsv2 info structure + * + * \details + * \p hipsparseDestroyBsrsv2Info destroys a bsrsv2 info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyBsrsv2Info(bsrsv2Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a bsrsm2 info structure + * + * \details + * \p hipsparseCreateBsrsm2Info creates a structure that holds the bsrsm2 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyBsrsm2Info(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateBsrsm2Info(bsrsm2Info_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a bsrsm2 info structure + * + * \details + * \p hipsparseDestroyBsrsm2Info destroys a bsrsm2 info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyBsrsm2Info(bsrsm2Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a bsrilu02 info structure + * + * \details + * \p hipsparseCreateBsrilu02Info creates a structure that holds the bsrilu02 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyBsrilu02Info(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateBsrilu02Info(bsrilu02Info_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a bsrilu02 info structure + * + * \details + * \p hipsparseDestroyBsrilu02Info destroys a bsrilu02 info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyBsrilu02Info(bsrilu02Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a bsric02 info structure + * + * \details + * \p hipsparseCreateBsric02Info creates a structure that holds the bsric02 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyBsric02Info(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateBsric02Info(bsric02Info_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a bsric02 info structure + * + * \details + * \p hipsparseDestroyBsric02Info destroys a bsric02 info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyBsric02Info(bsric02Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a csrsv2 info structure + * + * \details + * \p hipsparseCreateCsrsv2Info creates a structure that holds the csrsv2 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyCsrsv2Info(). + */ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsrsv2Info(csrsv2Info_t* info); + +/*! \ingroup aux_module + * \brief Destroy a csrsv2 info structure + * + * \details + * \p hipsparseDestroyCsrsv2Info destroys a csrsv2 info structure. + */ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyCsrsv2Info(csrsv2Info_t info); + +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a csrsm2 info structure + * + * \details + * \p hipsparseCreateCsrsm2Info creates a structure that holds the csrsm2 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyCsrsm2Info(). + */ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsrsm2Info(csrsm2Info_t* info); + +/*! \ingroup aux_module + * \brief Destroy a csrsm2 info structure + * + * \details + * \p hipsparseDestroyCsrsm2Info destroys a csrsm2 info structure. + */ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyCsrsm2Info(csrsm2Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a csrilu02 info structure + * + * \details + * \p hipsparseCreateCsrilu02Info creates a structure that holds the csrilu02 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyCsrilu02Info(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsrilu02Info(csrilu02Info_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a csrilu02 info structure + * + * \details + * \p hipsparseDestroyCsrilu02Info destroys a csrilu02 info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyCsrilu02Info(csrilu02Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a csric02 info structure + * + * \details + * \p hipsparseCreateCsric02Info creates a structure that holds the csric02 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyCsric02Info(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsric02Info(csric02Info_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a csric02 info structure + * + * \details + * \p hipsparseDestroyCsric02Info destroys a csric02 info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyCsric02Info(csric02Info_t info); +#endif + +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a csru2csr info structure + * + * \details + * \p hipsparseCreateCsru2csrInfo creates a structure that holds the csru2csr info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyCsru2csrInfo(). + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsru2csrInfo(csru2csrInfo_t* info); + +/*! \ingroup aux_module + * \brief Destroy a csru2csr info structure + * + * \details + * \p hipsparseDestroyCsru2csrInfo destroys a csru2csr info structure. + */ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyCsru2csrInfo(csru2csrInfo_t info); + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a color info structure + * + * \details + * \p hipsparseCreateColorInfo creates a structure that holds the color info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyColorInfo(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateColorInfo(hipsparseColorInfo_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a color info structure + * + * \details + * \p hipsparseDestroyColorInfo destroys a color info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyColorInfo(hipsparseColorInfo_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a csrgemm2 info structure + * + * \details + * \p hipsparseCreateCsrgemm2Info creates a structure that holds the csrgemm2 info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyCsrgemm2Info(). + */ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsrgemm2Info(csrgemm2Info_t* info); + +/*! \ingroup aux_module + * \brief Destroy a csrgemm2 info structure + * + * \details + * \p hipsparseDestroyCsrgemm2Info destroys a csrgemm2 info structure. + */ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyCsrgemm2Info(csrgemm2Info_t info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/* Info structures */ +/*! \ingroup aux_module + * \brief Create a prune info structure + * + * \details + * \p hipsparseCreatePruneInfo creates a structure that holds the prune info data + * that is gathered during the analysis routines available. It should be destroyed + * at the end using hipsparseDestroyPruneInfo(). + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreatePruneInfo(pruneInfo_t* info); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup aux_module + * \brief Destroy a prune info structure + * + * \details + * \p hipsparseDestroyPruneInfo destroys a prune info structure. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyPruneInfo(pruneInfo_t info); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/hipsparse_generic_auxiliary.h b/library/include/hipsparse_generic_auxiliary.h new file mode 100644 index 00000000..c42b504e --- /dev/null +++ b/library/include/hipsparse_generic_auxiliary.h @@ -0,0 +1,953 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse vector. +* +* \details +* \p hipsparseCreateSpVec creates a sparse vector descriptor. It should be +* destroyed at the end using hipsparseDestroySpVec(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateSpVec(hipsparseSpVecDescr_t* spVecDescr, + int64_t size, + int64_t nnz, + void* indices, + void* values, + hipsparseIndexType_t idxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a const sparse vector. +* +* \details +* \p hipsparseCreateConstSpVec creates a const sparse vector descriptor. It should be +* destroyed at the end using hipsparseDestroySpVec(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstSpVec(hipsparseConstSpVecDescr_t* spVecDescr, + int64_t size, + int64_t nnz, + const void* indices, + const void* values, + hipsparseIndexType_t idxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Destroy a sparse vector. +* +* \details +* \p hipsparseDestroySpVec destroys a sparse vector descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroySpVec(hipsparseConstSpVecDescr_t spVecDescr); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroySpVec(hipsparseSpVecDescr_t spVecDescr); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the fields of the sparse vector descriptor. +* +* \details +* \p hipsparseSpVecGet gets the fields of the sparse vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVecGet(const hipsparseSpVecDescr_t spVecDescr, + int64_t* size, + int64_t* nnz, + void** indices, + void** values, + hipsparseIndexType_t* idxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the fields of the const sparse vector descriptor. +* +* \details +* \p hipsparseConstSpVecGet gets the fields of the const sparse vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstSpVecGet(hipsparseConstSpVecDescr_t spVecDescr, + int64_t* size, + int64_t* nnz, + const void** indices, + const void** values, + hipsparseIndexType_t* idxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get index base of a sparse vector. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVecGetIndexBase(const hipsparseConstSpVecDescr_t spVecDescr, + hipsparseIndexBase_t* idxBase); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVecGetIndexBase(const hipsparseSpVecDescr_t spVecDescr, + hipsparseIndexBase_t* idxBase); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointer to a sparse vector data array. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVecGetValues(const hipsparseSpVecDescr_t spVecDescr, void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointer to a sparse vector data array. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstSpVecGetValues(hipsparseConstSpVecDescr_t spVecDescr, + const void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Set pointer of a sparse vector data array. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpVecSetValues(hipsparseSpVecDescr_t spVecDescr, void* values); +#endif + +/* Sparse matrix API */ + +/*! \ingroup generic_module +* \brief Description: Create a sparse COO matrix descriptor +* \details +* \p hipsparseCreateCoo creates a sparse COO matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCoo(hipsparseSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + void* cooRowInd, + void* cooColInd, + void* cooValues, + hipsparseIndexType_t cooIdxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse COO matrix descriptor +* \details +* \p hipsparseCreateConstCoo creates a sparse COO matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstCoo(hipsparseConstSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + const void* cooRowInd, + const void* cooColInd, + const void* cooValues, + hipsparseIndexType_t cooIdxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse COO (AoS) matrix descriptor +* \details +* \p hipsparseCreateCooAoS creates a sparse COO (AoS) matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 10010 && CUDART_VERSION < 12000)) +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCooAoS(hipsparseSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + void* cooInd, + void* cooValues, + hipsparseIndexType_t cooIdxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse CSR matrix descriptor +* \details +* \p hipsparseCreateCsr creates a sparse CSR matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsr(hipsparseSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + void* csrRowOffsets, + void* csrColInd, + void* csrValues, + hipsparseIndexType_t csrRowOffsetsType, + hipsparseIndexType_t csrColIndType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse CSR matrix descriptor +* \details +* \p hipsparseCreateConstCsr creates a sparse CSR matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstCsr(hipsparseConstSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + const void* csrRowOffsets, + const void* csrColInd, + const void* csrValues, + hipsparseIndexType_t csrRowOffsetsType, + hipsparseIndexType_t csrColIndType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse CSC matrix descriptor +* \details +* \p hipsparseCreateCsr creates a sparse CSC matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11020) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateCsc(hipsparseSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + void* cscColOffsets, + void* cscRowInd, + void* cscValues, + hipsparseIndexType_t cscColOffsetsType, + hipsparseIndexType_t cscRowIndType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse CSC matrix descriptor +* \details +* \p hipsparseCreateConstCsc creates a sparse CSC matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstCsc(hipsparseConstSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t nnz, + const void* cscColOffsets, + const void* cscRowInd, + const void* cscValues, + hipsparseIndexType_t cscColOffsetsType, + hipsparseIndexType_t cscRowIndType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse Blocked ELL matrix descriptor +* \details +* \p hipsparseCreateCsr creates a sparse Blocked ELL matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11021) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateBlockedEll(hipsparseSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t ellBlockSize, + int64_t ellCols, + void* ellColInd, + void* ellValue, + hipsparseIndexType_t ellIdxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create a sparse Blocked ELL matrix descriptor +* \details +* \p hipsparseCreateConstBlockedEll creates a sparse Blocked ELL matrix descriptor. It should be +* destroyed at the end using \p hipsparseDestroySpMat. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstBlockedEll(hipsparseConstSpMatDescr_t* spMatDescr, + int64_t rows, + int64_t cols, + int64_t ellBlockSize, + int64_t ellCols, + const void* ellColInd, + const void* ellValue, + hipsparseIndexType_t ellIdxType, + hipsparseIndexBase_t idxBase, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Destroy a sparse matrix descriptor +* \details +* \p hipsparseDestroySpMat destroys a sparse matrix descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroySpMat(hipsparseConstSpMatDescr_t spMatDescr); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroySpMat(hipsparseSpMatDescr_t spMatDescr); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse COO matrix +* \details +* \p hipsparseCooGet gets the fields of the sparse COO matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCooGet(const hipsparseSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + void** cooRowInd, + void** cooColInd, + void** cooValues, + hipsparseIndexType_t* idxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse COO matrix +* \details +* \p hipsparseConstCooGet gets the fields of the sparse COO matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstCooGet(hipsparseConstSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + const void** cooRowInd, + const void** cooColInd, + const void** cooValues, + hipsparseIndexType_t* idxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse COO (AoS) matrix +* \details +* \p hipsparseCooAoSGet gets the fields of the sparse COO (AoS) matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 10010 && CUDART_VERSION < 12000)) +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCooAoSGet(const hipsparseSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + void** cooInd, + void** cooValues, + hipsparseIndexType_t* idxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse CSR matrix +* \details +* \p hipsparseCsrGet gets the fields of the sparse CSR matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCsrGet(const hipsparseSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + void** csrRowOffsets, + void** csrColInd, + void** csrValues, + hipsparseIndexType_t* csrRowOffsetsType, + hipsparseIndexType_t* csrColIndType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse CSR matrix +* \details +* \p hipsparseConstCsrGet gets the fields of the sparse CSR matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstCsrGet(hipsparseConstSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + const void** csrRowOffsets, + const void** csrColInd, + const void** csrValues, + hipsparseIndexType_t* csrRowOffsetsType, + hipsparseIndexType_t* csrColIndType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse CSC matrix +* \details +* \p hipsparseCscGet gets the fields of the sparse CSC matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCscGet(const hipsparseSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + void** cscColOffsets, + void** cscRowInd, + void** cscValues, + hipsparseIndexType_t* cscColOffsetsType, + hipsparseIndexType_t* cscRowIndType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse CSC matrix +* \details +* \p hipsparseConstCscGet gets the fields of the sparse CSC matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstCscGet(hipsparseConstSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz, + const void** cscColOffsets, + const void** cscRowInd, + const void** cscValues, + hipsparseIndexType_t* cscColOffsetsType, + hipsparseIndexType_t* cscRowIndType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse blocked ELL matrix +* \details +* \p hipsparseBlockedEllGet gets the fields of the sparse blocked ELL matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11021) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseBlockedEllGet(const hipsparseSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* ellBlockSize, + int64_t* ellCols, + void** ellColInd, + void** ellValue, + hipsparseIndexType_t* ellIdxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get pointers of a sparse blocked ELL matrix +* \details +* \p hipsparseConstBlockedEllGet gets the fields of the sparse blocked ELL matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstBlockedEllGet(hipsparseConstSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* ellBlockSize, + int64_t* ellCols, + const void** ellColInd, + const void** ellValue, + hipsparseIndexType_t* ellIdxType, + hipsparseIndexBase_t* idxBase, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Set pointers of a sparse CSR matrix +* \details +* \p hipsparseCsrSetPointers sets the fields of the sparse CSR matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCsrSetPointers(hipsparseSpMatDescr_t spMatDescr, + void* csrRowOffsets, + void* csrColInd, + void* csrValues); +#endif + +/*! \ingroup generic_module +* \brief Description: Set pointers of a sparse CSC matrix +* \details +* \p hipsparseCscSetPointers sets the fields of the sparse CSC matrix descriptor +*/ +#if(!defined(CUDART_VERSION)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCscSetPointers(hipsparseSpMatDescr_t spMatDescr, + void* cscColOffsets, + void* cscRowInd, + void* cscValues); +#endif + +/*! \ingroup generic_module +* \brief Description: Set pointers of a sparse COO matrix +* \details +* \p hipsparseCooSetPointers sets the fields of the sparse COO matrix descriptor +*/ +#if(!defined(CUDART_VERSION)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCooSetPointers(hipsparseSpMatDescr_t spMatDescr, + void* cooRowInd, + void* cooColInd, + void* cooValues); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the sizes of a sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetSize(hipsparseConstSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetSize(hipsparseSpMatDescr_t spMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* nnz); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the format of a sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetFormat(hipsparseConstSpMatDescr_t spMatDescr, + hipsparseFormat_t* format); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetFormat(const hipsparseSpMatDescr_t spMatDescr, + hipsparseFormat_t* format); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the index base of a sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetIndexBase(hipsparseConstSpMatDescr_t spMatDescr, + hipsparseIndexBase_t* idxBase); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetIndexBase(const hipsparseSpMatDescr_t spMatDescr, + hipsparseIndexBase_t* idxBase); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the pointer of the values array of a sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetValues(hipsparseSpMatDescr_t spMatDescr, void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the pointer of the values array of a sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstSpMatGetValues(hipsparseConstSpMatDescr_t spMatDescr, + const void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Set the pointer of the values array of a sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatSetValues(hipsparseSpMatDescr_t spMatDescr, void* values); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the batch count of the sparse matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetStridedBatch(hipsparseConstSpMatDescr_t spMatDescr, + int* batchCount); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetStridedBatch(hipsparseSpMatDescr_t spMatDescr, int* batchCount); +#endif + +/*! \ingroup generic_module +* \brief Description: Set the batch count of the sparse matrix +*/ +#if(!defined(CUDART_VERSION) || (CUDART_VERSION >= 10010 && CUDART_VERSION < 12000)) +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatSetStridedBatch(hipsparseSpMatDescr_t spMatDescr, int batchCount); +#endif + +/*! \ingroup generic_module +* \brief Description: Set the batch count and stride of the sparse COO matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCooSetStridedBatch(hipsparseSpMatDescr_t spMatDescr, + int batchCount, + int64_t batchStride); +#endif + +/*! \ingroup generic_module +* \brief Description: Set the batch count and stride of the sparse CSR matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCsrSetStridedBatch(hipsparseSpMatDescr_t spMatDescr, + int batchCount, + int64_t offsetsBatchStride, + int64_t columnsValuesBatchStride); +#endif + +/*! \ingroup generic_module +* \brief Description: Get attribute from sparse matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetAttribute(hipsparseConstSpMatDescr_t spMatDescr, + hipsparseSpMatAttribute_t attribute, + void* data, + size_t dataSize); +#elif(CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatGetAttribute(hipsparseSpMatDescr_t spMatDescr, + hipsparseSpMatAttribute_t attribute, + void* data, + size_t dataSize); +#endif + +/*! \ingroup generic_module +* \brief Description: Set attribute in sparse matrix descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSpMatSetAttribute(hipsparseSpMatDescr_t spMatDescr, + hipsparseSpMatAttribute_t attribute, + const void* data, + size_t dataSize); +#endif + +/* Dense vector API */ + +/*! \ingroup generic_module +* \brief Description: Create dense vector +* \details +* \p hipsparseCreateDnVec creates a dense vector descriptor. It should be +* destroyed at the end using hipsparseDestroyDnVec(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateDnVec(hipsparseDnVecDescr_t* dnVecDescr, + int64_t size, + void* values, + hipDataType valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Create dense vector +* \details +* \p hipsparseCreateConstDnVec creates a dense vector descriptor. It should be +* destroyed at the end using hipsparseDestroyDnVec(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstDnVec(hipsparseConstDnVecDescr_t* dnVecDescr, + int64_t size, + const void* values, + hipDataType valueType); +#endif + +/* Description: Destroy dense vector */ + +/*! \ingroup generic_module +* \brief Description: Destroy dense vector +* \details +* \p hipsparseDestroyDnVec destroys a dense vector descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyDnVec(hipsparseConstDnVecDescr_t dnVecDescr); +#elif(CUDART_VERSION > 10010 || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyDnVec(hipsparseDnVecDescr_t dnVecDescr); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the fields from a dense vector +* \details +* \p hipsparseDnVecGet gets the fields of the dense vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnVecGet(const hipsparseDnVecDescr_t dnVecDescr, + int64_t* size, + void** values, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the fields from a dense vector +* \details +* \p hipsparseConstDnVecGet gets the fields of the dense vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstDnVecGet(hipsparseConstDnVecDescr_t dnVecDescr, + int64_t* size, + const void** values, + hipDataType* valueType); +#endif + +/*! \ingroup generic_module +* \brief Description: Get value pointer from a dense vector +* \details +* \p hipsparseDnVecGetValues gets the fields of the dense vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnVecGetValues(const hipsparseDnVecDescr_t dnVecDescr, void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Get value pointer from a dense vector +* \details +* \p hipsparseConstDnVecGetValues gets the fields of the dense vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12001) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstDnVecGetValues(hipsparseConstDnVecDescr_t dnVecDescr, + const void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Set value pointer of a dense vector +* \details +* \p hipsparseDnVecSetValues sets the fields of the dense vector descriptor +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnVecSetValues(hipsparseDnVecDescr_t dnVecDescr, void* values); +#endif + +/* Dense matrix API */ + +/* Description: Create dense matrix */ + +/*! \ingroup generic_module +* \brief Description: Create dense matrix +* \details +* \p hipsparseCreateDnMat creates a dense matrix descriptor. It should be +* destroyed at the end using hipsparseDestroyDnMat(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateDnMat(hipsparseDnMatDescr_t* dnMatDescr, + int64_t rows, + int64_t cols, + int64_t ld, + void* values, + hipDataType valueType, + hipsparseOrder_t order); +#endif + +/*! \ingroup generic_module +* \brief Description: Create dense matrix +* \details +* \p hipsparseCreateConstDnMat creates a dense matrix descriptor. It should be +* destroyed at the end using hipsparseDestroyDnMat(). +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCreateConstDnMat(hipsparseConstDnMatDescr_t* dnMatDescr, + int64_t rows, + int64_t cols, + int64_t ld, + const void* values, + hipDataType valueType, + hipsparseOrder_t order); +#endif + +/*! \ingroup generic_module +* \brief Description: Destroy dense matrix +* \details +* \p hipsparseDestroyDnMat destroys a dense matrix descriptor and releases all +* resources used by the descriptor. +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyDnMat(hipsparseConstDnMatDescr_t dnMatDescr); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDestroyDnMat(hipsparseDnMatDescr_t dnMatDescr); +#endif + +/*! \ingroup generic_module +* \brief Description: Get fields from a dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnMatGet(const hipsparseDnMatDescr_t dnMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* ld, + void** values, + hipDataType* valueType, + hipsparseOrder_t* order); +#endif + +/*! \ingroup generic_module +* \brief Description: Get fields from a dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstDnMatGet(hipsparseConstDnMatDescr_t dnMatDescr, + int64_t* rows, + int64_t* cols, + int64_t* ld, + const void** values, + hipDataType* valueType, + hipsparseOrder_t* order); +#endif + +/*! \ingroup generic_module +* \brief Description: Get value pointer from a dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnMatGetValues(const hipsparseDnMatDescr_t dnMatDescr, void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Get value pointer from a dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseConstDnMatGetValues(hipsparseConstDnMatDescr_t dnMatDescr, + const void** values); +#endif + +/*! \ingroup generic_module +* \brief Description: Set value pointer of a dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnMatSetValues(hipsparseDnMatDescr_t dnMatDescr, void* values); +#endif + +/*! \ingroup generic_module +* \brief Description: Get the batch count and batch stride of the dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnMatGetStridedBatch(hipsparseConstDnMatDescr_t dnMatDescr, + int* batchCount, + int64_t* batchStride); +#elif(CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnMatGetStridedBatch(hipsparseDnMatDescr_t dnMatDescr, + int* batchCount, + int64_t* batchStride); +#endif + +/*! \ingroup generic_module +* \brief Description: Set the batch count and batch stride of the dense matrix +*/ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDnMatSetStridedBatch(hipsparseDnMatDescr_t dnMatDescr, + int batchCount, + int64_t batchStride); +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/hipsparse_generic_types.h b/library/include/hipsparse_generic_types.h new file mode 100644 index 00000000..d04b09d4 --- /dev/null +++ b/library/include/hipsparse_generic_types.h @@ -0,0 +1,539 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a sparse vector + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information for a sparse vector. It must + * be initialized using hipsparseCreateSpVec() and the returned descriptor + * is used in hipSPARSE generic API's involving sparse vectors. It should be destroyed at the end using + * hipsparseDestroySpVec(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +typedef void* hipsparseSpVecDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a dense vector + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information for a dense vector. It must + * be initialized using hipsparseCreateDnVec() and the returned descriptor + * is used in hipSPARSE generic API's involving dense vectors. It should be destroyed at the end using + * hipsparseDestroyDnVec(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION > 10010 \ + || (CUDART_VERSION == 10010 && CUDART_10_1_UPDATE_VERSION == 1)) +typedef void* hipsparseDnVecDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a sparse matrix + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information for a sparse matrix. It must + * be initialized using hipsparseCreateSpMat() and the returned descriptor + * is used in hipSPARSE generic API's involving sparse matrices. It should be destroyed at the end using + * hipsparseDestroySpMat(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +typedef void* hipsparseSpMatDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a dense matrix + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information for a dense matrix. It must + * be initialized using hipsparseCreateDnMat() and the returned descriptor + * is used in hipSPARSE generic API's involving dense matrices. It should be destroyed at the end using + * hipsparseDestroyDnMat(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +typedef void* hipsparseDnMatDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a sparse vector + * + * \details + * The hipSPARSE (const) descriptor is an opaque structure holding information for a sparse vector. It must + * be initialized using hipsparseCreateConstSpVec() and the returned descriptor + * is used in hipSPARSE generic API's involving sparse vectors. It should be destroyed at the end using + * hipsparseDestroySpVec(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +typedef void const* hipsparseConstSpVecDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a dense vector + * + * \details + * The hipSPARSE (const) descriptor is an opaque structure holding information for a dense vector. It must + * be initialized using hipsparseCreateConstDnVec() and the returned descriptor + * is used in hipSPARSE generic API's involving dense vectors. It should be destroyed at the end using + * hipsparseDestroyDnVec(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +typedef void const* hipsparseConstDnVecDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a sparse matrix + * + * \details + * The hipSPARSE (const) descriptor is an opaque structure holding information for a sparse matrix. It must + * be initialized using hipsparseCreateConstSpMat() and the returned descriptor + * is used in hipSPARSE generic API's involving sparse matrices. It should be destroyed at the end using + * hipsparseDestroySpMat(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +typedef void const* hipsparseConstSpMatDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a dense matrix + * + * \details + * The hipSPARSE (const) descriptor is an opaque structure holding information for a dense matrix. It must + * be initialized using hipsparseCreateConstDnMat() and the returned descriptor + * is used in hipSPARSE generic API's involving dense matrices. It should be destroyed at the end using + * hipsparseDestroyDnMat(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 12000) +typedef void const* hipsparseConstDnMatDescr_t; +#endif + +/// \cond DO_NOT_DOCUMENT +// Forward declarations +struct hipsparseSpGEMMDescr; +struct hipsparseSpSVDescr; +struct hipsparseSpSMDescr; +/// \endcond + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a SpGEMM calculations + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information that is used in hipsparseSpGEMM_workEstimation(), + * hipsparseSpGEMMreuse_workEstimation(), hipsparseSpGEMMreuse_nnz(), hipsparseSpGEMM_compute(), + * hipsparseSpGEMMreuse_compute(), hipsparseSpGEMM_copy(), and hipsparseSpGEMMreuse_copy(). It must + * be initialized using hipsparseSpGEMM_createDescr(). It should be destroyed at the end using + * hipsparseSpGEMM_destroyDescr(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11000) +typedef struct hipsparseSpGEMMDescr* hipsparseSpGEMMDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a SpSV calculations + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information that is used in hipsparseSpSV_bufferSize(), + * hipsparseSpSV_analysis(), and hipsparseSpSV_solve(). It must be initialized using hipsparseSpSV_createDescr(). + * It should be destroyed at the end using hipsparseSpSV_destroyDescr(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) +typedef struct hipsparseSpSVDescr* hipsparseSpSVDescr_t; +#endif + +/*! \ingroup types_module + * \brief Generic API opaque structure holding information for a SpSM calculations + * + * \details + * The hipSPARSE descriptor is an opaque structure holding information that is used in hipsparseSpSM_bufferSize(), + * hipsparseSpSM_analysis(), and hipsparseSpSM_solve(). It must be initialized using hipsparseSpSM_createDescr(). + * It should be destroyed at the end using hipsparseSpSM_destroyDescr(). + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) +typedef struct hipsparseSpSMDescr* hipsparseSpSMDescr_t; +#endif + +/* Generic API types */ + +/*! \ingroup generic_module + * \brief List of hipsparse sparse matrix formats. + * + * \details + * This is a list of the \ref hipsparseFormat_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION)) +typedef enum +{ + HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ + HIPSPARSE_FORMAT_CSC = 2, /* Compressed Sparse Column */ + HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ + HIPSPARSE_FORMAT_COO_AOS = 4, /* Coordinate - Array of Structures */ + HIPSPARSE_FORMAT_BLOCKED_ELL = 5 /* Blocked ELL */ +} hipsparseFormat_t; +#else +#if(CUDART_VERSION >= 12000) +typedef enum +{ + HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ + HIPSPARSE_FORMAT_CSC = 2, /* Compressed Sparse Column */ + HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ + HIPSPARSE_FORMAT_BLOCKED_ELL = 5 /* Blocked ELL */ +} hipsparseFormat_t; +#elif(CUDART_VERSION >= 11021 && CUDART_VERSION < 12000) +typedef enum +{ + HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ + HIPSPARSE_FORMAT_CSC = 2, /* Compressed Sparse Column */ + HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ + HIPSPARSE_FORMAT_COO_AOS = 4, /* Coordinate - Array of Structures */ + HIPSPARSE_FORMAT_BLOCKED_ELL = 5 /* Blocked ELL */ +} hipsparseFormat_t; +#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 11021) +typedef enum +{ + HIPSPARSE_FORMAT_CSR = 1, /* Compressed Sparse Row */ + HIPSPARSE_FORMAT_COO = 3, /* Coordinate - Structure of Arrays */ + HIPSPARSE_FORMAT_COO_AOS = 4, /* Coordinate - Array of Structures */ +} hipsparseFormat_t; +#endif +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse dense matrix memory layout ordering. + * + * \details + * This is a list of the \ref hipsparseOrder_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION)) +typedef enum +{ + HIPSPARSE_ORDER_COLUMN HIPSPARSE_DEPRECATED_MSG("Please use HIPSPARSE_ORDER_COL instead") + = 1, /**< Column major */ + HIPSPARSE_ORDER_COL = 1, /**< Column major */ + HIPSPARSE_ORDER_ROW = 2 /**< Row major */ +} hipsparseOrder_t; +#else +#if(CUDART_VERSION >= 11000) +typedef enum +{ + HIPSPARSE_ORDER_COLUMN HIPSPARSE_DEPRECATED_MSG("Please use HIPSPARSE_ORDER_COL instead") + = 1, /**< Column major */ + HIPSPARSE_ORDER_COL = 1, /**< Column major */ + HIPSPARSE_ORDER_ROW = 2 /**< Row major */ +} hipsparseOrder_t; +#elif(CUDART_VERSION >= 10010) +typedef enum +{ + HIPSPARSE_ORDER_COLUMN HIPSPARSE_DEPRECATED_MSG("Please use HIPSPARSE_ORDER_COL instead") + = 1, /**< Column major */ + HIPSPARSE_ORDER_COL = 1 /**< Column major */ +} hipsparseOrder_t; +#endif +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse index type used by sparse matrix indices. + * + * \details + * This is a list of the \ref hipsparseIndexType_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 10010) +typedef enum +{ + HIPSPARSE_INDEX_16U = 1, /**< 16 bit unsigned integer indices */ + HIPSPARSE_INDEX_32I = 2, /**< 32 bit signed integer indices */ + HIPSPARSE_INDEX_64I = 3 /**< 64 bit signed integer indices */ +} hipsparseIndexType_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SpMV algorithms. + * + * \details + * This is a list of the \ref hipsparseSpMVAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION)) +typedef enum +{ + HIPSPARSE_MV_ALG_DEFAULT = 0, + HIPSPARSE_COOMV_ALG = 1, + HIPSPARSE_CSRMV_ALG1 = 2, + HIPSPARSE_CSRMV_ALG2 = 3, + HIPSPARSE_SPMV_ALG_DEFAULT = 0, + HIPSPARSE_SPMV_COO_ALG1 = 1, + HIPSPARSE_SPMV_CSR_ALG1 = 2, + HIPSPARSE_SPMV_CSR_ALG2 = 3, + HIPSPARSE_SPMV_COO_ALG2 = 4 +} hipsparseSpMVAlg_t; +#else +#if(CUDART_VERSION >= 12000) +typedef enum +{ + HIPSPARSE_SPMV_ALG_DEFAULT = 0, + HIPSPARSE_SPMV_COO_ALG1 = 1, + HIPSPARSE_SPMV_CSR_ALG1 = 2, + HIPSPARSE_SPMV_CSR_ALG2 = 3, + HIPSPARSE_SPMV_COO_ALG2 = 4 +} hipsparseSpMVAlg_t; +#elif(CUDART_VERSION >= 11021 && CUDART_VERSION < 12000) +typedef enum +{ + HIPSPARSE_MV_ALG_DEFAULT = 0, + HIPSPARSE_COOMV_ALG = 1, + HIPSPARSE_CSRMV_ALG1 = 2, + HIPSPARSE_CSRMV_ALG2 = 3, + HIPSPARSE_SPMV_ALG_DEFAULT = 0, + HIPSPARSE_SPMV_COO_ALG1 = 1, + HIPSPARSE_SPMV_CSR_ALG1 = 2, + HIPSPARSE_SPMV_CSR_ALG2 = 3, + HIPSPARSE_SPMV_COO_ALG2 = 4 +} hipsparseSpMVAlg_t; +#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 11021) +typedef enum +{ + HIPSPARSE_MV_ALG_DEFAULT = 0, + HIPSPARSE_COOMV_ALG = 1, + HIPSPARSE_CSRMV_ALG1 = 2, + HIPSPARSE_CSRMV_ALG2 = 3 +} hipsparseSpMVAlg_t; +#endif +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SpMM algorithms. + * + * \details + * This is a list of the \ref hipsparseSpMMAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION)) +typedef enum +{ + HIPSPARSE_MM_ALG_DEFAULT = 0, + HIPSPARSE_COOMM_ALG1 = 1, + HIPSPARSE_COOMM_ALG2 = 2, + HIPSPARSE_COOMM_ALG3 = 3, + HIPSPARSE_CSRMM_ALG1 = 4, + HIPSPARSE_SPMM_ALG_DEFAULT = 0, + HIPSPARSE_SPMM_COO_ALG1 = 1, + HIPSPARSE_SPMM_COO_ALG2 = 2, + HIPSPARSE_SPMM_COO_ALG3 = 3, + HIPSPARSE_SPMM_COO_ALG4 = 5, + HIPSPARSE_SPMM_CSR_ALG1 = 4, + HIPSPARSE_SPMM_CSR_ALG2 = 6, + HIPSPARSE_SPMM_CSR_ALG3 = 12, + HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 +} hipsparseSpMMAlg_t; +#else +#if(CUDART_VERSION >= 12000) +typedef enum +{ + HIPSPARSE_SPMM_ALG_DEFAULT = 0, + HIPSPARSE_SPMM_COO_ALG1 = 1, + HIPSPARSE_SPMM_COO_ALG2 = 2, + HIPSPARSE_SPMM_COO_ALG3 = 3, + HIPSPARSE_SPMM_COO_ALG4 = 5, + HIPSPARSE_SPMM_CSR_ALG1 = 4, + HIPSPARSE_SPMM_CSR_ALG2 = 6, + HIPSPARSE_SPMM_CSR_ALG3 = 12, + HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 +} hipsparseSpMMAlg_t; +#elif(CUDART_VERSION >= 11021 && CUDART_VERSION < 12000) +typedef enum +{ + HIPSPARSE_MM_ALG_DEFAULT = 0, + HIPSPARSE_COOMM_ALG1 = 1, + HIPSPARSE_COOMM_ALG2 = 2, + HIPSPARSE_COOMM_ALG3 = 3, + HIPSPARSE_CSRMM_ALG1 = 4, + HIPSPARSE_SPMM_ALG_DEFAULT = 0, + HIPSPARSE_SPMM_COO_ALG1 = 1, + HIPSPARSE_SPMM_COO_ALG2 = 2, + HIPSPARSE_SPMM_COO_ALG3 = 3, + HIPSPARSE_SPMM_COO_ALG4 = 5, + HIPSPARSE_SPMM_CSR_ALG1 = 4, + HIPSPARSE_SPMM_CSR_ALG2 = 6, + HIPSPARSE_SPMM_CSR_ALG3 = 12, + HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 +} hipsparseSpMMAlg_t; +#elif(CUDART_VERSION >= 11003 && CUDART_VERSION < 11021) +typedef enum +{ + HIPSPARSE_MM_ALG_DEFAULT = 0, + HIPSPARSE_COOMM_ALG1 = 1, + HIPSPARSE_COOMM_ALG2 = 2, + HIPSPARSE_COOMM_ALG3 = 3, + HIPSPARSE_CSRMM_ALG1 = 4, + HIPSPARSE_SPMM_ALG_DEFAULT = 0, + HIPSPARSE_SPMM_COO_ALG1 = 1, + HIPSPARSE_SPMM_COO_ALG2 = 2, + HIPSPARSE_SPMM_COO_ALG3 = 3, + HIPSPARSE_SPMM_COO_ALG4 = 5, + HIPSPARSE_SPMM_CSR_ALG1 = 4, + HIPSPARSE_SPMM_CSR_ALG2 = 6, + HIPSPARSE_SPMM_BLOCKED_ELL_ALG1 = 13 +} hipsparseSpMMAlg_t; +#elif(CUDART_VERSION >= 10010 && CUDART_VERSION < 11003) +typedef enum +{ + HIPSPARSE_MM_ALG_DEFAULT = 0, + HIPSPARSE_COOMM_ALG1 = 1, + HIPSPARSE_COOMM_ALG2 = 2, + HIPSPARSE_COOMM_ALG3 = 3, + HIPSPARSE_CSRMM_ALG1 = 4 +} hipsparseSpMMAlg_t; +#endif +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SparseToDense algorithms. + * + * \details + * This is a list of the \ref hipsparseSparseToDenseAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11020) +typedef enum +{ + HIPSPARSE_SPARSETODENSE_ALG_DEFAULT = 0, +} hipsparseSparseToDenseAlg_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse DenseToSparse algorithms. + * + * \details + * This is a list of the \ref hipsparseDenseToSparseAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11020) +typedef enum +{ + HIPSPARSE_DENSETOSPARSE_ALG_DEFAULT = 0, +} hipsparseDenseToSparseAlg_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SDDMM algorithms. + * + * \details + * This is a list of the \ref hipsparseSDDMMAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11022) +typedef enum +{ + HIPSPARSE_SDDMM_ALG_DEFAULT = 0 +} hipsparseSDDMMAlg_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SpSV algorithms. + * + * \details + * This is a list of the \ref hipsparseSpSVAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) +typedef enum +{ + HIPSPARSE_SPSV_ALG_DEFAULT = 0 +} hipsparseSpSVAlg_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SpSM algorithms. + * + * \details + * This is a list of the \ref hipsparseSpSMAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11031) +typedef enum +{ + HIPSPARSE_SPSM_ALG_DEFAULT = 0 +} hipsparseSpSMAlg_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse attributes. + * + * \details + * This is a list of the \ref hipsparseSpMatAttribute_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION) || CUDART_VERSION >= 11030) +typedef enum +{ + HIPSPARSE_SPMAT_FILL_MODE = 0, /**< Fill mode attribute */ + HIPSPARSE_SPMAT_DIAG_TYPE = 1 /**< Diag type attribute */ +} hipsparseSpMatAttribute_t; +#endif + +/*! \ingroup generic_module + * \brief List of hipsparse SpGEMM algorithms. + * + * \details + * This is a list of the \ref hipsparseSpGEMMAlg_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION)) +typedef enum +{ + HIPSPARSE_SPGEMM_DEFAULT = 0, + HIPSPARSE_SPGEMM_CSR_ALG_DETERMINISTIC = 1, + HIPSPARSE_SPGEMM_CSR_ALG_NONDETERMINISTIC = 2, + HIPSPARSE_SPGEMM_ALG1 = 3, + HIPSPARSE_SPGEMM_ALG2 = 4, + HIPSPARSE_SPGEMM_ALG3 = 5 +} hipsparseSpGEMMAlg_t; +#else +#if(CUDART_VERSION >= 12000) +typedef enum +{ + HIPSPARSE_SPGEMM_DEFAULT = 0, + HIPSPARSE_SPGEMM_CSR_ALG_DETERMINISTIC = 1, + HIPSPARSE_SPGEMM_CSR_ALG_NONDETERMINISTIC = 2, + HIPSPARSE_SPGEMM_ALG1 = 3, + HIPSPARSE_SPGEMM_ALG2 = 4, + HIPSPARSE_SPGEMM_ALG3 = 5 +} hipsparseSpGEMMAlg_t; +#elif(CUDART_VERSION >= 11031 && CUDART_VERSION < 12000) +typedef enum +{ + HIPSPARSE_SPGEMM_DEFAULT = 0, + HIPSPARSE_SPGEMM_CSR_ALG_DETERMINISTIC = 1, + HIPSPARSE_SPGEMM_CSR_ALG_NONDETERMINISTIC = 2, +} hipsparseSpGEMMAlg_t; +#elif(CUDART_VERSION >= 11000) +typedef enum +{ + HIPSPARSE_SPGEMM_DEFAULT = 0 +} hipsparseSpGEMMAlg_t; +#endif +#endif \ No newline at end of file diff --git a/library/include/hipsparse_types.h b/library/include/hipsparse_types.h new file mode 100644 index 00000000..bd30f046 --- /dev/null +++ b/library/include/hipsparse_types.h @@ -0,0 +1,417 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +/// \cond DO_NOT_DOCUMENT +// Forward declarations +struct bsrsv2Info; +struct bsrsm2Info; +struct bsrilu02Info; +struct bsric02Info; +struct csrsv2Info; +struct csrsm2Info; +struct csrilu02Info; +struct csric02Info; +struct csrgemm2Info; +struct pruneInfo; +struct csru2csrInfo; +/// \endcond + +/*! \ingroup types_module + * \brief Handle to the hipSPARSE library context queue. + * + * \details + * The hipSPARSE handle is a structure holding the hipSPARSE library context. It must + * be initialized using hipsparseCreate() and the returned handle must be passed to all + * subsequent library function calls. It should be destroyed at the end using + * hipsparseDestroy(). + */ +typedef void* hipsparseHandle_t; + +/*! \ingroup types_module + * \brief Descriptor of the matrix. + * + * \details + * The hipSPARSE matrix descriptor is a structure holding all properties of a matrix. + * It must be initialized using hipsparseCreateMatDescr() and the returned descriptor + * must be passed to all subsequent library calls that involve the matrix. It should be + * destroyed at the end using hipsparseDestroyMatDescr(). + */ +typedef void* hipsparseMatDescr_t; + +/*! \ingroup types_module + * \brief HYB matrix storage format. + * + * \details + * The hipSPARSE HYB matrix structure holds the HYB matrix. It must be initialized using + * hipsparseCreateHybMat() and the returned HYB matrix must be passed to all subsequent + * library calls that involve the matrix. It should be destroyed at the end using + * hipsparseDestroyHybMat(). + */ +typedef void* hipsparseHybMat_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding coloring info. + * + * \details + * The hipSPARSE ColorInfo structure holds the coloring information. It must be + * initialized using hipsparseCreateColorInfo() and the returned structure must be + * passed to all subsequent library calls that involve the coloring. It should be + * destroyed at the end using hipsparseDestroyColorInfo(). + */ +typedef void* hipsparseColorInfo_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding bsrsv2 info. + * + * \details + * The hipSPARSE bsrsv2 structure holds the information used by hipsparseXbsrsv2_zeroPivot(), + * hipsparseXbsrsv2_bufferSize(), hipsparseXbsrsv2_bufferSizeExt(), hipsparseXbsrsv2_analysis(), + * and hipsparseXbsrsv2_solve(). It must be initialized using hipsparseCreateBsrsv2Info() and + * the returned structure must be passed to all subsequent library calls that involve bsrsv2. + * It should be destroyed at the end using hipsparseDestroyBsrsv2Info(). + */ +typedef struct bsrsv2Info* bsrsv2Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding bsrsm2 info. + * + * \details + * The hipSPARSE bsrsm2 structure holds the information used by hipsparseXbsrsm2_zeroPivot(), hipsparseXbsrsm2_bufferSize(), + * hipsparseXbsrsm2_analysis(), and hipsparseXbsrsm2_solve(). It must be initialized using + * hipsparseCreateBsrsm2Info() and the returned structure must be + * passed to all subsequent library calls that involve bsrsm2. It should be + * destroyed at the end using hipsparseDestroyBsrsm2Info(). + */ +typedef struct bsrsm2Info* bsrsm2Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding bsrilu02 info. + * + * \details + * The hipSPARSE bsrilu02 structure holds the information used by hipsparseXbsrilu02_zeroPivot(), + * hipsparseXbsrilu02_numericBoost(), hipsparseXbsrilu02_bufferSize(), hipsparseXbsrilu02_analysis(), + * and hipsparseXbsrilu02(). It must be initialized using hipsparseCreateBsrilu02Info() and the + * returned structure must be passed to all subsequent library calls that involve bsrilu02. It should be + * destroyed at the end using hipsparseDestroyBsrilu02Info(). + */ +typedef struct bsrilu02Info* bsrilu02Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding bsric02 info. + * + * \details + * The hipSPARSE bsric02 structure holds the information used by hipsparseXbsric02_zeroPivot(), hipsparseXbsric02_bufferSize(), + * hipsparseXbsric02_analysis(), and hipsparseXbsric02(). It must be initialized using + * hipsparseCreateBsric02Info() and the returned structure must be + * passed to all subsequent library calls that involve bsric02. It should be + * destroyed at the end using hipsparseDestroyBsric02Info(). + */ +typedef struct bsric02Info* bsric02Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding csrsv2 info. + * + * \details + * The hipSPARSE csrsv2 structure holds the information used by hipsparseXcsrsv2_zeroPivot(), hipsparseXcsrsv2_bufferSize(), + * hipsparseXcsrsv2_analysis(), and hipsparseXcsrsv2(). It must be initialized using + * hipsparseCreateCsrsv2Info() and the returned structure must be + * passed to all subsequent library calls that involve csrsv2. It should be + * destroyed at the end using hipsparseDestroyCsrsv2Info(). + */ +typedef struct csrsv2Info* csrsv2Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding csrsm2 info. + * + * \details + * The hipSPARSE csrsm2 structure holds the information used by hipsparseXcsrsm2_zeroPivot(), hipsparseXcsrsm2_bufferSize(), + * hipsparseXcsrsm2_analysis(), and hipsparseXcsrsm2(). It must be initialized using + * hipsparseCreateCsrsm2Info() and the returned structure must be + * passed to all subsequent library calls that involve csrsm2. It should be + * destroyed at the end using hipsparseDestroyCsrsm2Info(). + */ +typedef struct csrsm2Info* csrsm2Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding csrilu02 info. + * + * \details + * The hipSPARSE csrilu02 structure holds the information used by hipsparseXcsrilu02_zeroPivot(), + * hipsparseXcsrilu02_numericBoost(), hipsparseXcsrilu02_bufferSize(), hipsparseXcsrilu02_analysis(), + * and hipsparseXcsrilu02(). It must be initialized using hipsparseCreateCsrilu02Info() and the + * returned structure must be passed to all subsequent library calls that involve csrilu02. It should be + * destroyed at the end using hipsparseDestroyCsrilu02Info(). + */ +typedef struct csrilu02Info* csrilu02Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding csric02 info. + * + * \details + * The hipSPARSE csric02 structure holds the information used by hipsparseXcsric02_zeroPivot(), + * hipsparseXcsric02_bufferSize(), hipsparseXcsric02_analysis(), and hipsparseXcsric02(). It must be + * initialized using hipsparseCreateCsric02Info() and the returned structure must be passed to all + * subsequent library calls that involve csric02. It should be destroyed at the end using + * hipsparseDestroyCsric02Info(). + */ +typedef struct csric02Info* csric02Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding csrgemm2 info. + * + * \details + * The hipSPARSE csrgemm2 structure holds the information used by hipsparseXcsrgemm2_bufferSizeExt(), + * hipsparseXcsrgemm2Nnz(), and hipsparseXcsrgemm2(). It must be initialized using + * hipsparseCreateCsrgemm2Info() and the returned structure must be passed to all subsequent + * library calls that involve csrgemm2. It should be destroyed at the end using + * hipsparseDestroyCsrgemm2Info(). + */ +typedef struct csrgemm2Info* csrgemm2Info_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding prune info. + * + * \details + * The hipSPARSE prune structure holds the information used by hipsparseXpruneDense2csrByPercentage_bufferSize(), + * hipsparseXpruneDense2csrByPercentage_bufferSizeExt(), hipsparseXpruneCsr2csrByPercentage_bufferSize(), + * hipsparseXpruneCsr2csrByPercentage_bufferSizeExt(), hipsparseXpruneDense2csrNnzByPercentage(), + * hipsparseXpruneCsr2csrNnzByPercentage(), hipsparseXpruneDense2csrByPercentage(), and + * hipsparseXpruneCsr2csrByPercentage(). It must be initialized using hipsparseCreatePruneInfo() and the + * returned structure must be passed to all subsequent library calls that involve prune. It should be + * destroyed at the end using hipsparseDestroyPruneInfo(). + */ +typedef struct pruneInfo* pruneInfo_t; + +/*! \ingroup types_module + * \brief Pointer type to opaque structure holding csru2csr info. + * + * \details + * The hipSPARSE csru2csr structure holds the information used by hipsparseXcsru2csr_bufferSizeExt(), + * hipsparseXcsru2csr(), and hipsparseXcsr2csru(). It must be initialized using hipsparseCreateCsru2csrInfo() + * and the returned structure must be passed to all subsequent library calls that involve csru2csr. It should be + * destroyed at the end using hipsparseDestroyCsru2csrInfo(). + */ +typedef struct csru2csrInfo* csru2csrInfo_t; + +// clang-format off + +/*! \ingroup types_module + * \brief List of hipsparse status codes definition. + * + * \details + * This is a list of the \ref hipsparseStatus_t types that are used by the hipSPARSE + * library. + */ +#if(!defined(CUDART_VERSION)) +typedef enum { + HIPSPARSE_STATUS_SUCCESS = 0, /**< Function succeeds */ + HIPSPARSE_STATUS_NOT_INITIALIZED = 1, /**< hipSPARSE was not initialized */ + HIPSPARSE_STATUS_ALLOC_FAILED = 2, /**< Resource allocation failed */ + HIPSPARSE_STATUS_INVALID_VALUE = 3, /**< Unsupported value was passed to the function */ + HIPSPARSE_STATUS_ARCH_MISMATCH = 4, /**< Device architecture not supported */ + HIPSPARSE_STATUS_MAPPING_ERROR = 5, /**< Access to GPU memory space failed */ + HIPSPARSE_STATUS_EXECUTION_FAILED = 6, /**< GPU program failed to execute */ + HIPSPARSE_STATUS_INTERNAL_ERROR = 7, /**< An internal hipSPARSE operation failed */ + HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED = 8, /**< Matrix type not supported */ + HIPSPARSE_STATUS_ZERO_PIVOT = 9, /**< Zero pivot was computed */ + HIPSPARSE_STATUS_NOT_SUPPORTED = 10, /**< Operation is not supported */ + HIPSPARSE_STATUS_INSUFFICIENT_RESOURCES = 11 /**< Resources are insufficient */ +} hipsparseStatus_t; +#else +#if(CUDART_VERSION >= 11003) +typedef enum { + HIPSPARSE_STATUS_SUCCESS = 0, /**< Function succeeds */ + HIPSPARSE_STATUS_NOT_INITIALIZED = 1, /**< hipSPARSE was not initialized */ + HIPSPARSE_STATUS_ALLOC_FAILED = 2, /**< Resource allocation failed */ + HIPSPARSE_STATUS_INVALID_VALUE = 3, /**< Unsupported value was passed to the function */ + HIPSPARSE_STATUS_ARCH_MISMATCH = 4, /**< Device architecture not supported */ + HIPSPARSE_STATUS_MAPPING_ERROR = 5, /**< Access to GPU memory space failed */ + HIPSPARSE_STATUS_EXECUTION_FAILED = 6, /**< GPU program failed to execute */ + HIPSPARSE_STATUS_INTERNAL_ERROR = 7, /**< An internal hipSPARSE operation failed */ + HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED = 8, /**< Matrix type not supported */ + HIPSPARSE_STATUS_ZERO_PIVOT = 9, /**< Zero pivot was computed */ + HIPSPARSE_STATUS_NOT_SUPPORTED = 10, /**< Operation is not supported */ + HIPSPARSE_STATUS_INSUFFICIENT_RESOURCES = 11 /**< Resources are insufficient */ +} hipsparseStatus_t; +#elif(CUDART_VERSION >= 10010) +typedef enum { + HIPSPARSE_STATUS_SUCCESS = 0, /**< Function succeeds */ + HIPSPARSE_STATUS_NOT_INITIALIZED = 1, /**< hipSPARSE was not initialized */ + HIPSPARSE_STATUS_ALLOC_FAILED = 2, /**< Resource allocation failed */ + HIPSPARSE_STATUS_INVALID_VALUE = 3, /**< Unsupported value was passed to the function */ + HIPSPARSE_STATUS_ARCH_MISMATCH = 4, /**< Device architecture not supported */ + HIPSPARSE_STATUS_MAPPING_ERROR = 5, /**< Access to GPU memory space failed */ + HIPSPARSE_STATUS_EXECUTION_FAILED = 6, /**< GPU program failed to execute */ + HIPSPARSE_STATUS_INTERNAL_ERROR = 7, /**< An internal hipSPARSE operation failed */ + HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED = 8, /**< Matrix type not supported */ + HIPSPARSE_STATUS_ZERO_PIVOT = 9, /**< Zero pivot was computed */ + HIPSPARSE_STATUS_NOT_SUPPORTED = 10 /**< Operation is not supported */ +} hipsparseStatus_t; +#endif +#endif + +/*! \ingroup types_module + * \brief Indicates if the pointer is device pointer or host pointer. + * + * \details + * The \ref hipsparsePointerMode_t indicates whether scalar values are passed by + * reference on the host or device. The \ref hipsparsePointerMode_t can be changed by + * hipsparseSetPointerMode(). The currently used pointer mode can be obtained by + * hipsparseGetPointerMode(). + */ +typedef enum { + HIPSPARSE_POINTER_MODE_HOST = 0, /**< Scalar pointers are in host memory */ + HIPSPARSE_POINTER_MODE_DEVICE = 1 /**< Scalar pointers are in device memory */ +} hipsparsePointerMode_t; + +/*! \ingroup types_module + * \brief Specify where the operation is performed on. + * + * \details + * The \ref hipsparseAction_t indicates whether the operation is performed on the full + * matrix, or only on the sparsity pattern of the matrix. + */ +typedef enum { + HIPSPARSE_ACTION_SYMBOLIC = 0, /**< Operate only on indices */ + HIPSPARSE_ACTION_NUMERIC = 1 /**< Operate on data and indices */ +} hipsparseAction_t; + +/*! \ingroup types_module + * \brief Specify the matrix type. + * + * \details + * The \ref hipsparseMatrixType_t indices the type of a matrix. For a given + * \ref hipsparseMatDescr_t, the \ref hipsparseMatrixType_t can be set using + * hipsparseSetMatType(). The current \ref hipsparseMatrixType_t of a matrix can be + * obtained by hipsparseGetMatType(). + */ +typedef enum { + HIPSPARSE_MATRIX_TYPE_GENERAL = 0, /**< General matrix type */ + HIPSPARSE_MATRIX_TYPE_SYMMETRIC = 1, /**< Symmetric matrix type */ + HIPSPARSE_MATRIX_TYPE_HERMITIAN = 2, /**< Hermitian matrix type */ + HIPSPARSE_MATRIX_TYPE_TRIANGULAR = 3 /**< Triangular matrix type */ +} hipsparseMatrixType_t; + +/*! \ingroup types_module + * \brief Specify the matrix fill mode. + * + * \details + * The \ref hipsparseFillMode_t indicates whether the lower or the upper part is stored + * in a sparse triangular matrix. For a given \ref hipsparseMatDescr_t, the + * \ref hipsparseFillMode_t can be set using hipsparseSetMatFillMode(). The current + * \ref hipsparseFillMode_t of a matrix can be obtained by hipsparseGetMatFillMode(). + */ +typedef enum { + HIPSPARSE_FILL_MODE_LOWER = 0, /**< Lower triangular part is stored */ + HIPSPARSE_FILL_MODE_UPPER = 1 /**< Upper triangular part is stored */ +} hipsparseFillMode_t; + +/*! \ingroup types_module + * \brief Indicates if the diagonal entries are unity. + * + * \details + * The \ref hipsparseDiagType_t indicates whether the diagonal entries of a matrix are + * unity or not. If \ref HIPSPARSE_DIAG_TYPE_UNIT is specified, all present diagonal + * values will be ignored. For a given \ref hipsparseMatDescr_t, the + * \ref hipsparseDiagType_t can be set using hipsparseSetMatDiagType(). The current + * \ref hipsparseDiagType_t of a matrix can be obtained by hipsparseGetMatDiagType(). + */ +typedef enum { + HIPSPARSE_DIAG_TYPE_NON_UNIT = 0, /**< Diagonal entries are non-unity */ + HIPSPARSE_DIAG_TYPE_UNIT = 1 /**< Diagonal entries are unity */ +} hipsparseDiagType_t; + +/*! \ingroup types_module + * \brief Specify the matrix index base. + * + * \details + * The \ref hipsparseIndexBase_t indicates the index base of the indices. For a + * given \ref hipsparseMatDescr_t, the \ref hipsparseIndexBase_t can be set using + * hipsparseSetMatIndexBase(). The current \ref hipsparseIndexBase_t of a matrix + * can be obtained by hipsparseGetMatIndexBase(). + */ +typedef enum { + HIPSPARSE_INDEX_BASE_ZERO = 0, /**< Zero based indexing */ + HIPSPARSE_INDEX_BASE_ONE = 1 /**< One based indexing */ +} hipsparseIndexBase_t; + +/*! \ingroup types_module + * \brief Specify whether the matrix is to be transposed or not. + * + * \details + * The \ref hipsparseOperation_t indicates the operation performed with the given matrix. + */ +typedef enum { + HIPSPARSE_OPERATION_NON_TRANSPOSE = 0, /**< Operate with matrix */ + HIPSPARSE_OPERATION_TRANSPOSE = 1, /**< Operate with transpose */ + HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE = 2 /**< Operate with conj. transpose */ +} hipsparseOperation_t; + +/*! \ingroup types_module + * \brief HYB matrix partitioning type. + * + * \details + * The \ref hipsparseHybPartition_t type indicates how the hybrid format partitioning + * between COO and ELL storage formats is performed. + */ +typedef enum { + HIPSPARSE_HYB_PARTITION_AUTO = 0, /**< Automatically decide on ELL nnz per row */ + HIPSPARSE_HYB_PARTITION_USER = 1, /**< User given ELL nnz per row */ + HIPSPARSE_HYB_PARTITION_MAX = 2 /**< Max ELL nnz per row, no COO part */ +} hipsparseHybPartition_t; + +/*! \ingroup types_module + * \brief Specify policy in triangular solvers and factorizations. + * + * \details + * The \ref hipsparseSolvePolicy_t type indicates the solve policy for the triangular + * solve. + */ +typedef enum { + HIPSPARSE_SOLVE_POLICY_NO_LEVEL = 0, /**< No level information generated */ + HIPSPARSE_SOLVE_POLICY_USE_LEVEL = 1 /**< Generate level information */ +} hipsparseSolvePolicy_t; + +/// \cond DO_NOT_DOCUMENT +// Note: Add back to types.rst if we get documentation for this in the future +typedef enum { + HIPSPARSE_SIDE_LEFT = 0, + HIPSPARSE_SIDE_RIGHT = 1 +} hipsparseSideMode_t; +/// \endcond + +/*! \ingroup types_module + * \brief Specify the matrix direction. + * + * \details + * The \ref hipsparseDirection_t indicates whether a dense matrix should be parsed by + * rows or by columns, assuming column-major storage. + */ +typedef enum { + HIPSPARSE_DIRECTION_ROW = 0, /**< Parse the matrix by rows */ + HIPSPARSE_DIRECTION_COLUMN = 1 /**< Parse the matrix by columns */ +} hipsparseDirection_t; + +// clang-format on diff --git a/library/include/level1/hipsparse_axpyi.h b/library/include/level1/hipsparse_axpyi.h new file mode 100644 index 00000000..f59aa6fd --- /dev/null +++ b/library/include/level1/hipsparse_axpyi.h @@ -0,0 +1,147 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level1_module +* \brief Scale a sparse vector and add it to a dense vector. +* +* \details +* \p hipsparseXaxpyi multiplies the sparse vector \f$x\f$ with scalar \f$\alpha\f$ and +* adds the result to the dense vector \f$y\f$, such that +* +* \f[ +* y := y + \alpha \cdot x +* \f] +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* y[x_ind[i]] = y[x_ind[i]] + alpha * x_val[i]; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Sparse index vector +* int hx_ind[3] = {0, 3, 5}; +* +* // Sparse value vector +* double hx_val[3] = {1.0, 2.0, 3.0}; +* +* // Dense vector +* double hy[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; +* +* // Scalar alpha +* double alpha = 3.7; +* +* // Index base +* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; +* +* // Offload data to device +* int* dx_ind; +* double* dx_val; +* double* dy; +* +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(double) * nnz); +* hipMalloc((void**)&dy, sizeof(double) * 9); +* +* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val, sizeof(double) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(double) * 9, hipMemcpyHostToDevice); +* +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Call daxpyi to perform y = y + alpha * x +* hipsparseDaxpyi(handle, nnz, &alpha, dx_val, dx_ind, dy, idx_base); +* +* // Copy result back to host +* hipMemcpy(hy, dy, sizeof(double) * 9, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSaxpyi(hipsparseHandle_t handle, + int nnz, + const float* alpha, + const float* xVal, + const int* xInd, + float* y, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDaxpyi(hipsparseHandle_t handle, + int nnz, + const double* alpha, + const double* xVal, + const int* xInd, + double* y, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCaxpyi(hipsparseHandle_t handle, + int nnz, + const hipComplex* alpha, + const hipComplex* xVal, + const int* xInd, + hipComplex* y, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZaxpyi(hipsparseHandle_t handle, + int nnz, + const hipDoubleComplex* alpha, + const hipDoubleComplex* xVal, + const int* xInd, + hipDoubleComplex* y, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level1/hipsparse_dotci.h b/library/include/level1/hipsparse_dotci.h new file mode 100644 index 00000000..2cbfb079 --- /dev/null +++ b/library/include/level1/hipsparse_dotci.h @@ -0,0 +1,77 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup level1_module +* \brief Compute the dot product of a complex conjugate sparse vector with a dense +* vector. +* +* \details +* \p hipsparseXdotci computes the dot product of the complex conjugate sparse vector +* \f$x\f$ with the dense vector \f$y\f$, such that +* \f[ +* \text{result} := \bar{x}^H y +* \f] +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* result += conj(x_val[i]) * y[x_ind[i]]; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCdotci(hipsparseHandle_t handle, + int nnz, + const hipComplex* xVal, + const int* xInd, + const hipComplex* y, + hipComplex* result, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZdotci(hipsparseHandle_t handle, + int nnz, + const hipDoubleComplex* xVal, + const int* xInd, + const hipDoubleComplex* y, + hipDoubleComplex* result, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level1/hipsparse_doti.h b/library/include/level1/hipsparse_doti.h new file mode 100644 index 00000000..eb8b6098 --- /dev/null +++ b/library/include/level1/hipsparse_doti.h @@ -0,0 +1,141 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup level1_module +* \brief Compute the dot product of a sparse vector with a dense vector. +* +* \details +* \p hipsparseXdoti computes the dot product of the sparse vector \f$x\f$ with the +* dense vector \f$y\f$, such that +* \f[ +* \text{result} := y^T x +* \f] +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* result += x_val[i] * y[x_ind[i]]; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Sparse index vector +* int hx_ind[3] = {0, 3, 5}; +* +* // Sparse value vector +* float hx_val[3] = {1.0f, 2.0f, 3.0f}; +* +* // Dense vector +* float hy[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // Index base +* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * 9); +* +* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val, sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); +* +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Call sdoti to compute the dot product +* float dot; +* hipsparseSdoti(handle, nnz, dx_val, dx_ind, dy, &dot, idx_base); +* +* // Clear hipSPARSE +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSdoti(hipsparseHandle_t handle, + int nnz, + const float* xVal, + const int* xInd, + const float* y, + float* result, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDdoti(hipsparseHandle_t handle, + int nnz, + const double* xVal, + const int* xInd, + const double* y, + double* result, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCdoti(hipsparseHandle_t handle, + int nnz, + const hipComplex* xVal, + const int* xInd, + const hipComplex* y, + hipComplex* result, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZdoti(hipsparseHandle_t handle, + int nnz, + const hipDoubleComplex* xVal, + const int* xInd, + const hipDoubleComplex* y, + hipDoubleComplex* result, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level1/hipsparse_gthr.h b/library/include/level1/hipsparse_gthr.h new file mode 100644 index 00000000..3dc96989 --- /dev/null +++ b/library/include/level1/hipsparse_gthr.h @@ -0,0 +1,135 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level1_module +* \brief Gather elements from a dense vector and store them into a sparse vector. +* +* \details +* \p hipsparseXgthr gathers the elements that are listed in \p x_ind from the dense +* vector \f$y\f$ and stores them in the sparse vector \f$x\f$. +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* x_val[i] = y[x_ind[i]]; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Sparse index vector +* int hx_ind[3] = {0, 3, 5}; +* +* // Sparse value vector +* float hx_val[3]; +* +* // Dense vector +* float hy[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; +* +* // Index base +* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * 9); +* +* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); +* +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Call sgthr +* hipsparseSgthr(handle, nnz, dy, dx_val, dx_ind, idx_base); +* +* // Copy result back to host +* hipMemcpy(hx_val, dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgthr(hipsparseHandle_t handle, + int nnz, + const float* y, + float* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgthr(hipsparseHandle_t handle, + int nnz, + const double* y, + double* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgthr(hipsparseHandle_t handle, + int nnz, + const hipComplex* y, + hipComplex* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgthr(hipsparseHandle_t handle, + int nnz, + const hipDoubleComplex* y, + hipDoubleComplex* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level1/hipsparse_gthrz.h b/library/include/level1/hipsparse_gthrz.h new file mode 100644 index 00000000..dfc013fa --- /dev/null +++ b/library/include/level1/hipsparse_gthrz.h @@ -0,0 +1,91 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level1_module +* \brief Gather and zero out elements from a dense vector and store them into a sparse +* vector. +* +* \details +* \p hipsparseXgthrz gathers the elements that are listed in \p x_ind from the dense +* vector \f$y\f$ and stores them in the sparse vector \f$x\f$. The gathered elements +* in \f$y\f$ are replaced by zero. +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* x_val[i] = y[x_ind[i]]; +* y[x_ind[i]] = 0; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ + +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgthrz(hipsparseHandle_t handle, + int nnz, + float* y, + float* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgthrz(hipsparseHandle_t handle, + int nnz, + double* y, + double* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgthrz(hipsparseHandle_t handle, + int nnz, + hipComplex* y, + hipComplex* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgthrz(hipsparseHandle_t handle, + int nnz, + hipDoubleComplex* y, + hipDoubleComplex* xVal, + const int* xInd, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level1/hipsparse_roti.h b/library/include/level1/hipsparse_roti.h new file mode 100644 index 00000000..5b266488 --- /dev/null +++ b/library/include/level1/hipsparse_roti.h @@ -0,0 +1,136 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level1_module +* \brief Apply Givens rotation to a dense and a sparse vector. +* +* \details +* \p hipsparseXroti applies the Givens rotation matrix \f$G\f$ to the sparse vector +* \f$x\f$ and the dense vector \f$y\f$, where +* \f[ +* G = \begin{pmatrix} c & s \\ -s & c \end{pmatrix} +* \f] +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* x_tmp = x_val[i]; +* y_tmp = y[x_ind[i]]; +* +* x_val[i] = c * x_tmp + s * y_tmp; +* y[x_ind[i]] = c * y_tmp - s * x_tmp; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Sparse index vector +* int hx_ind[3] = {0, 3, 5}; +* +* // Sparse value vector +* float hx_val[3] = {1.0f, 2.0f, 3.0f}; +* +* // Dense vector +* float hy[9] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; +* +* // c and s +* float c = 3.7; +* float s = 1.3; +* +* // Index base +* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * 9); +* +* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val, sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); +* +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Call sroti +* hipsparseSroti(handle, nnz, dx_val, dx_ind, dy, &c, &s, idx_base); +* +* // Copy result back to host +* hipMemcpy(hx_val, dx_val, sizeof(float) * nnz, hipMemcpyDeviceToHost); +* hipMemcpy(hy, dy, sizeof(float) * 9, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSroti(hipsparseHandle_t handle, + int nnz, + float* xVal, + const int* xInd, + float* y, + const float* c, + const float* s, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDroti(hipsparseHandle_t handle, + int nnz, + double* xVal, + const int* xInd, + double* y, + const double* c, + const double* s, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level1/hipsparse_sctr.h b/library/include/level1/hipsparse_sctr.h new file mode 100644 index 00000000..a1d03128 --- /dev/null +++ b/library/include/level1/hipsparse_sctr.h @@ -0,0 +1,137 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level1_module +* \brief Scatter elements from a dense vector across a sparse vector. +* +* \details +* \p hipsparseXsctr scatters the elements that are listed in \p x_ind from the sparse +* vector \f$x\f$ into the dense vector \f$y\f$. Indices of \f$y\f$ that are not listed +* in \p x_ind remain unchanged. +* +* \code{.c} +* for(i = 0; i < nnz; ++i) +* { +* y[x_ind[i]] = x_val[i]; +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \par Example +* \code{.c} +* // Number of non-zeros of the sparse vector +* int nnz = 3; +* +* // Sparse index vector +* int hx_ind[3] = {0, 3, 5}; +* +* // Sparse value vector +* float hx_val[3] = {9.0, 2.0, 3.0}; +* +* // Dense vector +* float hy[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; +* +* // Index base +* hipsparseIndexBase_t idx_base = HIPSPARSE_INDEX_BASE_ZERO; +* +* // Offload data to device +* int* dx_ind; +* float* dx_val; +* float* dy; +* +* hipMalloc((void**)&dx_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dx_val, sizeof(float) * nnz); +* hipMalloc((void**)&dy, sizeof(float) * 9); +* +* hipMemcpy(dx_ind, hx_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx_val, hx_val, sizeof(float) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(float) * 9, hipMemcpyHostToDevice); +* +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // Call ssctr +* hipsparseSsctr(handle, nnz, dx_val, dx_ind, dy, idx_base); +* +* // Copy result back to host +* hipMemcpy(hy, dy, sizeof(float) * 9, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dx_ind); +* hipFree(dx_val); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSsctr(hipsparseHandle_t handle, + int nnz, + const float* xVal, + const int* xInd, + float* y, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDsctr(hipsparseHandle_t handle, + int nnz, + const double* xVal, + const int* xInd, + double* y, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCsctr(hipsparseHandle_t handle, + int nnz, + const hipComplex* xVal, + const int* xInd, + hipComplex* y, + hipsparseIndexBase_t idxBase); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZsctr(hipsparseHandle_t handle, + int nnz, + const hipDoubleComplex* xVal, + const int* xInd, + hipDoubleComplex* y, + hipsparseIndexBase_t idxBase); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_bsrmv.h b/library/include/level2/hipsparse_bsrmv.h new file mode 100644 index 00000000..6463cb9e --- /dev/null +++ b/library/include/level2/hipsparse_bsrmv.h @@ -0,0 +1,229 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup level2_module +* \brief Sparse matrix vector multiplication using BSR storage format +* +* \details +* \p hipsparseXbsrmv multiplies the scalar \f$\alpha\f$ with a sparse +* \f$(mb \cdot \text{block_dim}) \times (nb \cdot \text{block_dim})\f$ +* matrix, defined in BSR storage format, and the dense vector \f$x\f$ and adds the +* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, +* such that +* \f[ +* y := \alpha \cdot op(A) \cdot x + \beta \cdot y, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // alpha * ( 1.0 0.0 2.0 ) * ( 1.0 ) + beta * ( 4.0 ) = ( 31.1 ) +* // ( 3.0 0.0 4.0 ) * ( 2.0 ) ( 5.0 ) = ( 62.0 ) +* // ( 5.0 6.0 0.0 ) * ( 3.0 ) ( 6.0 ) = ( 70.7 ) +* // ( 7.0 0.0 8.0 ) * ( 7.0 ) = ( 123.8 ) +* +* // BSR block dimension +* int bsr_dim = 2; +* +* // Number of block rows and columns +* int mb = 2; +* int nb = 2; +* +* // Number of non-zero blocks +* int nnzb = 4; +* +* // BSR row pointers +* int hbsr_row_ptr[3] = {0, 2, 4}; +* +* // BSR column indices +* int hbsr_col_ind[4] = {0, 1, 0, 1}; +* +* // BSR values +* double hbsr_val[16] +* = {1.0, 3.0, 0.0, 0.0, 2.0, 4.0, 0.0, 0.0, 5.0, 7.0, 6.0, 0.0, 0.0, 8.0, 0.0, 0.0}; +* +* // Block storage in column major +* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_COLUMN; +* +* // Transposition of the matrix +* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* +* // Scalar alpha and beta +* double alpha = 3.7; +* double beta = 1.3; +* +* // x and y +* double hx[4] = {1.0, 2.0, 3.0, 0.0}; +* double hy[4] = {4.0, 5.0, 6.0, 7.0}; +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Offload data to device +* int* dbsr_row_ptr; +* int* dbsr_col_ind; +* double* dbsr_val; +* double* dx; +* double* dy; +* +* hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); +* hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); +* hipMalloc((void**)&dbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim); +* hipMalloc((void**)&dx, sizeof(double) * nb * bsr_dim); +* hipMalloc((void**)&dy, sizeof(double) * mb * bsr_dim); +* +* hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); +* hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); +* hipMemcpy(dbsr_val, hbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim, hipMemcpyHostToDevice); +* hipMemcpy(dx, hx, sizeof(double) * nb * bsr_dim, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(double) * mb * bsr_dim, hipMemcpyHostToDevice); +* +* // Call dbsrmv to perform y = alpha * A x + beta * y +* hipsparseDbsrmv(handle, +* dir, +* trans, +* mb, +* nb, +* nnzb, +* &alpha, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* dx, +* &beta, +* dy); +* +* // Copy result back to host +* hipMemcpy(hy, dy, sizeof(double) * mb * bsr_dim, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroyMatDescr(descr); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dbsr_row_ptr); +* hipFree(dbsr_col_ind); +* hipFree(dbsr_val); +* hipFree(dx); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrmv(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nb, + int nnzb, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + const float* x, + const float* beta, + float* y); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrmv(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nb, + int nnzb, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + const double* x, + const double* beta, + double* y); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrmv(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nb, + int nnzb, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + const hipComplex* x, + const hipComplex* beta, + hipComplex* y); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrmv(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nb, + int nnzb, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + const hipDoubleComplex* x, + const hipDoubleComplex* beta, + hipDoubleComplex* y); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_bsrsv.h b/library/include/level2/hipsparse_bsrsv.h new file mode 100644 index 00000000..a71b1764 --- /dev/null +++ b/library/include/level2/hipsparse_bsrsv.h @@ -0,0 +1,551 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using BSR storage format +* +* \details +* \p hipsparseXbsrsv2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a +* structural or numerical zero has been found during hipsparseXbsrsv2_analysis() or +* hipsparseXbsrsv2_solve() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ +* is stored in \p position, using same index base as the BSR matrix. +* +* \p position can be in host or device memory. If no zero pivot has been found, +* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. +* +* \note \p hipsparseXbsrsv2_zeroPivot is a blocking function. It might influence +* performance negatively. +*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXbsrsv2_zeroPivot(hipsparseHandle_t handle, bsrsv2Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using BSR storage format +* +* \details +* \p hipsparseXbsrsv2_bufferSize returns the size of the temporary storage buffer in bytes +* that is required by hipsparseXbsrsv2_analysis() and hipsparseXbsrsv2_solve(). The +* temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +/*! \ingroup level2_module +* \brief Sparse triangular solve using BSR storage format +* +* \details +* \p hipsparseXbsrsv2_bufferSizeExt returns the size of the temporary storage buffer in bytes +* that is required by hipsparseXbsrsv2_analysis() and hipsparseXbsrsv2_solve(). The +* temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + size_t* pBufferSizeInBytes); +/**@}*/ + + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using BSR storage format +* +* \details +* \p hipsparseXbsrsv2_analysis performs the analysis step for hipsparseXbsrsv2_solve(). +* +* \note +* If the matrix sparsity pattern changes, the gathered information will become invalid. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsv2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsv2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsv2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsv2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using BSR storage format +* +* \details +* \p hipsparseXbsrsv2_solve solves a sparse triangular linear system of a sparse +* \f$m \times m\f$ matrix, defined in BSR storage format, a dense solution vector +* \f$y\f$ and the right-hand side \f$x\f$ that is multiplied by \f$\alpha\f$, such that +* \f[ +* op(A) \cdot y = \alpha \cdot x, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \p hipsparseXbsrsv2_solve requires a user allocated temporary buffer. Its size is +* returned by hipsparseXbsrsv2_bufferSize() or hipsparseXbsrsv2_bufferSizeExt(). +* Furthermore, analysis meta data is required. It can be obtained by +* hipsparseXbsrsv2_analysis(). \p hipsparseXbsrsv2_solve reports the first zero pivot +* (either numerical or structural zero). The zero pivot status can be checked calling +* hipsparseXbsrsv2_zeroPivot(). If +* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be +* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. +* +* \note +* The sparse BSR matrix has to be sorted. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE and +* \p trans == \ref HIPSPARSE_OPERATION_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // A = ( 1.0 0.0 0.0 0.0 ) +* // ( 2.0 3.0 0.0 0.0 ) +* // ( 4.0 5.0 6.0 0.0 ) +* // ( 7.0 0.0 8.0 9.0 ) +* // +* // with bsr_dim = 2 +* // +* // ------------------- +* // = | 1.0 0.0 | 0.0 0.0 | +* // | 2.0 3.0 | 0.0 0.0 | +* // ------------------- +* // | 4.0 5.0 | 6.0 0.0 | +* // | 7.0 0.0 | 8.0 9.0 | +* // ------------------- +* +* // Number of rows and columns +* int m = 4; +* +* // Number of block rows and block columns +* int mb = 2; +* int nb = 2; +* +* // BSR block dimension +* int bsr_dim = 2; +* +* // Number of non-zero blocks +* int nnzb = 3; +* +* // BSR row pointers +* int hbsr_row_ptr[3] = {0, 1, 3}; +* +* // BSR column indices +* int hbsr_col_ind[3] = {0, 0, 1}; +* +* // BSR values +* double hbsr_val[12] = {1.0, 2.0, 0.0, 3.0, 4.0, 7.0, 5.0, 0.0, 6.0, 8.0, 0.0, 9.0}; +* +* // Storage scheme of the BSR blocks +* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_COLUMN; +* +* // Transposition of the matrix and rhs matrix +* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* +* // Solve policy +* hipsparseSolvePolicy_t solve_policy = HIPSPARSE_SOLVE_POLICY_USE_LEVEL; +* +* // Scalar alpha and beta +* double alpha = 3.7; +* +* double hx[4] = {1, 2, 3, 4}; +* double hy[4]; +* +* // Offload data to device +* int* dbsr_row_ptr; +* int* dbsr_col_ind; +* double* dbsr_val; +* double* dx; +* double* dy; +* +* hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); +* hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); +* hipMalloc((void**)&dbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim); +* hipMalloc((void**)&dx, sizeof(double) * nb * bsr_dim); +* hipMalloc((void**)&dy, sizeof(double) * mb * bsr_dim); +* +* hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); +* hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); +* hipMemcpy(dbsr_val, hbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim, hipMemcpyHostToDevice); +* hipMemcpy(dx, hx, sizeof(double) * nb * bsr_dim, hipMemcpyHostToDevice); +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Matrix fill mode +* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); +* +* // Matrix diagonal type +* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_UNIT); +* +* // Matrix info structure +* bsrsv2Info_t info; +* hipsparseCreateBsrsv2Info(&info); +* +* // Obtain required buffer size +* int buffer_size; +* hipsparseDbsrsv2_bufferSize(handle, +* dir, +* trans, +* mb, +* nnzb, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* info, +* &buffer_size); +* +* // Allocate temporary buffer +* void* dbuffer; +* hipMalloc(&dbuffer, buffer_size); +* +* // Perform analysis step +* hipsparseDbsrsv2_analysis(handle, +* dir, +* trans, +* mb, +* nnzb, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* info, +* solve_policy, +* dbuffer); +* +* // Call dbsrsm to perform lower triangular solve LX = B +* hipsparseDbsrsv2_solve(handle, +* dir, +* trans, +* mb, +* nnzb, +* &alpha, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* info, +* dx, +* dy, +* solve_policy, +* dbuffer); +* +* // Check for zero pivots +* int pivot; +* hipsparseStatus_t status = hipsparseXbsrsv2_zeroPivot(handle, info, &pivot); +* +* if(status == HIPSPARSE_STATUS_ZERO_PIVOT) +* { +* std::cout << "Found zero pivot in matrix row " << pivot << std::endl; +* } +* +* // Copy results back to the host +* hipMemcpy(hy, dy, sizeof(double) * mb * bsr_dim, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroyBsrsv2Info(info); +* hipsparseDestroyMatDescr(descr); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dbsr_row_ptr); +* hipFree(dbsr_col_ind); +* hipFree(dbsr_val); +* hipFree(dx); +* hipFree(dy); +* hipFree(dbuffer); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsv2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + const float* f, + float* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsv2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + const double* f, + double* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsv2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + const hipComplex* f, + hipComplex* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsv2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + int mb, + int nnzb, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsv2Info_t info, + const hipDoubleComplex* f, + hipDoubleComplex* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_bsrxmv.h b/library/include/level2/hipsparse_bsrxmv.h new file mode 100644 index 00000000..87c458f4 --- /dev/null +++ b/library/include/level2/hipsparse_bsrxmv.h @@ -0,0 +1,152 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level2_module +* \brief Sparse matrix vector multiplication with mask operation using BSR storage format +* +* \details +* \p hipsparseXbsrxmv multiplies the scalar \f$\alpha\f$ with a sparse +* \f$(mb \cdot \text{block_dim}) \times (nb \cdot \text{block_dim})\f$ +* modified matrix, defined in BSR storage format, and the dense vector \f$x\f$ and adds the +* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, +* such that +* \f[ +* y := \left( \alpha \cdot op(A) \cdot x + \beta \cdot y \right)\left( \text{mask} \right), +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* The \f$\text{mask}\f$ is defined as an array of block row indices. +* The input sparse matrix is defined with a modified BSR storage format where the beginning and the end of each row +* is defined with two arrays, \p bsr_row_ptr and \p bsr_end_ptr (both of size \p mb), rather the usual \p bsr_row_ptr of size \p mb + 1. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. +* Currently, \p block_dim == 1 is not supported. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrxmv(hipsparseHandle_t handle, + hipsparseDirection_t dir, + hipsparseOperation_t trans, + int sizeOfMask, + int mb, + int nb, + int nnzb, + const float* alpha, + const hipsparseMatDescr_t descr, + const float* bsrVal, + const int* bsrMaskPtr, + const int* bsrRowPtr, + const int* bsrEndPtr, + const int* bsrColInd, + int blockDim, + const float* x, + const float* beta, + float* y); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrxmv(hipsparseHandle_t handle, + hipsparseDirection_t dir, + hipsparseOperation_t trans, + int sizeOfMask, + int mb, + int nb, + int nnzb, + const double* alpha, + const hipsparseMatDescr_t descr, + const double* bsrVal, + const int* bsrMaskPtr, + const int* bsrRowPtr, + const int* bsrEndPtr, + const int* bsrColInd, + int blockDim, + const double* x, + const double* beta, + double* y); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrxmv(hipsparseHandle_t handle, + hipsparseDirection_t dir, + hipsparseOperation_t trans, + int sizeOfMask, + int mb, + int nb, + int nnzb, + const hipComplex* alpha, + const hipsparseMatDescr_t descr, + const hipComplex* bsrVal, + const int* bsrMaskPtr, + const int* bsrRowPtr, + const int* bsrEndPtr, + const int* bsrColInd, + int blockDim, + const hipComplex* x, + const hipComplex* beta, + hipComplex* y); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrxmv(hipsparseHandle_t handle, + hipsparseDirection_t dir, + hipsparseOperation_t trans, + int sizeOfMask, + int mb, + int nb, + int nnzb, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descr, + const hipDoubleComplex* bsrVal, + const int* bsrMaskPtr, + const int* bsrRowPtr, + const int* bsrEndPtr, + const int* bsrColInd, + int blockDim, + const hipDoubleComplex* x, + const hipDoubleComplex* beta, + hipDoubleComplex* y); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_csrmv.h b/library/include/level2/hipsparse_csrmv.h new file mode 100644 index 00000000..6ed39d70 --- /dev/null +++ b/library/include/level2/hipsparse_csrmv.h @@ -0,0 +1,226 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup level2_module +* \brief Sparse matrix vector multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrmv multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times n\f$ +* matrix, defined in CSR storage format, and the dense vector \f$x\f$ and adds the +* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, +* such that +* \f[ +* y := \alpha \cdot op(A) \cdot x + \beta \cdot y, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \code{.c} +* for(i = 0; i < m; ++i) +* { +* y[i] = beta * y[i]; +* +* for(j = csr_row_ptr[i]; j < csr_row_ptr[i + 1]; ++j) +* { +* y[i] = y[i] + alpha * csr_val[j] * x[csr_col_ind[j]]; +* } +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // alpha * ( 1.0 0.0 2.0 ) * ( 1.0 ) + beta * ( 4.0 ) = ( 31.1 ) +* // ( 3.0 0.0 4.0 ) * ( 2.0 ) ( 5.0 ) = ( 62.0 ) +* // ( 5.0 6.0 0.0 ) * ( 3.0 ) ( 6.0 ) = ( 70.7 ) +* // ( 7.0 0.0 8.0 ) * ( 7.0 ) = ( 123.8 ) +* +* int m = 4; +* int n = 3; +* int nnz = 8; +* +* // CSR row pointers +* int hcsr_row_ptr[5] = {0, 2, 4, 6, 8}; +* +* // CSR column indices +* int hcsr_col_ind[8] = {0, 2, 0, 2, 0, 1, 0, 2}; +* +* // CSR values +* double hcsr_val[8] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; +* +* // Transposition of the matrix +* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* +* // Scalar alpha and beta +* double alpha = 3.7; +* double beta = 1.3; +* +* // x and y +* double hx[3] = {1.0, 2.0, 3.0}; +* double hy[4] = {4.0, 5.0, 6.0, 7.0}; +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Offload data to device +* int* dcsr_row_ptr; +* int* dcsr_col_ind; +* double* dcsr_val; +* double* dx; +* double* dy; +* +* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dcsr_val, sizeof(double) * nnz); +* hipMalloc((void**)&dx, sizeof(double) * n); +* hipMalloc((void**)&dy, sizeof(double) * m); +* +* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_val, hcsr_val, sizeof(double) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx, hx, sizeof(double) * n, hipMemcpyHostToDevice); +* hipMemcpy(dy, hy, sizeof(double) * m, hipMemcpyHostToDevice); +* +* // Call dcsrmv to perform y = alpha * A x + beta * y +* hipsparseDcsrmv(handle, +* trans, +* m, +* n, +* nnz, +* &alpha, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* dx, +* &beta, +* dy); +* +* // Copy result back to host +* hipMemcpy(hy, dy, sizeof(double) * m, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroyMatDescr(descr); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dcsr_row_ptr); +* hipFree(dcsr_col_ind); +* hipFree(dcsr_val); +* hipFree(dx); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* x, + const float* beta, + float* y); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* x, + const double* beta, + double* y); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* x, + const hipComplex* beta, + hipComplex* y); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* x, + const hipDoubleComplex* beta, + hipDoubleComplex* y); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_csrsv.h b/library/include/level2/hipsparse_csrsv.h new file mode 100644 index 00000000..40044f9c --- /dev/null +++ b/library/include/level2/hipsparse_csrsv.h @@ -0,0 +1,483 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using CSR storage format +* +* \details +* \p hipsparseXcsrsv2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a +* structural or numerical zero has been found during hipsparseScsrsv2_solve(), +* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() or hipsparseZcsrsv2_solve() +* computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is stored in \p position, +* using same index base as the CSR matrix. +* +* \p position can be in host or device memory. If no zero pivot has been found, +* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. +* +* \note \p hipsparseXcsrsv2_zeroPivot is a blocking function. It might influence +* performance negatively. +*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXcsrsv2_zeroPivot(hipsparseHandle_t handle, csrsv2Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using CSR storage format +* +* \details +* \p hipsparseXcsrsv2_bufferSize returns the size of the temporary storage buffer in bytes +* that is required by hipsparseScsrsv2_analysis(), hipsparseDcsrsv2_analysis(), +* hipsparseCcsrsv2_analysis(), hipsparseZcsrsv2_analysis(), hipsparseScsrsv2_solve(), +* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). The +* temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsv2_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +/*! \ingroup level2_module +* \brief Sparse triangular solve using CSR storage format +* +* \details +* \p hipsparseXcsrsv2_bufferSizeExt returns the size of the temporary storage buffer in bytes +* that is required by hipsparseScsrsv2_analysis(), hipsparseDcsrsv2_analysis(), +* hipsparseCcsrsv2_analysis(), hipsparseZcsrsv2_analysis(), hipsparseScsrsv2_solve(), +* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). The +* temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsv2_bufferSizeExt(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + size_t* pBufferSizeInBytes); +/**@}*/ + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using CSR storage format +* +* \details +* \p hipsparseXcsrsv2_analysis performs the analysis step for hipsparseScsrsv2_solve(), +* hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsv2_analysis(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsv2_analysis(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsv2_analysis(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsv2_analysis(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level2_module +* \brief Sparse triangular solve using CSR storage format +* +* \details +* \p hipsparseXcsrsv2_solve solves a sparse triangular linear system of a sparse +* \f$m \times m\f$ matrix, defined in CSR storage format, a dense solution vector +* \f$y\f$ and the right-hand side \f$x\f$ that is multiplied by \f$\alpha\f$, such that +* \f[ +* op(A) \cdot y = \alpha \cdot x, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \p hipsparseXcsrsv2_solve requires a user allocated temporary buffer. Its size is +* returned by hipsparseXcsrsv2_bufferSize() or hipsparseXcsrsv2_bufferSizeExt(). +* Furthermore, analysis meta data is required. It can be obtained by +* hipsparseXcsrsv2_analysis(). \p hipsparseXcsrsv2_solve reports the first zero pivot +* (either numerical or structural zero). The zero pivot status can be checked calling +* hipsparseXcsrsv2_zeroPivot(). If +* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be +* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. +* +* \note +* The sparse CSR matrix has to be sorted. This can be achieved by calling +* hipsparseXcsrsort(). +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE and +* \p trans == \ref HIPSPARSE_OPERATION_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // alpha * ( 1.0 0.0 2.0 0.0 ) * ( x_0 ) = ( 32.0 ) +* // ( 3.0 2.0 4.0 1.0 ) * ( x_1 ) = ( 14.7 ) +* // ( 5.0 6.0 1.0 3.0 ) * ( x_2 ) = ( 33.6 ) +* // ( 7.0 0.0 8.0 0.6 ) * ( x_3 ) = ( 10.0 ) +* +* int m = 4; +* int nnz = 13; +* +* // CSR row pointers +* int hcsr_row_ptr[5] = {0, 2, 6, 10, 13}; +* +* // CSR column indices +* int hcsr_col_ind[13] = {0, 2, 0, 1, 2, 3, 0, 1, 2, 3, 0, 2, 3}; +* +* // CSR values +* double hcsr_val[13] = {1.0, 2.0, 3.0, 2.0, 4.0, 1.0, 5.0, 6.0, 1.0, 3.0, 7.0, 8.0, 0.6}; +* +* // Transposition of the matrix +* hipsparseOperation_t trans = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseSolvePolicy_t policy = HIPSPARSE_SOLVE_POLICY_USE_LEVEL; +* +* // Scalar alpha +* double alpha = 1.0; +* +* // f and x +* double hf[4] = {32.0, 14.7, 33.6, 10.0}; +* double hx[4]; +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Set index base on descriptor +* hipsparseSetMatIndexBase(descr, HIPSPARSE_INDEX_BASE_ZERO); +* +* // Set fill mode on descriptor +* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); +* +* // Set diag type on descriptor +* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_UNIT); +* +* // Csrsv info +* csrsv2Info_t info; +* hipsparseCreateCsrsv2Info(&info); +* +* // Offload data to device +* int* dcsr_row_ptr; +* int* dcsr_col_ind; +* double* dcsr_val; +* double* df; +* double* dx; +* +* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dcsr_val, sizeof(double) * nnz); +* hipMalloc((void**)&df, sizeof(double) * m); +* hipMalloc((void**)&dx, sizeof(double) * m); +* +* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_val, hcsr_val, sizeof(double) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(df, hf, sizeof(double) * m, hipMemcpyHostToDevice); +* +* int bufferSize = 0; +* hipsparseDcsrsv2_bufferSize(handle, +* trans, +* m, +* nnz, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* info, +* &bufferSize); +* +* void* dbuffer = nullptr; +* hipMalloc((void**)&dbuffer, bufferSize); +* +* hipsparseDcsrsv2_analysis(handle, +* trans, +* m, +* nnz, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* info, +* policy, +* dbuffer); +* +* // Call dcsrsv to perform alpha * A * x = f +* hipsparseDcsrsv2_solve(handle, +* trans, +* m, +* nnz, +* &alpha, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* info, +* df, +* dx, +* policy, +* dbuffer); +* +* // Copy result back to host +* hipMemcpy(hx, dx, sizeof(double) * m, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroyMatDescr(descr); +* hipsparseDestroyCsrsv2Info(info); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dcsr_row_ptr); +* hipFree(dcsr_col_ind); +* hipFree(dcsr_val); +* hipFree(df); +* hipFree(dx); +* hipFree(dbuffer); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsv2_solve(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + const float* f, + float* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsv2_solve(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + const double* f, + double* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsv2_solve(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + const hipComplex* f, + hipComplex* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsv2_solve(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrsv2Info_t info, + const hipDoubleComplex* f, + hipDoubleComplex* x, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_gemvi.h b/library/include/level2/hipsparse_gemvi.h new file mode 100644 index 00000000..f2d2a83c --- /dev/null +++ b/library/include/level2/hipsparse_gemvi.h @@ -0,0 +1,171 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup level2_module + * \brief Dense matrix sparse vector multiplication + * + * \details + * \p hipsparseXgemvi_bufferSize returns the size of the temporary storage buffer in bytes + * required by hipsparseXgemvi(). The temporary storage buffer must be allocated by the + * user. + */ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgemvi_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + int* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgemvi_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + int* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgemvi_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + int* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgemvi_bufferSize(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int nnz, + int* pBufferSizeInBytes); +/**@}*/ + +/*! \ingroup level2_module + * \brief Dense matrix sparse vector multiplication + * + * \details + * \p hipsparseXgemvi multiplies the scalar \f$\alpha\f$ with a dense \f$m \times n\f$ + * matrix \f$A\f$ and the sparse vector \f$x\f$ and adds the result to the dense vector + * \f$y\f$ that is multiplied by the scalar \f$\beta\f$, such that + * \f[ + * y := \alpha \cdot op(A) \cdot x + \beta \cdot y, + * \f] + * with + * \f[ + * op(A) = \left\{ + * \begin{array}{ll} + * A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ + * A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ + * A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} + * \end{array} + * \right. + * \f] + * + * \p hipsparseXgemvi requires a user allocated temporary buffer. Its size is returned + * by hipsparseXgemvi_bufferSize(). + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. + * + * \note + * Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. + */ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgemvi(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + const float* alpha, + const float* A, + int lda, + int nnz, + const float* x, + const int* xInd, + const float* beta, + float* y, + hipsparseIndexBase_t idxBase, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgemvi(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + const double* alpha, + const double* A, + int lda, + int nnz, + const double* x, + const int* xInd, + const double* beta, + double* y, + hipsparseIndexBase_t idxBase, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgemvi(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + const hipComplex* alpha, + const hipComplex* A, + int lda, + int nnz, + const hipComplex* x, + const int* xInd, + const hipComplex* beta, + hipComplex* y, + hipsparseIndexBase_t idxBase, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgemvi(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + const hipDoubleComplex* alpha, + const hipDoubleComplex* A, + int lda, + int nnz, + const hipDoubleComplex* x, + const int* xInd, + const hipDoubleComplex* beta, + hipDoubleComplex* y, + hipsparseIndexBase_t idxBase, + void* pBuffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level2/hipsparse_hybmv.h b/library/include/level2/hipsparse_hybmv.h new file mode 100644 index 00000000..c3e5e3a8 --- /dev/null +++ b/library/include/level2/hipsparse_hybmv.h @@ -0,0 +1,179 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup level2_module +* \brief Sparse matrix vector multiplication using HYB storage format +* +* \details +* \p hipsparseXhybmv multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times n\f$ +* matrix, defined in HYB storage format, and the dense vector \f$x\f$ and adds the +* result to the dense vector \f$y\f$ that is multiplied by the scalar \f$\beta\f$, +* such that +* \f[ +* y := \alpha \cdot op(A) \cdot x + \beta \cdot y, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // A sparse matrix +* // 1 0 3 4 +* // 0 0 5 1 +* // 0 2 0 0 +* // 4 0 0 8 +* int hAptr[5] = {0, 3, 5, 6, 8}; +* int hAcol[8] = {0, 2, 3, 2, 3, 1, 0, 3}; +* double hAval[8] = {1.0, 3.0, 4.0, 5.0, 1.0, 2.0, 4.0, 8.0}; +* +* int m = 4; +* int n = 4; +* int nnz = 8; +* +* double halpha = 1.0; +* double hbeta = 0.0; +* +* double hx[4] = {1.0, 2.0, 3.0, 4.0}; +* double hy[4] = {4.0, 5.0, 6.0, 7.0}; +* +* // Matrix descriptor +* hipsparseMatDescr_t descrA; +* hipsparseCreateMatDescr(&descrA); +* +* // Offload data to device +* int* dAptr = NULL; +* int* dAcol = NULL; +* double* dAval = NULL; +* double* dx = NULL; +* double* dy = NULL; +* +* hipMalloc((void**)&dAptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dAcol, sizeof(int) * nnz); +* hipMalloc((void**)&dAval, sizeof(double) * nnz); +* hipMalloc((void**)&dx, sizeof(double) * n); +* hipMalloc((void**)&dy, sizeof(double) * m); +* +* hipMemcpy(dAptr, hAptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dAcol, hAcol, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dAval, hAval, sizeof(double) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dx, hx, sizeof(double) * n, hipMemcpyHostToDevice); +* +* // Convert CSR matrix to HYB format +* hipsparseHybMat_t hybA; +* hipsparseCreateHybMat(&hybA); +* +* hipsparseDcsr2hyb(handle, m, n, descrA, dAval, dAptr, dAcol, hybA, 0, HIPSPARSE_HYB_PARTITION_AUTO); +* +* // Clean up CSR structures +* hipFree(dAptr); +* hipFree(dAcol); +* hipFree(dAval); +* +* // Call hipsparse hybmv +* hipsparseDhybmv(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, &halpha, descrA, hybA, dx, &hbeta, dy); +* +* // Copy result back to host +* hipMemcpy(hy, dy, sizeof(double) * m, hipMemcpyDeviceToHost); +* +* // Clear up on device +* hipsparseDestroyHybMat(hybA); +* hipsparseDestroyMatDescr(descrA); +* hipsparseDestroy(handle); +* +* hipFree(dx); +* hipFree(dy); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseShybmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + const float* alpha, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + const float* x, + const float* beta, + float* y); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDhybmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + const double* alpha, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + const double* x, + const double* beta, + double* y); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseChybmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + const hipComplex* x, + const hipComplex* beta, + hipComplex* y); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZhybmv(hipsparseHandle_t handle, + hipsparseOperation_t transA, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipsparseHybMat_t hybA, + const hipDoubleComplex* x, + const hipDoubleComplex* beta, + hipDoubleComplex* y); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level3/hipsparse_bsrmm.h b/library/include/level3/hipsparse_bsrmm.h new file mode 100644 index 00000000..60f6e0e3 --- /dev/null +++ b/library/include/level3/hipsparse_bsrmm.h @@ -0,0 +1,241 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup level3_module + * \brief Sparse matrix dense matrix multiplication using BSR storage format + * + * \details + * \p hipsparseXbsrmm multiplies the scalar \f$\alpha\f$ with a sparse \f$mb \times kb\f$ + * matrix \f$A\f$, defined in BSR storage format, and the dense \f$k \times n\f$ + * matrix \f$B\f$ (where \f$k = block\_dim \times kb\f$) and adds the result to the dense + * \f$m \times n\f$ matrix \f$C\f$ (where \f$m = block\_dim \times mb\f$) that + * is multiplied by the scalar \f$\beta\f$, such that + * \f[ + * C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C, + * \f] + * with + * \f[ + * op(A) = \left\{ + * \begin{array}{ll} + * A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ + * \end{array} + * \right. + * \f] + * and + * \f[ + * op(B) = \left\{ + * \begin{array}{ll} + * B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ + * B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ + * \end{array} + * \right. + * \f] + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. + * + * \note + * Currently, only \p trans_A == \ref HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. + * + * \par Example + * \code{.c} + * // hipSPARSE handle + * hipsparseHandle_t handle; + * hipsparseCreate(&handle); + * + * // 1 2 0 3 0 0 + * // A = 0 4 5 0 0 0 + * // 0 0 0 7 8 0 + * // 0 0 1 2 4 1 + * + * int block_dim = 2; + * int mb = 2; + * int kb = 3; + * int nnzb = 4; + * hipsparseDirection_t dir = HIPSPARSE_DIRECTION_ROW; + * + * int hbsr_row_ptr[2 + 1] = {0, 2, 4}; + * int hbsr_col_ind[4] = {0, 1, 1, 2}; + * float hbsr_val[4 * 2 * 2] = {1, 2, 0, 4, 0, 3, 5, 0, 0, 7, 1, 2, 8, 0, 4, 1}; + * + * // Set dimension n of B + * int n = 3; + * int m = mb * block_dim; + * int k = kb * block_dim; + * + * // Allocate and generate dense matrix B (k x n) + * float hB[6 * 3] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + * 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f}; + * + * int* dbsr_row_ptr = NULL; + * int* dbsr_col_ind = NULL; + * float* dbsr_val = NULL; + * hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); + * hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); + * hipMalloc((void**)&dbsr_val, sizeof(float) * nnzb * block_dim * block_dim); + * hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); + * hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); + * hipMemcpy(dbsr_val, hbsr_val, sizeof(float) * nnzb * block_dim * block_dim, hipMemcpyHostToDevice); + * + * // Copy B to the device + * float* dB; + * hipMalloc((void**)&dB, sizeof(float) * k * n); + * hipMemcpy(dB, hB, sizeof(float) * k * n, hipMemcpyHostToDevice); + * + * // alpha and beta + * float alpha = 1.0f; + * float beta = 0.0f; + * + * // Allocate memory for the resulting matrix C + * float* dC; + * hipMalloc((void**)&dC, sizeof(float) * m * n); + * + * // Matrix descriptor + * hipsparseMatDescr_t descr; + * hipsparseCreateMatDescr(&descr); + * + * // Perform the matrix multiplication + * hipsparseSbsrmm(handle, + * dir, + * HIPSPARSE_OPERATION_NON_TRANSPOSE, + * HIPSPARSE_OPERATION_NON_TRANSPOSE, + * mb, + * n, + * kb, + * nnzb, + * &alpha, + * descr, + * dbsr_val, + * dbsr_row_ptr, + * dbsr_col_ind, + * block_dim, + * dB, + * k, + * &beta, + * dC, + * m); + * + * // Copy results to host + * float hC[6 * 3]; + * hipMemcpy(hC, dC, sizeof(float) * m * n, hipMemcpyDeviceToHost); + * + * hipFree(dbsr_row_ptr); + * hipFree(dbsr_col_ind); + * hipFree(dbsr_val); + * hipFree(dB); + * hipFree(dC); + * \endcode + */ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrmm(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int mb, + int n, + int kb, + int nnzb, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const float* B, + int ldb, + const float* beta, + float* C, + int ldc); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrmm(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int mb, + int n, + int kb, + int nnzb, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const double* B, + int ldb, + const double* beta, + double* C, + int ldc); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrmm(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int mb, + int n, + int kb, + int nnzb, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const hipComplex* B, + int ldb, + const hipComplex* beta, + hipComplex* C, + int ldc); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrmm(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int mb, + int n, + int kb, + int nnzb, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + const hipDoubleComplex* B, + int ldb, + const hipDoubleComplex* beta, + hipDoubleComplex* C, + int ldc); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level3/hipsparse_bsrsm.h b/library/include/level3/hipsparse_bsrsm.h new file mode 100644 index 00000000..bb24af6b --- /dev/null +++ b/library/include/level3/hipsparse_bsrsm.h @@ -0,0 +1,556 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using BSR storage format +* +* \details +* \p hipsparseXbsrsm2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a +* structural or numerical zero has been found during hipsparseXbsrsm2_analysis() or +* hipsparseXbsrsm2_solve() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ +* is stored in \p position, using same index base as the BSR matrix. +* +* \p position can be in host or device memory. If no zero pivot has been found, +* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. +* +* \note \p hipsparseXbsrsm2_zeroPivot is a blocking function. It might influence +* performance negatively. +*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXbsrsm2_zeroPivot(hipsparseHandle_t handle, bsrsm2Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using BSR storage format +* +* \details +* \p hipsparseXbsrsm2_buffer_size returns the size of the temporary storage buffer in bytes +* that is required by hipsparseXbsrsm2_analysis() and hipsparseXbsrsm2_solve(). The +* temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsm2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + int* pBufferSizeInBytes); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsm2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + int* pBufferSizeInBytes); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsm2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + int* pBufferSizeInBytes); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsm2_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using BSR storage format +* +* \details +* \p hipsparseXbsrsm2_analysis performs the analysis step for hipsparseXbsrsm2_solve(). +* +* \note +* If the matrix sparsity pattern changes, the gathered information will become invalid. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsm2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + const float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsm2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + const double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsm2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsm2_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using BSR storage format +* +* \details +* \p hipsparseXbsrsm2_solve solves a sparse triangular linear system of a sparse +* \f$m \times m\f$ matrix, defined in BSR storage format, a dense solution matrix +* \f$X\f$ and the right-hand side matrix \f$B\f$ that is multiplied by \f$\alpha\f$, such that +* \f[ +* op(A) \cdot op(X) = \alpha \cdot op(B), +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* , +* \f[ +* op(X) = \left\{ +* \begin{array}{ll} +* X, & \text{if trans_X == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* X^T, & \text{if trans_X == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* X^H, & \text{if trans_X == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \p hipsparseXbsrsm2_solve requires a user allocated temporary buffer. Its size is +* returned by hipsparseXbsrsm2_bufferSize(). Furthermore, analysis meta data is +* required. It can be obtained by hipsparseXbsrsm2_analysis(). \p hipsparseXbsrsm2_solve +* reports the first zero pivot (either numerical or structural zero). The zero pivot +* status can be checked calling hipsparseXbsrsm2_zeroPivot(). If +* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be +* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. +* +* \note +* The sparse BSR matrix has to be sorted. +* +* \note +* Operation type of B and X must match, if \f$op(B)=B, op(X)=X\f$. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans_A != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and +* \p trans_X != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // A = ( 1.0 0.0 0.0 0.0 ) +* // ( 2.0 3.0 0.0 0.0 ) +* // ( 4.0 5.0 6.0 0.0 ) +* // ( 7.0 0.0 8.0 9.0 ) +* // +* // with bsr_dim = 2 +* // +* // ------------------- +* // = | 1.0 0.0 | 0.0 0.0 | +* // | 2.0 3.0 | 0.0 0.0 | +* // ------------------- +* // | 4.0 5.0 | 6.0 0.0 | +* // | 7.0 0.0 | 8.0 9.0 | +* // ------------------- +* +* // Number of rows and columns +* int m = 4; +* +* // Number of block rows and block columns +* int mb = 2; +* int nb = 2; +* +* // BSR block dimension +* int bsr_dim = 2; +* +* // Number of right-hand-sides +* int nrhs = 4; +* +* // Number of non-zero blocks +* int nnzb = 3; +* +* // BSR row pointers +* int hbsr_row_ptr[3] = {0, 1, 3}; +* +* // BSR column indices +* int hbsr_col_ind[3] = {0, 0, 1}; +* +* // BSR values +* double hbsr_val[12] = {1.0, 2.0, 0.0, 3.0, 4.0, 7.0, 5.0, 0.0, 6.0, 8.0, 0.0, 9.0}; +* +* // Storage scheme of the BSR blocks +* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_COLUMN; +* +* // Transposition of the matrix and rhs matrix +* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseOperation_t transX = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* +* // Solve policy +* hipsparseSolvePolicy_t solve_policy = HIPSPARSE_SOLVE_POLICY_NO_LEVEL; +* +* // Scalar alpha and beta +* double alpha = 1.0; +* +* // rhs and solution matrix +* int ldb = nb * bsr_dim; +* int ldx = mb * bsr_dim; +* +* double hB[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; +* double hX[16]; +* +* // Offload data to device +* int* dbsr_row_ptr; +* int* dbsr_col_ind; +* double* dbsr_val; +* double* dB; +* double* dX; +* +* hipMalloc((void**)&dbsr_row_ptr, sizeof(int) * (mb + 1)); +* hipMalloc((void**)&dbsr_col_ind, sizeof(int) * nnzb); +* hipMalloc((void**)&dbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim); +* hipMalloc((void**)&dB, sizeof(double) * nb * bsr_dim * nrhs); +* hipMalloc((void**)&dX, sizeof(double) * mb * bsr_dim * nrhs); +* +* hipMemcpy(dbsr_row_ptr, hbsr_row_ptr, sizeof(int) * (mb + 1), hipMemcpyHostToDevice); +* hipMemcpy(dbsr_col_ind, hbsr_col_ind, sizeof(int) * nnzb, hipMemcpyHostToDevice); +* hipMemcpy(dbsr_val, hbsr_val, sizeof(double) * nnzb * bsr_dim * bsr_dim, hipMemcpyHostToDevice); +* hipMemcpy(dB, hB, sizeof(double) * nb * bsr_dim * nrhs, hipMemcpyHostToDevice); +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Matrix fill mode +* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); +* +* // Matrix diagonal type +* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_NON_UNIT); +* +* // Matrix info structure +* bsrsm2Info_t info; +* hipsparseCreateBsrsm2Info(&info); +* +* // Obtain required buffer size +* int buffer_size; +* hipsparseDbsrsm2_bufferSize(handle, +* dir, +* transA, +* transX, +* mb, +* nrhs, +* nnzb, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* info, +* &buffer_size); +* +* // Allocate temporary buffer +* void* dbuffer; +* hipMalloc(&dbuffer, buffer_size); +* +* // Perform analysis step +* hipsparseDbsrsm2_analysis(handle, +* dir, +* transA, +* transX, +* mb, +* nrhs, +* nnzb, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* info, +* solve_policy, +* dbuffer); +* +* // Call dbsrsm to perform lower triangular solve LX = B +* hipsparseDbsrsm2_solve(handle, +* dir, +* transA, +* transX, +* mb, +* nrhs, +* nnzb, +* &alpha, +* descr, +* dbsr_val, +* dbsr_row_ptr, +* dbsr_col_ind, +* bsr_dim, +* info, +* dB, +* ldb, +* dX, +* ldx, +* solve_policy, +* dbuffer); +* +* // Check for zero pivots +* int pivot; +* hipsparseStatus_t status = hipsparseXbsrsm2_zeroPivot(handle, info, &pivot); +* +* if(status == HIPSPARSE_STATUS_ZERO_PIVOT) +* { +* std::cout << "Found zero pivot in matrix row " << pivot << std::endl; +* } +* +* // Copy result back to host +* hipMemcpy(hX, dX, sizeof(double) * mb * bsr_dim * nrhs, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroyBsrsm2Info(info); +* hipsparseDestroyMatDescr(descr); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dbsr_row_ptr); +* hipFree(dbsr_col_ind); +* hipFree(dbsr_val); +* hipFree(dB); +* hipFree(dX); +* hipFree(dbuffer); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrsm2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + const float* B, + int ldb, + float* X, + int ldx, + hipsparseSolvePolicy_t policy, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrsm2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + const double* B, + int ldb, + double* X, + int ldx, + hipsparseSolvePolicy_t policy, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrsm2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + const hipComplex* B, + int ldb, + hipComplex* X, + int ldx, + hipsparseSolvePolicy_t policy, + void* pBuffer); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrsm2_solve(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + hipsparseOperation_t transA, + hipsparseOperation_t transX, + int mb, + int nrhs, + int nnzb, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrsm2Info_t info, + const hipDoubleComplex* B, + int ldb, + hipDoubleComplex* X, + int ldx, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level3/hipsparse_csrmm.h b/library/include/level3/hipsparse_csrmm.h new file mode 100644 index 00000000..29ae7040 --- /dev/null +++ b/library/include/level3/hipsparse_csrmm.h @@ -0,0 +1,366 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup level3_module +* \brief Sparse matrix dense matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrmm multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times k\f$ +* matrix \f$A\f$, defined in CSR storage format, and the dense \f$k \times n\f$ +* matrix \f$B\f$ and adds the result to the dense \f$m \times n\f$ matrix \f$C\f$ that +* is multiplied by the scalar \f$\beta\f$, such that +* \f[ +* C := \alpha \cdot op(A) \cdot B + \beta \cdot C, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \code{.c} +* for(i = 0; i < ldc; ++i) +* { +* for(j = 0; j < n; ++j) +* { +* C[i][j] = beta * C[i][j]; +* +* for(k = csr_row_ptr[i]; k < csr_row_ptr[i + 1]; ++k) +* { +* C[i][j] += alpha * csr_val[k] * B[csr_col_ind[k]][j]; +* } +* } +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // 1 2 0 3 0 0 +* // A = 0 4 5 0 0 0 +* // 0 0 0 7 8 0 +* // 0 0 1 2 4 1 +* +* int m = 4; +* int k = 6; +* int nnz = 11; +* hipsparseDirection_t dir = HIPSPARSE_DIRECTION_ROW; +* +* int hcsr_row_ptr[4 + 1] = {0, 3, 5, 7, 11}; +* int hcsr_col_ind[11] = {0, 1, 3, 1, 2, 3, 4, 2, 3, 4, 5}; +* float hcsr_val[11] = {1, 2, 3, 4, 5, 7, 8, 1, 2, 4, 1}; +* +* // Set dimension n of B +* int n = 3; +* +* // Allocate and generate dense matrix B (k x n) +* float hB[6 * 3] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, +* 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f}; +* +* int* dcsr_row_ptr = NULL; +* int* dcsr_col_ind = NULL; +* float* dcsr_val = NULL; +* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dcsr_val, sizeof(float) * nnz); +* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_val, hcsr_val, sizeof(float) * nnz, hipMemcpyHostToDevice); +* +* // Copy B to the device +* float* dB; +* hipMalloc((void**)&dB, sizeof(float) * k * n); +* hipMemcpy(dB, hB, sizeof(float) * k * n, hipMemcpyHostToDevice); +* +* // alpha and beta +* float alpha = 1.0f; +* float beta = 0.0f; +* +* // Allocate memory for the resulting matrix C +* float* dC; +* hipMalloc((void**)&dC, sizeof(float) * m * n); +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Perform the matrix multiplication +* hipsparseScsrmm(handle, +* HIPSPARSE_OPERATION_NON_TRANSPOSE, +* m, +* n, +* k, +* nnz, +* &alpha, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* dB, +* k, +* &beta, +* dC, +* m); +* +* // Copy results to host +* float hC[6 * 3]; +* hipMemcpy(hC, dC, sizeof(float) * m * n, hipMemcpyDeviceToHost); +* +* hipFree(dcsr_row_ptr); +* hipFree(dcsr_col_ind); +* hipFree(dcsr_val); +* hipFree(dB); +* hipFree(dC); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrmm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int k, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* B, + int ldb, + const float* beta, + float* C, + int ldc); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrmm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int k, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* B, + int ldb, + const double* beta, + double* C, + int ldc); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrmm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int k, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* B, + int ldb, + const hipComplex* beta, + hipComplex* C, + int ldc); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrmm(hipsparseHandle_t handle, + hipsparseOperation_t transA, + int m, + int n, + int k, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* B, + int ldb, + const hipDoubleComplex* beta, + hipDoubleComplex* C, + int ldc); +/**@}*/ +#endif + + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) +/*! \ingroup level3_module +* \brief Sparse matrix dense matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXcsrmm2 multiplies the scalar \f$\alpha\f$ with a sparse \f$m \times k\f$ +* matrix \f$A\f$, defined in CSR storage format, and the dense \f$k \times n\f$ +* matrix \f$B\f$ and adds the result to the dense \f$m \times n\f$ matrix \f$C\f$ that +* is multiplied by the scalar \f$\beta\f$, such that +* \f[ +* C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C, +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* and +* \f[ +* op(B) = \left\{ +* \begin{array}{ll} +* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \code{.c} +* for(i = 0; i < ldc; ++i) +* { +* for(j = 0; j < n; ++j) +* { +* C[i][j] = beta * C[i][j]; +* +* for(k = csr_row_ptr[i]; k < csr_row_ptr[i + 1]; ++k) +* { +* C[i][j] += alpha * csr_val[k] * B[csr_col_ind[k]][j]; +* } +* } +* } +* \endcode +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrmm2(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* B, + int ldb, + const float* beta, + float* C, + int ldc); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrmm2(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* B, + int ldb, + const double* beta, + double* C, + int ldc); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrmm2(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* B, + int ldb, + const hipComplex* beta, + hipComplex* C, + int ldc); +DEPRECATED_CUDA_10000("The routine will be removed in CUDA 11") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrmm2(hipsparseHandle_t handle, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int n, + int k, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* B, + int ldb, + const hipDoubleComplex* beta, + hipDoubleComplex* C, + int ldc); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level3/hipsparse_csrsm.h b/library/include/level3/hipsparse_csrsm.h new file mode 100644 index 00000000..87d00cc4 --- /dev/null +++ b/library/include/level3/hipsparse_csrsm.h @@ -0,0 +1,541 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using CSR storage format +* +* \details +* \p hipsparseXcsrsm2_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a +* structural or numerical zero has been found during hipsparseXcsrsm2_analysis() or +* hipsparseXcsrsm2_solve() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ +* is stored in \p position, using same index base as the CSR matrix. +* +* \p position can be in host or device memory. If no zero pivot has been found, +* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. +* +* \note \p hipsparseXcsrsm2_zeroPivot is a blocking function. It might influence +* performance negatively. +*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXcsrsm2_zeroPivot(hipsparseHandle_t handle, csrsm2Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using CSR storage format +* +* \details +* \p hipsparseXcsrsm2_bufferSizeExt returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXcsrsm2_analysis() and hipsparseXcsrsm2_solve(). +* The temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsm2_bufferSizeExt(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + size_t* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsm2_bufferSizeExt(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + size_t* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsm2_bufferSizeExt(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + size_t* pBufferSizeInBytes); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsm2_bufferSizeExt(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + size_t* pBufferSizeInBytes); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using CSR storage format +* +* \details +* \p hipsparseXcsrsm2_analysis performs the analysis step for hipsparseXcsrsm2_solve(). +* +* \note +* If the matrix sparsity pattern changes, the gathered information will become invalid. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsm2_analysis(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const float* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsm2_analysis(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const double* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsm2_analysis(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipComplex* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsm2_analysis(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + const hipDoubleComplex* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level3_module +* \brief Sparse triangular system solve using CSR storage format +* +* \details +* \p hipsparseXcsrsm2_solve solves a sparse triangular linear system of a sparse +* \f$m \times m\f$ matrix, defined in CSR storage format, a dense solution matrix +* \f$X\f$ and the right-hand side matrix \f$B\f$ that is multiplied by \f$\alpha\f$, such that +* \f[ +* op(A) \cdot op(X) = \alpha \cdot op(B), +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* , +* \f[ +* op(B) = \left\{ +* \begin{array}{ll} +* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* and +* \f[ +* op(X) = \left\{ +* \begin{array}{ll} +* X, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* X^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* X^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \p hipsparseXcsrsm2_solve requires a user allocated temporary buffer. Its size is +* returned by hipsparseXcsrsm2_bufferSizeExt(). Furthermore, analysis meta data is +* required. It can be obtained by hipsparseXcsrsm2_analysis(). +* \p hipsparseXcsrsm2_solve reports the first zero pivot (either numerical or structural +* zero). The zero pivot status can be checked calling hipsparseXcsrsm2_zeroPivot(). If +* \ref hipsparseDiagType_t == \ref HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be +* reported, even if \f$A_{j,j} = 0\f$ for some \f$j\f$. +* +* \note +* The sparse CSR matrix has to be sorted. This can be achieved by calling +* hipsparseXcsrsort(). +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +* +* \note +* Currently, only \p trans_A != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and +* \p trans_B != \ref HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported. +* +* \par Example +* \code{.c} +* // hipSPARSE handle +* hipsparseHandle_t handle; +* hipsparseCreate(&handle); +* +* // A = ( 1.0 0.0 0.0 0.0 ) +* // ( 2.0 3.0 0.0 0.0 ) +* // ( 4.0 5.0 6.0 0.0 ) +* // ( 7.0 0.0 8.0 9.0 ) +* +* // Number of rows and columns +* int m = 4; +* int n = 4; +* +* // Number of right-hand-sides +* int nrhs = 4; +* +* // Number of non-zeros +* int nnz = 9; +* +* // CSR row pointers +* int hcsr_row_ptr[5] = {0, 1, 3, 6, 9}; +* +* // CSR column indices +* int hcsr_col_ind[9] = {0, 0, 1, 0, 1, 2, 0, 2, 3}; +* +* // CSR values +* double hcsr_val[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; +* +* // Transposition of the matrix and rhs matrix +* hipsparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* hipsparseOperation_t transB = HIPSPARSE_OPERATION_NON_TRANSPOSE; +* +* // Solve policy +* hipsparseSolvePolicy_t solve_policy = HIPSPARSE_SOLVE_POLICY_NO_LEVEL; +* +* // Scalar alpha and beta +* double alpha = 1.0; +* +* // rhs and solution matrix +* int ldb = n; +* +* double hB[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; +* +* // Offload data to device +* int* dcsr_row_ptr; +* int* dcsr_col_ind; +* double* dcsr_val; +* double* dB; +* +* hipMalloc((void**)&dcsr_row_ptr, sizeof(int) * (m + 1)); +* hipMalloc((void**)&dcsr_col_ind, sizeof(int) * nnz); +* hipMalloc((void**)&dcsr_val, sizeof(double) * nnz); +* hipMalloc((void**)&dB, sizeof(double) * n * nrhs); +* +* hipMemcpy(dcsr_row_ptr, hcsr_row_ptr, sizeof(int) * (m + 1), hipMemcpyHostToDevice); +* hipMemcpy(dcsr_col_ind, hcsr_col_ind, sizeof(int) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dcsr_val, hcsr_val, sizeof(double) * nnz, hipMemcpyHostToDevice); +* hipMemcpy(dB, hB, sizeof(double) * n * nrhs, hipMemcpyHostToDevice); +* +* // Matrix descriptor +* hipsparseMatDescr_t descr; +* hipsparseCreateMatDescr(&descr); +* +* // Matrix fill mode +* hipsparseSetMatFillMode(descr, HIPSPARSE_FILL_MODE_LOWER); +* +* // Matrix diagonal type +* hipsparseSetMatDiagType(descr, HIPSPARSE_DIAG_TYPE_NON_UNIT); +* +* // Matrix info structure +* csrsm2Info_t info; +* hipsparseCreateCsrsm2Info(&info); +* +* // Obtain required buffer size +* size_t buffer_size; +* hipsparseDcsrsm2_bufferSizeExt(handle, +* 0, +* transA, +* transB, +* m, +* nrhs, +* nnz, +* &alpha, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* dB, +* ldb, +* info, +* solve_policy, +* &buffer_size); +* +* // Allocate temporary buffer +* void* dbuffer; +* hipMalloc(&dbuffer, buffer_size); +* +* // Perform analysis step +* hipsparseDcsrsm2_analysis(handle, +* 0, +* transA, +* transB, +* m, +* nrhs, +* nnz, +* &alpha, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* dB, +* ldb, +* info, +* solve_policy, +* dbuffer); +* +* // Call dcsrsm to perform lower triangular solve LB = B +* hipsparseDcsrsm2_solve(handle, +* 0, +* transA, +* transB, +* m, +* nrhs, +* nnz, +* &alpha, +* descr, +* dcsr_val, +* dcsr_row_ptr, +* dcsr_col_ind, +* dB, +* ldb, +* info, +* solve_policy, +* dbuffer); +* +* // Check for zero pivots +* int pivot; +* hipsparseStatus_t status = hipsparseXcsrsm2_zeroPivot(handle, info, &pivot); +* +* if(status == HIPSPARSE_STATUS_ZERO_PIVOT) +* { +* std::cout << "Found zero pivot in matrix row " << pivot << std::endl; +* } +* +* // Copy result back to host +* hipMemcpy(hB, dB, sizeof(double) * m * nrhs, hipMemcpyDeviceToHost); +* +* // Clear hipSPARSE +* hipsparseDestroyCsrsm2Info(info); +* hipsparseDestroyMatDescr(descr); +* hipsparseDestroy(handle); +* +* // Clear device memory +* hipFree(dcsr_row_ptr); +* hipFree(dcsr_col_ind); +* hipFree(dcsr_val); +* hipFree(dB); +* hipFree(dbuffer); +* \endcode +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrsm2_solve(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const float* alpha, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + float* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrsm2_solve(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const double* alpha, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + double* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrsm2_solve(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const hipComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + hipComplex* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrsm2_solve(hipsparseHandle_t handle, + int algo, + hipsparseOperation_t transA, + hipsparseOperation_t transB, + int m, + int nrhs, + int nnz, + const hipDoubleComplex* alpha, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + hipDoubleComplex* B, + int ldb, + csrsm2Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/level3/hipsparse_gemmi.h b/library/include/level3/hipsparse_gemmi.h new file mode 100644 index 00000000..09aea259 --- /dev/null +++ b/library/include/level3/hipsparse_gemmi.h @@ -0,0 +1,137 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) +/*! \ingroup level3_module +* \brief Dense matrix sparse matrix multiplication using CSR storage format +* +* \details +* \p hipsparseXgemmi multiplies the scalar \f$\alpha\f$ with a dense \f$m \times k\f$ +* matrix \f$A\f$ and the sparse \f$k \times n\f$ matrix \f$B\f$, defined in CSR +* storage format and adds the result to the dense \f$m \times n\f$ matrix \f$C\f$ that +* is multiplied by the scalar \f$\beta\f$, such that +* \f[ +* C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C +* \f] +* with +* \f[ +* op(A) = \left\{ +* \begin{array}{ll} +* A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* and +* \f[ +* op(B) = \left\{ +* \begin{array}{ll} +* B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ +* B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ +* B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} +* \end{array} +* \right. +* \f] +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgemmi(hipsparseHandle_t handle, + int m, + int n, + int k, + int nnz, + const float* alpha, + const float* A, + int lda, + const float* cscValB, + const int* cscColPtrB, + const int* cscRowIndB, + const float* beta, + float* C, + int ldc); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgemmi(hipsparseHandle_t handle, + int m, + int n, + int k, + int nnz, + const double* alpha, + const double* A, + int lda, + const double* cscValB, + const int* cscColPtrB, + const int* cscRowIndB, + const double* beta, + double* C, + int ldc); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgemmi(hipsparseHandle_t handle, + int m, + int n, + int k, + int nnz, + const hipComplex* alpha, + const hipComplex* A, + int lda, + const hipComplex* cscValB, + const int* cscColPtrB, + const int* cscRowIndB, + const hipComplex* beta, + hipComplex* C, + int ldc); +DEPRECATED_CUDA_11000("The routine will be removed in CUDA 12") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgemmi(hipsparseHandle_t handle, + int m, + int n, + int k, + int nnz, + const hipDoubleComplex* alpha, + const hipDoubleComplex* A, + int lda, + const hipDoubleComplex* cscValB, + const int* cscColPtrB, + const int* cscRowIndB, + const hipDoubleComplex* beta, + hipDoubleComplex* C, + int ldc); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_bsric0.h b/library/include/precond/hipsparse_bsric0.h new file mode 100644 index 00000000..59d9e788 --- /dev/null +++ b/library/include/precond/hipsparse_bsric0.h @@ -0,0 +1,283 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR + * storage format + * + * \details + * \p hipsparseXbsric02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a + * structural or numerical zero has been found during hipsparseXbsric02_analysis() or + * hipsparseXbsric02() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is + * stored in \p position, using same index base as the BSR matrix. + * + * \p position can be in host or device memory. If no zero pivot has been found, + * \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. + * + * \note + * If a zero pivot is found, \p position=j means that either the diagonal block \p A(j,j) + * is missing (structural zero) or the diagonal block \p A(j,j) is not positive definite + * (numerical zero). + * + * \note \p hipsparseXbsric02_zeroPivot is a blocking function. It might influence + * performance negatively. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXbsric02_zeroPivot(hipsparseHandle_t handle, bsric02Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR + * storage format + * + * \details + * \p hipsparseXbsric02_bufferSize returns the size of the temporary storage buffer + * in bytes that is required by hipsparseXbsric02_analysis() and hipsparseXbsric02(). + * The temporary storage buffer must be allocated by the user. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsric02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsric02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsric02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsric02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR + * storage format + * + * \details + * \p hipsparseXbsric02_analysis performs the analysis step for hipsparseXbsric02(). + * + * \note + * If the matrix sparsity pattern changes, the gathered information will become invalid. + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsric02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsric02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsric02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsric02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using BSR + * storage format + * + * \details + * \p hipsparseXbsric02 computes the incomplete Cholesky factorization with 0 fill-ins + * and no pivoting of a sparse \f$mb \times mb\f$ BSR matrix \f$A\f$, such that + * \f[ + * A \approx LL^T + * \f] + * + * \p hipsparseXbsric02 requires a user allocated temporary buffer. Its size is returned + * by hipsparseXbsric02_bufferSize(). Furthermore, analysis meta data is required. It + * can be obtained by hipsparseXbsric02_analysis(). \p hipsparseXbsric02 reports the + * first zero pivot (either numerical or structural zero). The zero pivot status can be + * obtained by calling hipsparseXbsric02_zeroPivot(). + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsric02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsric02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsric02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsric02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrValA, + const int* bsrRowPtrA, + const int* bsrColIndA, + int blockDim, + bsric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_bsrilu0.h b/library/include/precond/hipsparse_bsrilu0.h new file mode 100644 index 00000000..be641664 --- /dev/null +++ b/library/include/precond/hipsparse_bsrilu0.h @@ -0,0 +1,339 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage + * format + * + * \details + * \p hipsparseXbsrilu02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a + * structural or numerical zero has been found during hipsparseXbsrilu02_analysis() or + * hipsparseXbsrilu02() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is + * stored in \p position, using same index base as the BSR matrix. + * + * \p position can be in host or device memory. If no zero pivot has been found, + * \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. + * + * \note + * If a zero pivot is found, \p position \f$=j\f$ means that either the diagonal block + * \f$A_{j,j}\f$ is missing (structural zero) or the diagonal block \f$A_{j,j}\f$ is not + * invertible (numerical zero). + * + * \note \p hipsparseXbsrilu02_zeroPivot is a blocking function. It might influence + * performance negatively. + */ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXbsrilu02_zeroPivot(hipsparseHandle_t handle, bsrilu02Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage + * format + * + * \details + * \p hipsparseXbsrilu02_numericBoost enables the user to replace a numerical value in + * an incomplete LU factorization. \p tol is used to determine whether a numerical value + * is replaced by \p boost_val, such that \f$A_{j,j} = \text{boost_val}\f$ if + * \f$\text{tol} \ge \left|A_{j,j}\right|\f$. + * + * \note The boost value is enabled by setting \p enable_boost to 1 or disabled by + * setting \p enable_boost to 0. + * + * \note \p tol and \p boost_val can be in host or device memory. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrilu02_numericBoost( + hipsparseHandle_t handle, bsrilu02Info_t info, int enable_boost, double* tol, float* boost_val); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrilu02_numericBoost(hipsparseHandle_t handle, + bsrilu02Info_t info, + int enable_boost, + double* tol, + double* boost_val); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrilu02_numericBoost(hipsparseHandle_t handle, + bsrilu02Info_t info, + int enable_boost, + double* tol, + hipComplex* boost_val); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrilu02_numericBoost(hipsparseHandle_t handle, + bsrilu02Info_t info, + int enable_boost, + double* tol, + hipDoubleComplex* boost_val); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage + * format + * + * \details + * \p hipsparseXbsrilu02_bufferSize returns the size of the temporary storage buffer + * in bytes that is required by hipsparseXbsrilu02_analysis() and hipsparseXbsrilu02(). + * The temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrilu02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrilu02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrilu02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrilu02_bufferSize(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage + * format + * + * \details + * \p hipsparseXbsrilu02_analysis performs the analysis step for hipsparseXbsrilu02(). + * + * \note + * If the matrix sparsity pattern changes, the gathered information will become invalid. + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrilu02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrilu02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrilu02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrilu02_analysis(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrSortedValA, + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using BSR storage + * format + * + * \details + * \p hipsparseXbsrilu02 computes the incomplete LU factorization with 0 fill-ins and no + * pivoting of a sparse \f$mb \times mb\f$ BSR matrix \f$A\f$, such that + * \f[ + * A \approx LU + * \f] + * + * \p hipsparseXbsrilu02 requires a user allocated temporary buffer. Its size is + * returned by hipsparseXbsrilu02_bufferSize(). Furthermore, analysis meta data is + * required. It can be obtained by hipsparseXbsrilu02_analysis(). \p hipsparseXbsrilu02 + * reports the first zero pivot (either numerical or structural zero). The zero pivot + * status can be obtained by calling hipsparseXbsrilu02_zeroPivot(). + * + * \note + * This function is non blocking and executed asynchronously with respect to the host. + * It may return before the actual computation has finished. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSbsrilu02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + float* bsrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDbsrilu02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + double* bsrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCbsrilu02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipComplex* bsrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZbsrilu02(hipsparseHandle_t handle, + hipsparseDirection_t dirA, + int mb, + int nnzb, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* bsrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* bsrSortedRowPtrA, + const int* bsrSortedColIndA, + int blockDim, + bsrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_csric0.h b/library/include/precond/hipsparse_csric0.h new file mode 100644 index 00000000..b7f974c3 --- /dev/null +++ b/library/include/precond/hipsparse_csric0.h @@ -0,0 +1,316 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsric02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a +* structural or numerical zero has been found during hipsparseXcsric02_analysis() or +* hipsparseXcsric02() computation. The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ +* is stored in \p position, using same index base as the CSR matrix. +* +* \p position can be in host or device memory. If no zero pivot has been found, +* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. +* +* \note \p hipsparseXcsric02_zeroPivot is a blocking function. It might influence +* performance negatively. +*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXcsric02_zeroPivot(hipsparseHandle_t handle, csric02Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsric02_bufferSize returns the size of the temporary storage buffer in bytes +* that is required by hipsparseXcsric02_analysis() and hipsparseXcsric02(). +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsric02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsric02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsric02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsric02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +/*! \ingroup precond_module +* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsric02_bufferSizeExt returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXcsric02_analysis() and hipsparseXcsric02(). +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsric02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsric02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsric02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsric02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + size_t* pBufferSizeInBytes); +/**@}*/ + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsric02_analysis performs the analysis step for hipsparseXcsric02(). +* +* \note +* If the matrix sparsity pattern changes, the gathered information will become invalid. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsric02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsric02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsric02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsric02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete Cholesky factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsric02 computes the incomplete Cholesky factorization with 0 fill-ins +* and no pivoting of a sparse \f$m \times m\f$ CSR matrix \f$A\f$, such that +* \f[ +* A \approx LL^T +* \f] +* +* \p hipsparseXcsric02 requires a user allocated temporary buffer. Its size is returned +* by hipsparseXcsric02_bufferSize() or hipsparseXcsric02_bufferSizeExt(). Furthermore, +* analysis meta data is required. It can be obtained by hipsparseXcsric02_analysis(). +* \p hipsparseXcsric02 reports the first zero pivot (either numerical or structural +* zero). The zero pivot status can be obtained by calling hipsparseXcsric02_zeroPivot(). +* +* \note +* The sparse CSR matrix has to be sorted. This can be achieved by calling +* hipsparseXcsrsort(). +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsric02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsric02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsric02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsric02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csric02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_csrilu0.h b/library/include/precond/hipsparse_csrilu0.h new file mode 100644 index 00000000..09e8e106 --- /dev/null +++ b/library/include/precond/hipsparse_csrilu0.h @@ -0,0 +1,366 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsrilu02_zeroPivot returns \ref HIPSPARSE_STATUS_ZERO_PIVOT, if either a +* structural or numerical zero has been found during hipsparseXcsrilu02() computation. +* The first zero pivot \f$j\f$ at \f$A_{j,j}\f$ is stored in \p position, using same +* index base as the CSR matrix. +* +* \p position can be in host or device memory. If no zero pivot has been found, +* \p position is set to -1 and \ref HIPSPARSE_STATUS_SUCCESS is returned instead. +* +* \note \p hipsparseXcsrilu02_zeroPivot is a blocking function. It might influence +* performance negatively. +*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t + hipsparseXcsrilu02_zeroPivot(hipsparseHandle_t handle, csrilu02Info_t info, int* position); +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module + * \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR storage + * format + * + * \details + * \p hipsparseXcsrilu02_numericBoost enables the user to replace a numerical value in + * an incomplete LU factorization. \p tol is used to determine whether a numerical value + * is replaced by \p boost_val, such that \f$A_{j,j} = \text{boost_val}\f$ if + * \f$\text{tol} \ge \left|A_{j,j}\right|\f$. + * + * \note The boost value is enabled by setting \p enable_boost to 1 or disabled by + * setting \p enable_boost to 0. + * + * \note \p tol and \p boost_val can be in host or device memory. + */ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrilu02_numericBoost( + hipsparseHandle_t handle, csrilu02Info_t info, int enable_boost, double* tol, float* boost_val); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrilu02_numericBoost(hipsparseHandle_t handle, + csrilu02Info_t info, + int enable_boost, + double* tol, + double* boost_val); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrilu02_numericBoost(hipsparseHandle_t handle, + csrilu02Info_t info, + int enable_boost, + double* tol, + hipComplex* boost_val); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrilu02_numericBoost(hipsparseHandle_t handle, + csrilu02Info_t info, + int enable_boost, + double* tol, + hipDoubleComplex* boost_val); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsrilu02_bufferSize returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXcsrilu02_analysis() and hipsparseXcsrilu02_solve(). +* The temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrilu02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrilu02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrilu02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + int* pBufferSizeInBytes); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrilu02_bufferSize(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + int* pBufferSizeInBytes); +/**@}*/ +#endif + +/*! \ingroup precond_module +* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsrilu02_bufferSizeExt returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXcsrilu02_analysis() and hipsparseXcsrilu02_solve(). +* The temporary storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrilu02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrilu02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrilu02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + size_t* pBufferSizeInBytes); +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrilu02_bufferSizeExt(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + size_t* pBufferSizeInBytes); +/**@}*/ + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsrilu02_analysis performs the analysis step for hipsparseXcsrilu02(). +* +* \note +* If the matrix sparsity pattern changes, the gathered information will become invalid. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrilu02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const float* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrilu02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const double* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrilu02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrilu02_analysis(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrSortedValA, + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup precond_module +* \brief Incomplete LU factorization with 0 fill-ins and no pivoting using CSR +* storage format +* +* \details +* \p hipsparseXcsrilu02 computes the incomplete LU factorization with 0 fill-ins and no +* pivoting of a sparse \f$m \times m\f$ CSR matrix \f$A\f$, such that +* \f[ +* A \approx LU +* \f] +* +* \p hipsparseXcsrilu02 requires a user allocated temporary buffer. Its size is returned +* by hipsparseXcsrilu02_bufferSize() or hipsparseXcsrilu02_bufferSizeExt(). Furthermore, +* analysis meta data is required. It can be obtained by hipsparseXcsrilu02_analysis(). +* \p hipsparseXcsrilu02 reports the first zero pivot (either numerical or structural +* zero). The zero pivot status can be obtained by calling hipsparseXcsrilu02_zeroPivot(). +* +* \note +* The sparse CSR matrix has to be sorted. This can be achieved by calling +* hipsparseXcsrsort(). +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrilu02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + float* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrilu02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + double* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrilu02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipComplex* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrilu02(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + hipDoubleComplex* csrSortedValA_valM, + /* matrix A values are updated inplace + to be the preconditioner M values */ + const int* csrSortedRowPtrA, + const int* csrSortedColIndA, + csrilu02Info_t info, + hipsparseSolvePolicy_t policy, + void* pBuffer); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_gpsv_interleaved_batch.h b/library/include/precond/hipsparse_gpsv_interleaved_batch.h new file mode 100644 index 00000000..6b46b033 --- /dev/null +++ b/library/include/precond/hipsparse_gpsv_interleaved_batch.h @@ -0,0 +1,160 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup precond_module +* \brief Interleaved Batch pentadiagonal solver +* +* \details +* \p hipsparseXgpsvInterleavedBatch_bufferSizeExt returns the size of the temporary storage +* buffer in bytes that is required by hipsparseXgpsvInterleavedBatch(). The temporary +* storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const float* ds, + const float* dl, + const float* d, + const float* du, + const float* dw, + const float* x, + int batchCount, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const double* ds, + const double* dl, + const double* d, + const double* du, + const double* dw, + const double* x, + int batchCount, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const hipComplex* ds, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + const hipComplex* dw, + const hipComplex* x, + int batchCount, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgpsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const hipDoubleComplex* ds, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + const hipDoubleComplex* dw, + const hipDoubleComplex* x, + int batchCount, + size_t* pBufferSizeInBytes); + +/**@}*/ + +/*! \ingroup precond_module +* \brief Interleaved Batch pentadiagonal solver +* +* \details +* \p hipsparseXgpsvInterleavedBatch solves a batched pentadiagonal linear system +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgpsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + float* ds, + float* dl, + float* d, + float* du, + float* dw, + float* x, + int batchCount, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgpsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + double* ds, + double* dl, + double* d, + double* du, + double* dw, + double* x, + int batchCount, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgpsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + hipComplex* ds, + hipComplex* dl, + hipComplex* d, + hipComplex* du, + hipComplex* dw, + hipComplex* x, + int batchCount, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgpsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + hipDoubleComplex* ds, + hipDoubleComplex* dl, + hipDoubleComplex* d, + hipDoubleComplex* du, + hipDoubleComplex* dw, + hipDoubleComplex* x, + int batchCount, + void* pBuffer); + +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv.h b/library/include/precond/hipsparse_gtsv.h new file mode 100644 index 00000000..c4ded098 --- /dev/null +++ b/library/include/precond/hipsparse_gtsv.h @@ -0,0 +1,142 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup precond_module +* \brief Tridiagonal solver with pivoting +* +* \details +* \p hipsparseXgtsv2_bufferSize returns the size of the temporary storage buffer +* in bytes that is required by hipsparseXgtsv2(). The temporary storage buffer must +* be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsv2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const float* dl, + const float* d, + const float* du, + const float* B, + int ldb, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsv2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const double* dl, + const double* d, + const double* du, + const double* B, + int db, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsv2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + const hipComplex* B, + int ldb, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsv2_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + const hipDoubleComplex* B, + int ldb, + size_t* pBufferSizeInBytes); +/**@}*/ + +/*! \ingroup precond_module +* \brief Tridiagonal solver with pivoting +* +* \details +* \p hipsparseXgtsv2 solves a tridiagonal system for multiple right hand sides using pivoting. +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsv2(hipsparseHandle_t handle, + int m, + int n, + const float* dl, + const float* d, + const float* du, + float* B, + int ldb, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsv2(hipsparseHandle_t handle, + int m, + int n, + const double* dl, + const double* d, + const double* du, + double* B, + int ldb, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsv2(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + hipComplex* B, + int ldb, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsv2(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + hipDoubleComplex* B, + int ldb, + void* pBuffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv_interleaved_batch.h b/library/include/precond/hipsparse_gtsv_interleaved_batch.h new file mode 100644 index 00000000..03419d85 --- /dev/null +++ b/library/include/precond/hipsparse_gtsv_interleaved_batch.h @@ -0,0 +1,142 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup precond_module +* \brief Interleaved Batch tridiagonal solver +* +* \details +* \p hipsparseXgtsvInterleavedBatch_bufferSizeExt returns the size of the temporary storage +* buffer in bytes that is required by hipsparseXgtsvInterleavedBatch(). The temporary storage +* buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const float* dl, + const float* d, + const float* du, + const float* x, + int batchCount, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const double* dl, + const double* d, + const double* du, + const double* x, + int batchCount, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + const hipComplex* x, + int batchCount, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsvInterleavedBatch_bufferSizeExt(hipsparseHandle_t handle, + int algo, + int m, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + const hipDoubleComplex* x, + int batchCount, + size_t* pBufferSizeInBytes); +/**@}*/ + +/*! \ingroup precond_module +* \brief Interleaved Batch tridiagonal solver +* +* \details +* \p hipsparseXgtsvInterleavedBatch solves a batched tridiagonal linear system +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + float* dl, + float* d, + float* du, + float* x, + int batchCount, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + double* dl, + double* d, + double* du, + double* x, + int batchCount, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + hipComplex* dl, + hipComplex* d, + hipComplex* du, + hipComplex* x, + int batchCount, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsvInterleavedBatch(hipsparseHandle_t handle, + int algo, + int m, + hipDoubleComplex* dl, + hipDoubleComplex* d, + hipDoubleComplex* du, + hipDoubleComplex* x, + int batchCount, + void* pBuffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv_nopivot.h b/library/include/precond/hipsparse_gtsv_nopivot.h new file mode 100644 index 00000000..5bfa3aa5 --- /dev/null +++ b/library/include/precond/hipsparse_gtsv_nopivot.h @@ -0,0 +1,142 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup precond_module +* \brief Tridiagonal solver (no pivoting) +* +* \details +* \p hipsparseXgtsv2_nopivot_bufferSizeExt returns the size of the temporary storage +* buffer in bytes that is required by hipsparseXgtsv2_nopivot(). The temporary storage +* buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const float* dl, + const float* d, + const float* du, + const float* B, + int ldb, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const double* dl, + const double* d, + const double* du, + const double* B, + int db, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + const hipComplex* B, + int ldb, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsv2_nopivot_bufferSizeExt(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + const hipDoubleComplex* B, + int ldb, + size_t* pBufferSizeInBytes); +/**@}*/ + +/*! \ingroup precond_module +* \brief Tridiagonal solver (no pivoting) +* +* \details +* \p hipsparseXgtsv2_nopivot solves a tridiagonal linear system for multiple right-hand sides +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsv2_nopivot(hipsparseHandle_t handle, + int m, + int n, + const float* dl, + const float* d, + const float* du, + float* B, + int ldb, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsv2_nopivot(hipsparseHandle_t handle, + int m, + int n, + const double* dl, + const double* d, + const double* du, + double* B, + int ldb, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsv2_nopivot(hipsparseHandle_t handle, + int m, + int n, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + hipComplex* B, + int ldb, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsv2_nopivot(hipsparseHandle_t handle, + int m, + int n, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + hipDoubleComplex* B, + int ldb, + void* pBuffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv_strided_batch.h b/library/include/precond/hipsparse_gtsv_strided_batch.h new file mode 100644 index 00000000..904c127a --- /dev/null +++ b/library/include/precond/hipsparse_gtsv_strided_batch.h @@ -0,0 +1,142 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \ingroup precond_module +* \brief Strided Batch tridiagonal solver (no pivoting) +* +* \details +* \p hipsparseXgtsv2StridedBatch_bufferSizeExt returns the size of the temporary storage +* buffer in bytes that is required by hipsparseXgtsv2StridedBatch(). The temporary +* storage buffer must be allocated by the user. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, + int m, + const float* dl, + const float* d, + const float* du, + const float* x, + int batchCount, + int batchStride, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, + int m, + const double* dl, + const double* d, + const double* du, + const double* x, + int batchCount, + int batchStride, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, + int m, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + const hipComplex* x, + int batchCount, + int batchStride, + size_t* pBufferSizeInBytes); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsv2StridedBatch_bufferSizeExt(hipsparseHandle_t handle, + int m, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + const hipDoubleComplex* x, + int batchCount, + int batchStride, + size_t* pBufferSizeInBytes); +/**@}*/ + +/*! \ingroup precond_module +* \brief Strided Batch tridiagonal solver (no pivoting) +* +* \details +* \p hipsparseXgtsv2StridedBatch solves a batched tridiagonal linear system +* +* \note +* This function is non blocking and executed asynchronously with respect to the host. +* It may return before the actual computation has finished. +*/ +/**@{*/ +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseSgtsv2StridedBatch(hipsparseHandle_t handle, + int m, + const float* dl, + const float* d, + const float* du, + float* x, + int batchCount, + int batchStride, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDgtsv2StridedBatch(hipsparseHandle_t handle, + int m, + const double* dl, + const double* d, + const double* du, + double* x, + int batchCount, + int batchStride, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCgtsv2StridedBatch(hipsparseHandle_t handle, + int m, + const hipComplex* dl, + const hipComplex* d, + const hipComplex* du, + hipComplex* x, + int batchCount, + int batchStride, + void* pBuffer); + +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZgtsv2StridedBatch(hipsparseHandle_t handle, + int m, + const hipDoubleComplex* dl, + const hipDoubleComplex* d, + const hipDoubleComplex* du, + hipDoubleComplex* x, + int batchCount, + int batchStride, + void* pBuffer); +/**@}*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/library/include/reorder/hipsparse_csrcolor.h b/library/include/reorder/hipsparse_csrcolor.h new file mode 100644 index 00000000..aef34bee --- /dev/null +++ b/library/include/reorder/hipsparse_csrcolor.h @@ -0,0 +1,102 @@ +/*! \file */ +/* ************************************************************************ + * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * ************************************************************************ */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) +/*! \ingroup reordering_module +* \brief Coloring of the adjacency graph of the matrix \f$A\f$ stored in the CSR format. +* +* \details +* \p hipsparseXcsrcolor performs the coloring of the undirected graph represented by the (symmetric) sparsity pattern of the matrix \f$A\f$ stored in CSR format. Graph coloring is a way of coloring the nodes of a graph such that no two adjacent nodes are of the same color. The \p fraction_to_color is a parameter to only color a given percentage of the graph nodes, the remaining uncolored nodes receive distinct new colors. The optional \p reordering array is a permutation array such that unknowns of the same color are grouped. The matrix \f$A\f$ must be stored as a general matrix with a symmetric sparsity pattern, and if the matrix \f$A\f$ is non-symmetric then the user is responsible to provide the symmetric part \f$\frac{A+A^T}{2}\f$. +*/ +/**@{*/ +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseScsrcolor(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const float* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* fractionToColor, + int* ncolors, + int* coloring, + int* reordering, + hipsparseColorInfo_t info); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseDcsrcolor(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const double* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* fractionToColor, + int* ncolors, + int* coloring, + int* reordering, + hipsparseColorInfo_t info); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseCcsrcolor(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const float* fractionToColor, + int* ncolors, + int* coloring, + int* reordering, + hipsparseColorInfo_t info); + +DEPRECATED_CUDA_12000("The routine will be removed in CUDA 13") +HIPSPARSE_EXPORT +hipsparseStatus_t hipsparseZcsrcolor(hipsparseHandle_t handle, + int m, + int nnz, + const hipsparseMatDescr_t descrA, + const hipDoubleComplex* csrValA, + const int* csrRowPtrA, + const int* csrColIndA, + const double* fractionToColor, + int* ncolors, + int* coloring, + int* reordering, + hipsparseColorInfo_t info); +/**@}*/ +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file From ede23282bd3e1d4c2b368818548a2a0a03e25823 Mon Sep 17 00:00:00 2001 From: jsandham Date: Thu, 18 Apr 2024 00:00:09 +0000 Subject: [PATCH 2/8] Clang formatting --- library/include/conversion/hipsparse_bsr2csr.h | 1 + library/include/conversion/hipsparse_coo2csr.h | 1 + library/include/conversion/hipsparse_coosort.h | 1 + .../include/conversion/hipsparse_create_identity_permutation.h | 1 + library/include/conversion/hipsparse_csc2dense.h | 1 + library/include/conversion/hipsparse_cscsort.h | 1 + library/include/conversion/hipsparse_csr2bsr.h | 1 + library/include/conversion/hipsparse_csr2coo.h | 1 + library/include/conversion/hipsparse_csr2csc.h | 1 + library/include/conversion/hipsparse_csr2csr_compress.h | 1 + library/include/conversion/hipsparse_csr2csru.h | 1 + library/include/conversion/hipsparse_csr2dense.h | 1 + library/include/conversion/hipsparse_csr2gebsr.h | 1 + library/include/conversion/hipsparse_csr2hyb.h | 1 + library/include/conversion/hipsparse_csrsort.h | 1 + library/include/conversion/hipsparse_csru2csr.h | 1 + library/include/conversion/hipsparse_dense2csc.h | 1 + library/include/conversion/hipsparse_dense2csr.h | 1 + library/include/conversion/hipsparse_gebsr2csr.h | 1 + library/include/conversion/hipsparse_gebsr2gebsc.h | 1 + library/include/conversion/hipsparse_gebsr2gebsr.h | 1 + library/include/conversion/hipsparse_hyb2csr.h | 1 + library/include/conversion/hipsparse_nnz.h | 1 + library/include/conversion/hipsparse_nnz_compress.h | 1 + library/include/conversion/hipsparse_prune_csr2csr.h | 1 + .../include/conversion/hipsparse_prune_csr2csr_by_percentage.h | 1 + library/include/conversion/hipsparse_prune_dense2csr.h | 1 + .../include/conversion/hipsparse_prune_dense2csr_by_percentage.h | 1 + library/include/extra/hipsparse_csrgeam.h | 1 + library/include/extra/hipsparse_csrgemm.h | 1 + library/include/generic/hipsparse_axpby.h | 1 + library/include/generic/hipsparse_dense2sparse.h | 1 + library/include/generic/hipsparse_gather.h | 1 + library/include/generic/hipsparse_rot.h | 1 + library/include/generic/hipsparse_scatter.h | 1 + library/include/generic/hipsparse_sddmm.h | 1 + library/include/generic/hipsparse_sparse2dense.h | 1 + library/include/generic/hipsparse_spgemm.h | 1 + library/include/generic/hipsparse_spgemm_reuse.h | 1 + library/include/generic/hipsparse_spmm.h | 1 + library/include/generic/hipsparse_spmv.h | 1 + library/include/generic/hipsparse_spsm.h | 1 + library/include/generic/hipsparse_spsv.h | 1 + library/include/generic/hipsparse_spvv.h | 1 + library/include/hipsparse.h | 1 + library/include/hipsparse_auxiliary.h | 1 + library/include/hipsparse_generic_auxiliary.h | 1 + library/include/hipsparse_generic_types.h | 1 + library/include/hipsparse_types.h | 1 + library/include/level1/hipsparse_axpyi.h | 1 + library/include/level1/hipsparse_dotci.h | 1 + library/include/level1/hipsparse_doti.h | 1 + library/include/level1/hipsparse_gthr.h | 1 + library/include/level1/hipsparse_gthrz.h | 1 + library/include/level1/hipsparse_roti.h | 1 + library/include/level1/hipsparse_sctr.h | 1 + library/include/level2/hipsparse_bsrmv.h | 1 + library/include/level2/hipsparse_bsrsv.h | 1 + library/include/level2/hipsparse_bsrxmv.h | 1 + library/include/level2/hipsparse_csrmv.h | 1 + library/include/level2/hipsparse_csrsv.h | 1 + library/include/level2/hipsparse_gemvi.h | 1 + library/include/level2/hipsparse_hybmv.h | 1 + library/include/level3/hipsparse_bsrmm.h | 1 + library/include/level3/hipsparse_bsrsm.h | 1 + library/include/level3/hipsparse_csrmm.h | 1 + library/include/level3/hipsparse_csrsm.h | 1 + library/include/level3/hipsparse_gemmi.h | 1 + library/include/precond/hipsparse_bsric0.h | 1 + library/include/precond/hipsparse_bsrilu0.h | 1 + library/include/precond/hipsparse_csric0.h | 1 + library/include/precond/hipsparse_csrilu0.h | 1 + library/include/precond/hipsparse_gpsv_interleaved_batch.h | 1 + library/include/precond/hipsparse_gtsv.h | 1 + library/include/precond/hipsparse_gtsv_interleaved_batch.h | 1 + library/include/precond/hipsparse_gtsv_nopivot.h | 1 + library/include/precond/hipsparse_gtsv_strided_batch.h | 1 + library/include/reorder/hipsparse_csrcolor.h | 1 + 78 files changed, 78 insertions(+) diff --git a/library/include/conversion/hipsparse_bsr2csr.h b/library/include/conversion/hipsparse_bsr2csr.h index 5b8422f2..7223dd2e 100644 --- a/library/include/conversion/hipsparse_bsr2csr.h +++ b/library/include/conversion/hipsparse_bsr2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_coo2csr.h b/library/include/conversion/hipsparse_coo2csr.h index 8039b50d..64c602c7 100644 --- a/library/include/conversion/hipsparse_coo2csr.h +++ b/library/include/conversion/hipsparse_coo2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_coosort.h b/library/include/conversion/hipsparse_coosort.h index 564580bd..7f45b0c7 100644 --- a/library/include/conversion/hipsparse_coosort.h +++ b/library/include/conversion/hipsparse_coosort.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_create_identity_permutation.h b/library/include/conversion/hipsparse_create_identity_permutation.h index 9c553be7..14f7c3ad 100644 --- a/library/include/conversion/hipsparse_create_identity_permutation.h +++ b/library/include/conversion/hipsparse_create_identity_permutation.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csc2dense.h b/library/include/conversion/hipsparse_csc2dense.h index 282bb765..17fa857e 100644 --- a/library/include/conversion/hipsparse_csc2dense.h +++ b/library/include/conversion/hipsparse_csc2dense.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_cscsort.h b/library/include/conversion/hipsparse_cscsort.h index 2dfb1a6b..76b1236e 100644 --- a/library/include/conversion/hipsparse_cscsort.h +++ b/library/include/conversion/hipsparse_cscsort.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2bsr.h b/library/include/conversion/hipsparse_csr2bsr.h index 146c93ff..84eb96c8 100644 --- a/library/include/conversion/hipsparse_csr2bsr.h +++ b/library/include/conversion/hipsparse_csr2bsr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2coo.h b/library/include/conversion/hipsparse_csr2coo.h index e803803a..aafdd3ef 100644 --- a/library/include/conversion/hipsparse_csr2coo.h +++ b/library/include/conversion/hipsparse_csr2coo.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2csc.h b/library/include/conversion/hipsparse_csr2csc.h index 21b0350d..cad69e9d 100644 --- a/library/include/conversion/hipsparse_csr2csc.h +++ b/library/include/conversion/hipsparse_csr2csc.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2csr_compress.h b/library/include/conversion/hipsparse_csr2csr_compress.h index 01010d0d..31678f10 100644 --- a/library/include/conversion/hipsparse_csr2csr_compress.h +++ b/library/include/conversion/hipsparse_csr2csr_compress.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2csru.h b/library/include/conversion/hipsparse_csr2csru.h index b8cf3f4b..f5bff18e 100644 --- a/library/include/conversion/hipsparse_csr2csru.h +++ b/library/include/conversion/hipsparse_csr2csru.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2dense.h b/library/include/conversion/hipsparse_csr2dense.h index 8794b21e..9ea6f149 100644 --- a/library/include/conversion/hipsparse_csr2dense.h +++ b/library/include/conversion/hipsparse_csr2dense.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2gebsr.h b/library/include/conversion/hipsparse_csr2gebsr.h index 468cc885..2c2ff808 100644 --- a/library/include/conversion/hipsparse_csr2gebsr.h +++ b/library/include/conversion/hipsparse_csr2gebsr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2hyb.h b/library/include/conversion/hipsparse_csr2hyb.h index 4aa639ed..0f58b02a 100644 --- a/library/include/conversion/hipsparse_csr2hyb.h +++ b/library/include/conversion/hipsparse_csr2hyb.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csrsort.h b/library/include/conversion/hipsparse_csrsort.h index bd88dbfa..1ee5951c 100644 --- a/library/include/conversion/hipsparse_csrsort.h +++ b/library/include/conversion/hipsparse_csrsort.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csru2csr.h b/library/include/conversion/hipsparse_csru2csr.h index 3dd5fdf9..e660eb47 100644 --- a/library/include/conversion/hipsparse_csru2csr.h +++ b/library/include/conversion/hipsparse_csru2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_dense2csc.h b/library/include/conversion/hipsparse_dense2csc.h index f24a186e..c07ef515 100644 --- a/library/include/conversion/hipsparse_dense2csc.h +++ b/library/include/conversion/hipsparse_dense2csc.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_dense2csr.h b/library/include/conversion/hipsparse_dense2csr.h index 8518c2b2..772635cc 100644 --- a/library/include/conversion/hipsparse_dense2csr.h +++ b/library/include/conversion/hipsparse_dense2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_gebsr2csr.h b/library/include/conversion/hipsparse_gebsr2csr.h index a4fe3bb2..ba9a1782 100644 --- a/library/include/conversion/hipsparse_gebsr2csr.h +++ b/library/include/conversion/hipsparse_gebsr2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsc.h b/library/include/conversion/hipsparse_gebsr2gebsc.h index 3b02f48f..13e3c023 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsc.h +++ b/library/include/conversion/hipsparse_gebsr2gebsc.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsr.h b/library/include/conversion/hipsparse_gebsr2gebsr.h index dd046596..9ce4f512 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsr.h +++ b/library/include/conversion/hipsparse_gebsr2gebsr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_hyb2csr.h b/library/include/conversion/hipsparse_hyb2csr.h index 47ca3801..6c973871 100644 --- a/library/include/conversion/hipsparse_hyb2csr.h +++ b/library/include/conversion/hipsparse_hyb2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_nnz.h b/library/include/conversion/hipsparse_nnz.h index 6fc56af8..0c8bf153 100644 --- a/library/include/conversion/hipsparse_nnz.h +++ b/library/include/conversion/hipsparse_nnz.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_nnz_compress.h b/library/include/conversion/hipsparse_nnz_compress.h index 70083f1e..fc82c5c5 100644 --- a/library/include/conversion/hipsparse_nnz_compress.h +++ b/library/include/conversion/hipsparse_nnz_compress.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_csr2csr.h b/library/include/conversion/hipsparse_prune_csr2csr.h index a7d4c11f..6bef365a 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr.h +++ b/library/include/conversion/hipsparse_prune_csr2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h index 1d72b3a0..e2307154 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_dense2csr.h b/library/include/conversion/hipsparse_prune_dense2csr.h index da97e467..d410e643 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr.h +++ b/library/include/conversion/hipsparse_prune_dense2csr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h index 4a03fcd8..2b9eec21 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/extra/hipsparse_csrgeam.h b/library/include/extra/hipsparse_csrgeam.h index 4aba4f4f..ef66e40f 100644 --- a/library/include/extra/hipsparse_csrgeam.h +++ b/library/include/extra/hipsparse_csrgeam.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/extra/hipsparse_csrgemm.h b/library/include/extra/hipsparse_csrgemm.h index 224b760c..a7207822 100644 --- a/library/include/extra/hipsparse_csrgemm.h +++ b/library/include/extra/hipsparse_csrgemm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_axpby.h b/library/include/generic/hipsparse_axpby.h index ae5329d5..666d05bf 100644 --- a/library/include/generic/hipsparse_axpby.h +++ b/library/include/generic/hipsparse_axpby.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_dense2sparse.h b/library/include/generic/hipsparse_dense2sparse.h index 1334bce5..66d700ae 100644 --- a/library/include/generic/hipsparse_dense2sparse.h +++ b/library/include/generic/hipsparse_dense2sparse.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_gather.h b/library/include/generic/hipsparse_gather.h index c3df4e4b..2631bbdb 100644 --- a/library/include/generic/hipsparse_gather.h +++ b/library/include/generic/hipsparse_gather.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_rot.h b/library/include/generic/hipsparse_rot.h index 52427c97..8cfc5cff 100644 --- a/library/include/generic/hipsparse_rot.h +++ b/library/include/generic/hipsparse_rot.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_scatter.h b/library/include/generic/hipsparse_scatter.h index 5371f191..c1883bb0 100644 --- a/library/include/generic/hipsparse_scatter.h +++ b/library/include/generic/hipsparse_scatter.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_sddmm.h b/library/include/generic/hipsparse_sddmm.h index 11f570d6..3594c2a6 100644 --- a/library/include/generic/hipsparse_sddmm.h +++ b/library/include/generic/hipsparse_sddmm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_sparse2dense.h b/library/include/generic/hipsparse_sparse2dense.h index 1faebf73..95ccbdd6 100644 --- a/library/include/generic/hipsparse_sparse2dense.h +++ b/library/include/generic/hipsparse_sparse2dense.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spgemm.h b/library/include/generic/hipsparse_spgemm.h index 3c7f94f3..7c0d472b 100644 --- a/library/include/generic/hipsparse_spgemm.h +++ b/library/include/generic/hipsparse_spgemm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spgemm_reuse.h b/library/include/generic/hipsparse_spgemm_reuse.h index b81fa3d4..ad6cd5b5 100644 --- a/library/include/generic/hipsparse_spgemm_reuse.h +++ b/library/include/generic/hipsparse_spgemm_reuse.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spmm.h b/library/include/generic/hipsparse_spmm.h index 4ba4e599..25ee74d9 100644 --- a/library/include/generic/hipsparse_spmm.h +++ b/library/include/generic/hipsparse_spmm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spmv.h b/library/include/generic/hipsparse_spmv.h index 405ee180..d4d27eb2 100644 --- a/library/include/generic/hipsparse_spmv.h +++ b/library/include/generic/hipsparse_spmv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spsm.h b/library/include/generic/hipsparse_spsm.h index 94797fe2..e69c52fa 100644 --- a/library/include/generic/hipsparse_spsm.h +++ b/library/include/generic/hipsparse_spsm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spsv.h b/library/include/generic/hipsparse_spsv.h index 5451a86a..79ac9034 100644 --- a/library/include/generic/hipsparse_spsv.h +++ b/library/include/generic/hipsparse_spsv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spvv.h b/library/include/generic/hipsparse_spvv.h index 1a42974e..093ce965 100644 --- a/library/include/generic/hipsparse_spvv.h +++ b/library/include/generic/hipsparse_spvv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/hipsparse.h b/library/include/hipsparse.h index cc998bf9..df66732a 100644 --- a/library/include/hipsparse.h +++ b/library/include/hipsparse.h @@ -217,3 +217,4 @@ #include "generic/hipsparse_spsm.h" #endif // HIPSPARSE_H + diff --git a/library/include/hipsparse_auxiliary.h b/library/include/hipsparse_auxiliary.h index 79d1af30..25988d8f 100644 --- a/library/include/hipsparse_auxiliary.h +++ b/library/include/hipsparse_auxiliary.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/hipsparse_generic_auxiliary.h b/library/include/hipsparse_generic_auxiliary.h index c42b504e..271b214b 100644 --- a/library/include/hipsparse_generic_auxiliary.h +++ b/library/include/hipsparse_generic_auxiliary.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/hipsparse_generic_types.h b/library/include/hipsparse_generic_types.h index d04b09d4..718b9ea4 100644 --- a/library/include/hipsparse_generic_types.h +++ b/library/include/hipsparse_generic_types.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + /*! \ingroup types_module * \brief Generic API opaque structure holding information for a sparse vector * diff --git a/library/include/hipsparse_types.h b/library/include/hipsparse_types.h index bd30f046..f154b206 100644 --- a/library/include/hipsparse_types.h +++ b/library/include/hipsparse_types.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + /// \cond DO_NOT_DOCUMENT // Forward declarations struct bsrsv2Info; diff --git a/library/include/level1/hipsparse_axpyi.h b/library/include/level1/hipsparse_axpyi.h index f59aa6fd..7f9fea1f 100644 --- a/library/include/level1/hipsparse_axpyi.h +++ b/library/include/level1/hipsparse_axpyi.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_dotci.h b/library/include/level1/hipsparse_dotci.h index 2cbfb079..daedecc6 100644 --- a/library/include/level1/hipsparse_dotci.h +++ b/library/include/level1/hipsparse_dotci.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_doti.h b/library/include/level1/hipsparse_doti.h index eb8b6098..f5b660bb 100644 --- a/library/include/level1/hipsparse_doti.h +++ b/library/include/level1/hipsparse_doti.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_gthr.h b/library/include/level1/hipsparse_gthr.h index 3dc96989..37579548 100644 --- a/library/include/level1/hipsparse_gthr.h +++ b/library/include/level1/hipsparse_gthr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_gthrz.h b/library/include/level1/hipsparse_gthrz.h index dfc013fa..298017b2 100644 --- a/library/include/level1/hipsparse_gthrz.h +++ b/library/include/level1/hipsparse_gthrz.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_roti.h b/library/include/level1/hipsparse_roti.h index 5b266488..4d161374 100644 --- a/library/include/level1/hipsparse_roti.h +++ b/library/include/level1/hipsparse_roti.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_sctr.h b/library/include/level1/hipsparse_sctr.h index a1d03128..205723d6 100644 --- a/library/include/level1/hipsparse_sctr.h +++ b/library/include/level1/hipsparse_sctr.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_bsrmv.h b/library/include/level2/hipsparse_bsrmv.h index 6463cb9e..2fabb015 100644 --- a/library/include/level2/hipsparse_bsrmv.h +++ b/library/include/level2/hipsparse_bsrmv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_bsrsv.h b/library/include/level2/hipsparse_bsrsv.h index a71b1764..e4d56b75 100644 --- a/library/include/level2/hipsparse_bsrsv.h +++ b/library/include/level2/hipsparse_bsrsv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_bsrxmv.h b/library/include/level2/hipsparse_bsrxmv.h index 87c458f4..16363a30 100644 --- a/library/include/level2/hipsparse_bsrxmv.h +++ b/library/include/level2/hipsparse_bsrxmv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_csrmv.h b/library/include/level2/hipsparse_csrmv.h index 6ed39d70..70fa019d 100644 --- a/library/include/level2/hipsparse_csrmv.h +++ b/library/include/level2/hipsparse_csrmv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_csrsv.h b/library/include/level2/hipsparse_csrsv.h index 40044f9c..52edd7dc 100644 --- a/library/include/level2/hipsparse_csrsv.h +++ b/library/include/level2/hipsparse_csrsv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_gemvi.h b/library/include/level2/hipsparse_gemvi.h index f2d2a83c..f4f8814b 100644 --- a/library/include/level2/hipsparse_gemvi.h +++ b/library/include/level2/hipsparse_gemvi.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_hybmv.h b/library/include/level2/hipsparse_hybmv.h index c3e5e3a8..493c85b0 100644 --- a/library/include/level2/hipsparse_hybmv.h +++ b/library/include/level2/hipsparse_hybmv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_bsrmm.h b/library/include/level3/hipsparse_bsrmm.h index 60f6e0e3..484bdfee 100644 --- a/library/include/level3/hipsparse_bsrmm.h +++ b/library/include/level3/hipsparse_bsrmm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_bsrsm.h b/library/include/level3/hipsparse_bsrsm.h index bb24af6b..3bc96cba 100644 --- a/library/include/level3/hipsparse_bsrsm.h +++ b/library/include/level3/hipsparse_bsrsm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_csrmm.h b/library/include/level3/hipsparse_csrmm.h index 29ae7040..92d38b53 100644 --- a/library/include/level3/hipsparse_csrmm.h +++ b/library/include/level3/hipsparse_csrmm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_csrsm.h b/library/include/level3/hipsparse_csrsm.h index 87d00cc4..a725bed8 100644 --- a/library/include/level3/hipsparse_csrsm.h +++ b/library/include/level3/hipsparse_csrsm.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_gemmi.h b/library/include/level3/hipsparse_gemmi.h index 09aea259..aa377338 100644 --- a/library/include/level3/hipsparse_gemmi.h +++ b/library/include/level3/hipsparse_gemmi.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_bsric0.h b/library/include/precond/hipsparse_bsric0.h index 59d9e788..ba95948b 100644 --- a/library/include/precond/hipsparse_bsric0.h +++ b/library/include/precond/hipsparse_bsric0.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_bsrilu0.h b/library/include/precond/hipsparse_bsrilu0.h index be641664..281c4c64 100644 --- a/library/include/precond/hipsparse_bsrilu0.h +++ b/library/include/precond/hipsparse_bsrilu0.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_csric0.h b/library/include/precond/hipsparse_csric0.h index b7f974c3..2fdce72d 100644 --- a/library/include/precond/hipsparse_csric0.h +++ b/library/include/precond/hipsparse_csric0.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_csrilu0.h b/library/include/precond/hipsparse_csrilu0.h index 09e8e106..2471e3cc 100644 --- a/library/include/precond/hipsparse_csrilu0.h +++ b/library/include/precond/hipsparse_csrilu0.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gpsv_interleaved_batch.h b/library/include/precond/hipsparse_gpsv_interleaved_batch.h index 6b46b033..3d72d198 100644 --- a/library/include/precond/hipsparse_gpsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gpsv_interleaved_batch.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv.h b/library/include/precond/hipsparse_gtsv.h index c4ded098..62dab298 100644 --- a/library/include/precond/hipsparse_gtsv.h +++ b/library/include/precond/hipsparse_gtsv.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv_interleaved_batch.h b/library/include/precond/hipsparse_gtsv_interleaved_batch.h index 03419d85..12f5505d 100644 --- a/library/include/precond/hipsparse_gtsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gtsv_interleaved_batch.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv_nopivot.h b/library/include/precond/hipsparse_gtsv_nopivot.h index 5bfa3aa5..4740d7c2 100644 --- a/library/include/precond/hipsparse_gtsv_nopivot.h +++ b/library/include/precond/hipsparse_gtsv_nopivot.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv_strided_batch.h b/library/include/precond/hipsparse_gtsv_strided_batch.h index 904c127a..a1afe5a1 100644 --- a/library/include/precond/hipsparse_gtsv_strided_batch.h +++ b/library/include/precond/hipsparse_gtsv_strided_batch.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/reorder/hipsparse_csrcolor.h b/library/include/reorder/hipsparse_csrcolor.h index aef34bee..462c3428 100644 --- a/library/include/reorder/hipsparse_csrcolor.h +++ b/library/include/reorder/hipsparse_csrcolor.h @@ -23,6 +23,7 @@ * ************************************************************************ */ #pragma once + #ifdef __cplusplus extern "C" { #endif From 7bfe16153b360c264956a816b20c1bca6e528bab Mon Sep 17 00:00:00 2001 From: jsandham Date: Thu, 18 Apr 2024 00:00:14 +0000 Subject: [PATCH 3/8] Clang formatting --- .../include/conversion/hipsparse_bsr2csr.h | 1 - .../include/conversion/hipsparse_coo2csr.h | 1 - .../include/conversion/hipsparse_coosort.h | 1 - .../hipsparse_create_identity_permutation.h | 1 - .../include/conversion/hipsparse_csc2dense.h | 1 - .../include/conversion/hipsparse_cscsort.h | 1 - .../include/conversion/hipsparse_csr2bsr.h | 1 - .../include/conversion/hipsparse_csr2coo.h | 1 - .../include/conversion/hipsparse_csr2csc.h | 1 - .../conversion/hipsparse_csr2csr_compress.h | 1 - .../include/conversion/hipsparse_csr2csru.h | 1 - .../include/conversion/hipsparse_csr2dense.h | 1 - .../include/conversion/hipsparse_csr2gebsr.h | 1 - .../include/conversion/hipsparse_csr2hyb.h | 1 - .../include/conversion/hipsparse_csrsort.h | 1 - .../include/conversion/hipsparse_csru2csr.h | 2 - .../include/conversion/hipsparse_dense2csc.h | 1 - .../include/conversion/hipsparse_dense2csr.h | 1 - .../include/conversion/hipsparse_gebsr2csr.h | 1 - .../conversion/hipsparse_gebsr2gebsc.h | 1 - .../conversion/hipsparse_gebsr2gebsr.h | 1 - .../include/conversion/hipsparse_hyb2csr.h | 1 - library/include/conversion/hipsparse_nnz.h | 1 - .../conversion/hipsparse_nnz_compress.h | 1 - .../conversion/hipsparse_prune_csr2csr.h | 1 - .../hipsparse_prune_csr2csr_by_percentage.h | 1 - .../conversion/hipsparse_prune_dense2csr.h | 1 - .../hipsparse_prune_dense2csr_by_percentage.h | 1 - library/include/extra/hipsparse_csrgeam.h | 2 - library/include/extra/hipsparse_csrgemm.h | 6 -- library/include/generic/hipsparse_axpby.h | 1 - .../include/generic/hipsparse_dense2sparse.h | 1 - library/include/generic/hipsparse_gather.h | 1 - library/include/generic/hipsparse_rot.h | 1 - library/include/generic/hipsparse_scatter.h | 1 - library/include/generic/hipsparse_sddmm.h | 1 - .../include/generic/hipsparse_sparse2dense.h | 1 - library/include/generic/hipsparse_spgemm.h | 1 - .../include/generic/hipsparse_spgemm_reuse.h | 1 - library/include/generic/hipsparse_spmm.h | 1 - library/include/generic/hipsparse_spmv.h | 1 - library/include/generic/hipsparse_spsm.h | 1 - library/include/generic/hipsparse_spsv.h | 1 - library/include/generic/hipsparse_spvv.h | 4 - library/include/hipsparse.h | 79 +++++++++---------- library/include/hipsparse_auxiliary.h | 1 - library/include/hipsparse_generic_auxiliary.h | 1 - library/include/hipsparse_generic_types.h | 1 - library/include/hipsparse_types.h | 1 - library/include/level1/hipsparse_axpyi.h | 1 - library/include/level1/hipsparse_dotci.h | 1 - library/include/level1/hipsparse_doti.h | 1 - library/include/level1/hipsparse_gthr.h | 1 - library/include/level1/hipsparse_gthrz.h | 1 - library/include/level1/hipsparse_roti.h | 1 - library/include/level1/hipsparse_sctr.h | 1 - library/include/level2/hipsparse_bsrmv.h | 1 - library/include/level2/hipsparse_bsrsv.h | 2 - library/include/level2/hipsparse_bsrxmv.h | 1 - library/include/level2/hipsparse_csrmv.h | 1 - library/include/level2/hipsparse_csrsv.h | 1 - library/include/level2/hipsparse_gemvi.h | 1 - library/include/level2/hipsparse_hybmv.h | 1 - library/include/level3/hipsparse_bsrmm.h | 1 - library/include/level3/hipsparse_bsrsm.h | 1 - library/include/level3/hipsparse_csrmm.h | 2 - library/include/level3/hipsparse_csrsm.h | 1 - library/include/level3/hipsparse_gemmi.h | 1 - library/include/precond/hipsparse_bsric0.h | 1 - library/include/precond/hipsparse_bsrilu0.h | 1 - library/include/precond/hipsparse_csric0.h | 1 - library/include/precond/hipsparse_csrilu0.h | 1 - .../hipsparse_gpsv_interleaved_batch.h | 1 - library/include/precond/hipsparse_gtsv.h | 1 - .../hipsparse_gtsv_interleaved_batch.h | 1 - .../include/precond/hipsparse_gtsv_nopivot.h | 1 - .../precond/hipsparse_gtsv_strided_batch.h | 1 - library/include/reorder/hipsparse_csrcolor.h | 1 - 78 files changed, 39 insertions(+), 129 deletions(-) diff --git a/library/include/conversion/hipsparse_bsr2csr.h b/library/include/conversion/hipsparse_bsr2csr.h index 7223dd2e..5b8422f2 100644 --- a/library/include/conversion/hipsparse_bsr2csr.h +++ b/library/include/conversion/hipsparse_bsr2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_coo2csr.h b/library/include/conversion/hipsparse_coo2csr.h index 64c602c7..8039b50d 100644 --- a/library/include/conversion/hipsparse_coo2csr.h +++ b/library/include/conversion/hipsparse_coo2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_coosort.h b/library/include/conversion/hipsparse_coosort.h index 7f45b0c7..564580bd 100644 --- a/library/include/conversion/hipsparse_coosort.h +++ b/library/include/conversion/hipsparse_coosort.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_create_identity_permutation.h b/library/include/conversion/hipsparse_create_identity_permutation.h index 14f7c3ad..9c553be7 100644 --- a/library/include/conversion/hipsparse_create_identity_permutation.h +++ b/library/include/conversion/hipsparse_create_identity_permutation.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csc2dense.h b/library/include/conversion/hipsparse_csc2dense.h index 17fa857e..282bb765 100644 --- a/library/include/conversion/hipsparse_csc2dense.h +++ b/library/include/conversion/hipsparse_csc2dense.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_cscsort.h b/library/include/conversion/hipsparse_cscsort.h index 76b1236e..2dfb1a6b 100644 --- a/library/include/conversion/hipsparse_cscsort.h +++ b/library/include/conversion/hipsparse_cscsort.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2bsr.h b/library/include/conversion/hipsparse_csr2bsr.h index 84eb96c8..146c93ff 100644 --- a/library/include/conversion/hipsparse_csr2bsr.h +++ b/library/include/conversion/hipsparse_csr2bsr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2coo.h b/library/include/conversion/hipsparse_csr2coo.h index aafdd3ef..e803803a 100644 --- a/library/include/conversion/hipsparse_csr2coo.h +++ b/library/include/conversion/hipsparse_csr2coo.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2csc.h b/library/include/conversion/hipsparse_csr2csc.h index cad69e9d..21b0350d 100644 --- a/library/include/conversion/hipsparse_csr2csc.h +++ b/library/include/conversion/hipsparse_csr2csc.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2csr_compress.h b/library/include/conversion/hipsparse_csr2csr_compress.h index 31678f10..01010d0d 100644 --- a/library/include/conversion/hipsparse_csr2csr_compress.h +++ b/library/include/conversion/hipsparse_csr2csr_compress.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2csru.h b/library/include/conversion/hipsparse_csr2csru.h index f5bff18e..b8cf3f4b 100644 --- a/library/include/conversion/hipsparse_csr2csru.h +++ b/library/include/conversion/hipsparse_csr2csru.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2dense.h b/library/include/conversion/hipsparse_csr2dense.h index 9ea6f149..8794b21e 100644 --- a/library/include/conversion/hipsparse_csr2dense.h +++ b/library/include/conversion/hipsparse_csr2dense.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2gebsr.h b/library/include/conversion/hipsparse_csr2gebsr.h index 2c2ff808..468cc885 100644 --- a/library/include/conversion/hipsparse_csr2gebsr.h +++ b/library/include/conversion/hipsparse_csr2gebsr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csr2hyb.h b/library/include/conversion/hipsparse_csr2hyb.h index 0f58b02a..4aa639ed 100644 --- a/library/include/conversion/hipsparse_csr2hyb.h +++ b/library/include/conversion/hipsparse_csr2hyb.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csrsort.h b/library/include/conversion/hipsparse_csrsort.h index 1ee5951c..bd88dbfa 100644 --- a/library/include/conversion/hipsparse_csrsort.h +++ b/library/include/conversion/hipsparse_csrsort.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_csru2csr.h b/library/include/conversion/hipsparse_csru2csr.h index e660eb47..56211e4b 100644 --- a/library/include/conversion/hipsparse_csru2csr.h +++ b/library/include/conversion/hipsparse_csru2csr.h @@ -23,12 +23,10 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif - #if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) /*! \ingroup conv_module * \brief diff --git a/library/include/conversion/hipsparse_dense2csc.h b/library/include/conversion/hipsparse_dense2csc.h index c07ef515..f24a186e 100644 --- a/library/include/conversion/hipsparse_dense2csc.h +++ b/library/include/conversion/hipsparse_dense2csc.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_dense2csr.h b/library/include/conversion/hipsparse_dense2csr.h index 772635cc..8518c2b2 100644 --- a/library/include/conversion/hipsparse_dense2csr.h +++ b/library/include/conversion/hipsparse_dense2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_gebsr2csr.h b/library/include/conversion/hipsparse_gebsr2csr.h index ba9a1782..a4fe3bb2 100644 --- a/library/include/conversion/hipsparse_gebsr2csr.h +++ b/library/include/conversion/hipsparse_gebsr2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsc.h b/library/include/conversion/hipsparse_gebsr2gebsc.h index 13e3c023..3b02f48f 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsc.h +++ b/library/include/conversion/hipsparse_gebsr2gebsc.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsr.h b/library/include/conversion/hipsparse_gebsr2gebsr.h index 9ce4f512..dd046596 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsr.h +++ b/library/include/conversion/hipsparse_gebsr2gebsr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_hyb2csr.h b/library/include/conversion/hipsparse_hyb2csr.h index 6c973871..47ca3801 100644 --- a/library/include/conversion/hipsparse_hyb2csr.h +++ b/library/include/conversion/hipsparse_hyb2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_nnz.h b/library/include/conversion/hipsparse_nnz.h index 0c8bf153..6fc56af8 100644 --- a/library/include/conversion/hipsparse_nnz.h +++ b/library/include/conversion/hipsparse_nnz.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_nnz_compress.h b/library/include/conversion/hipsparse_nnz_compress.h index fc82c5c5..70083f1e 100644 --- a/library/include/conversion/hipsparse_nnz_compress.h +++ b/library/include/conversion/hipsparse_nnz_compress.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_csr2csr.h b/library/include/conversion/hipsparse_prune_csr2csr.h index 6bef365a..a7d4c11f 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr.h +++ b/library/include/conversion/hipsparse_prune_csr2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h index e2307154..1d72b3a0 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_dense2csr.h b/library/include/conversion/hipsparse_prune_dense2csr.h index d410e643..da97e467 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr.h +++ b/library/include/conversion/hipsparse_prune_dense2csr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h index 2b9eec21..4a03fcd8 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/extra/hipsparse_csrgeam.h b/library/include/extra/hipsparse_csrgeam.h index ef66e40f..6ae44ff0 100644 --- a/library/include/extra/hipsparse_csrgeam.h +++ b/library/include/extra/hipsparse_csrgeam.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif @@ -305,7 +304,6 @@ hipsparseStatus_t hipsparseXcsrgeam2Nnz(hipsparseHandle_t handle, int* nnzTotalDevHostPtr, void* workspace); - /*! \ingroup extra_module * \brief Sparse matrix sparse matrix addition using CSR storage format * diff --git a/library/include/extra/hipsparse_csrgemm.h b/library/include/extra/hipsparse_csrgemm.h index a7207822..f91d2119 100644 --- a/library/include/extra/hipsparse_csrgemm.h +++ b/library/include/extra/hipsparse_csrgemm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif @@ -73,8 +72,6 @@ hipsparseStatus_t hipsparseXcsrgemmNnz(hipsparseHandle_t handle, int* csrRowPtrC, int* nnzTotalDevHostPtr); - - /*! \ingroup extra_module * \brief Sparse matrix sparse matrix multiplication using CSR storage format * @@ -212,9 +209,6 @@ hipsparseStatus_t hipsparseZcsrgemm(hipsparseHandle_t handle, /**@}*/ #endif - - - #if(!defined(CUDART_VERSION) || CUDART_VERSION < 12000) /*! \ingroup extra_module * \brief Sparse matrix sparse matrix multiplication using CSR storage format diff --git a/library/include/generic/hipsparse_axpby.h b/library/include/generic/hipsparse_axpby.h index 666d05bf..ae5329d5 100644 --- a/library/include/generic/hipsparse_axpby.h +++ b/library/include/generic/hipsparse_axpby.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_dense2sparse.h b/library/include/generic/hipsparse_dense2sparse.h index 66d700ae..1334bce5 100644 --- a/library/include/generic/hipsparse_dense2sparse.h +++ b/library/include/generic/hipsparse_dense2sparse.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_gather.h b/library/include/generic/hipsparse_gather.h index 2631bbdb..c3df4e4b 100644 --- a/library/include/generic/hipsparse_gather.h +++ b/library/include/generic/hipsparse_gather.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_rot.h b/library/include/generic/hipsparse_rot.h index 8cfc5cff..52427c97 100644 --- a/library/include/generic/hipsparse_rot.h +++ b/library/include/generic/hipsparse_rot.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_scatter.h b/library/include/generic/hipsparse_scatter.h index c1883bb0..5371f191 100644 --- a/library/include/generic/hipsparse_scatter.h +++ b/library/include/generic/hipsparse_scatter.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_sddmm.h b/library/include/generic/hipsparse_sddmm.h index 3594c2a6..11f570d6 100644 --- a/library/include/generic/hipsparse_sddmm.h +++ b/library/include/generic/hipsparse_sddmm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_sparse2dense.h b/library/include/generic/hipsparse_sparse2dense.h index 95ccbdd6..1faebf73 100644 --- a/library/include/generic/hipsparse_sparse2dense.h +++ b/library/include/generic/hipsparse_sparse2dense.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spgemm.h b/library/include/generic/hipsparse_spgemm.h index 7c0d472b..3c7f94f3 100644 --- a/library/include/generic/hipsparse_spgemm.h +++ b/library/include/generic/hipsparse_spgemm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spgemm_reuse.h b/library/include/generic/hipsparse_spgemm_reuse.h index ad6cd5b5..b81fa3d4 100644 --- a/library/include/generic/hipsparse_spgemm_reuse.h +++ b/library/include/generic/hipsparse_spgemm_reuse.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spmm.h b/library/include/generic/hipsparse_spmm.h index 25ee74d9..4ba4e599 100644 --- a/library/include/generic/hipsparse_spmm.h +++ b/library/include/generic/hipsparse_spmm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spmv.h b/library/include/generic/hipsparse_spmv.h index d4d27eb2..405ee180 100644 --- a/library/include/generic/hipsparse_spmv.h +++ b/library/include/generic/hipsparse_spmv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spsm.h b/library/include/generic/hipsparse_spsm.h index e69c52fa..94797fe2 100644 --- a/library/include/generic/hipsparse_spsm.h +++ b/library/include/generic/hipsparse_spsm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spsv.h b/library/include/generic/hipsparse_spsv.h index 79ac9034..5451a86a 100644 --- a/library/include/generic/hipsparse_spsv.h +++ b/library/include/generic/hipsparse_spsv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/generic/hipsparse_spvv.h b/library/include/generic/hipsparse_spvv.h index 093ce965..a57aaadf 100644 --- a/library/include/generic/hipsparse_spvv.h +++ b/library/include/generic/hipsparse_spvv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif @@ -57,9 +56,6 @@ hipsparseStatus_t hipsparseSpVV_bufferSize(hipsparseHandle_t handle, size_t* bufferSize); #endif - - - /*! \ingroup generic_module * \brief Description: Compute the inner dot product of a sparse vector with a dense vector * diff --git a/library/include/hipsparse.h b/library/include/hipsparse.h index df66732a..c0c8d32d 100644 --- a/library/include/hipsparse.h +++ b/library/include/hipsparse.h @@ -85,8 +85,8 @@ #endif #endif -#include "hipsparse_types.h" #include "hipsparse_auxiliary.h" +#include "hipsparse_types.h" /* * =========================================================================== @@ -95,8 +95,8 @@ */ #include "level1/hipsparse_axpyi.h" -#include "level1/hipsparse_doti.h" #include "level1/hipsparse_dotci.h" +#include "level1/hipsparse_doti.h" #include "level1/hipsparse_gthr.h" #include "level1/hipsparse_gthrz.h" #include "level1/hipsparse_roti.h" @@ -107,13 +107,13 @@ * level 2 SPARSE * =========================================================================== */ -#include "level2/hipsparse_csrmv.h" -#include "level2/hipsparse_csrsv.h" -#include "level2/hipsparse_hybmv.h" #include "level2/hipsparse_bsrmv.h" -#include "level2/hipsparse_bsrxmv.h" #include "level2/hipsparse_bsrsv.h" +#include "level2/hipsparse_bsrxmv.h" +#include "level2/hipsparse_csrmv.h" +#include "level2/hipsparse_csrsv.h" #include "level2/hipsparse_gemvi.h" +#include "level2/hipsparse_hybmv.h" /* * =========================================================================== @@ -121,8 +121,8 @@ * =========================================================================== */ #include "level3/hipsparse_bsrmm.h" -#include "level3/hipsparse_csrmm.h" #include "level3/hipsparse_bsrsm.h" +#include "level3/hipsparse_csrmm.h" #include "level3/hipsparse_csrsm.h" #include "level3/hipsparse_gemmi.h" @@ -139,49 +139,49 @@ * preconditioner SPARSE * =========================================================================== */ -#include "precond/hipsparse_bsrilu0.h" -#include "precond/hipsparse_csrilu0.h" #include "precond/hipsparse_bsric0.h" +#include "precond/hipsparse_bsrilu0.h" #include "precond/hipsparse_csric0.h" +#include "precond/hipsparse_csrilu0.h" +#include "precond/hipsparse_gpsv_interleaved_batch.h" #include "precond/hipsparse_gtsv.h" +#include "precond/hipsparse_gtsv_interleaved_batch.h" #include "precond/hipsparse_gtsv_nopivot.h" #include "precond/hipsparse_gtsv_strided_batch.h" -#include "precond/hipsparse_gtsv_interleaved_batch.h" -#include "precond/hipsparse_gpsv_interleaved_batch.h" /* * =========================================================================== * Sparse Format Conversions * =========================================================================== */ -#include "conversion/hipsparse_nnz.h" -#include "conversion/hipsparse_dense2csr.h" -#include "conversion/hipsparse_prune_dense2csr.h" -#include "conversion/hipsparse_prune_dense2csr_by_percentage.h" -#include "conversion/hipsparse_dense2csc.h" -#include "conversion/hipsparse_csr2dense.h" +#include "conversion/hipsparse_bsr2csr.h" +#include "conversion/hipsparse_coo2csr.h" +#include "conversion/hipsparse_coosort.h" +#include "conversion/hipsparse_create_identity_permutation.h" #include "conversion/hipsparse_csc2dense.h" -#include "conversion/hipsparse_nnz_compress.h" +#include "conversion/hipsparse_cscsort.h" +#include "conversion/hipsparse_csr2bsr.h" #include "conversion/hipsparse_csr2coo.h" #include "conversion/hipsparse_csr2csc.h" -#include "conversion/hipsparse_csr2hyb.h" -#include "conversion/hipsparse_gebsr2gebsc.h" +#include "conversion/hipsparse_csr2csr_compress.h" +#include "conversion/hipsparse_csr2csru.h" +#include "conversion/hipsparse_csr2dense.h" #include "conversion/hipsparse_csr2gebsr.h" -#include "conversion/hipsparse_csr2bsr.h" -#include "conversion/hipsparse_bsr2csr.h" +#include "conversion/hipsparse_csr2hyb.h" +#include "conversion/hipsparse_csrsort.h" +#include "conversion/hipsparse_csru2csr.h" +#include "conversion/hipsparse_dense2csc.h" +#include "conversion/hipsparse_dense2csr.h" #include "conversion/hipsparse_gebsr2csr.h" -#include "conversion/hipsparse_csr2csr_compress.h" +#include "conversion/hipsparse_gebsr2gebsc.h" +#include "conversion/hipsparse_gebsr2gebsr.h" +#include "conversion/hipsparse_hyb2csr.h" +#include "conversion/hipsparse_nnz.h" +#include "conversion/hipsparse_nnz_compress.h" #include "conversion/hipsparse_prune_csr2csr.h" #include "conversion/hipsparse_prune_csr2csr_by_percentage.h" -#include "conversion/hipsparse_hyb2csr.h" -#include "conversion/hipsparse_coo2csr.h" -#include "conversion/hipsparse_create_identity_permutation.h" -#include "conversion/hipsparse_csrsort.h" -#include "conversion/hipsparse_cscsort.h" -#include "conversion/hipsparse_coosort.h" -#include "conversion/hipsparse_gebsr2gebsr.h" -#include "conversion/hipsparse_csru2csr.h" -#include "conversion/hipsparse_csr2csru.h" +#include "conversion/hipsparse_prune_dense2csr.h" +#include "conversion/hipsparse_prune_dense2csr_by_percentage.h" /* * =========================================================================== @@ -202,19 +202,18 @@ /* Generic API functions */ #include "generic/hipsparse_axpby.h" +#include "generic/hipsparse_dense2sparse.h" #include "generic/hipsparse_gather.h" -#include "generic/hipsparse_scatter.h" #include "generic/hipsparse_rot.h" +#include "generic/hipsparse_scatter.h" +#include "generic/hipsparse_sddmm.h" #include "generic/hipsparse_sparse2dense.h" -#include "generic/hipsparse_dense2sparse.h" -#include "generic/hipsparse_spvv.h" -#include "generic/hipsparse_spmv.h" -#include "generic/hipsparse_spmm.h" #include "generic/hipsparse_spgemm.h" #include "generic/hipsparse_spgemm_reuse.h" -#include "generic/hipsparse_sddmm.h" -#include "generic/hipsparse_spsv.h" +#include "generic/hipsparse_spmm.h" +#include "generic/hipsparse_spmv.h" #include "generic/hipsparse_spsm.h" +#include "generic/hipsparse_spsv.h" +#include "generic/hipsparse_spvv.h" #endif // HIPSPARSE_H - diff --git a/library/include/hipsparse_auxiliary.h b/library/include/hipsparse_auxiliary.h index 25988d8f..79d1af30 100644 --- a/library/include/hipsparse_auxiliary.h +++ b/library/include/hipsparse_auxiliary.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/hipsparse_generic_auxiliary.h b/library/include/hipsparse_generic_auxiliary.h index 271b214b..c42b504e 100644 --- a/library/include/hipsparse_generic_auxiliary.h +++ b/library/include/hipsparse_generic_auxiliary.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/hipsparse_generic_types.h b/library/include/hipsparse_generic_types.h index 718b9ea4..d04b09d4 100644 --- a/library/include/hipsparse_generic_types.h +++ b/library/include/hipsparse_generic_types.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - /*! \ingroup types_module * \brief Generic API opaque structure holding information for a sparse vector * diff --git a/library/include/hipsparse_types.h b/library/include/hipsparse_types.h index f154b206..bd30f046 100644 --- a/library/include/hipsparse_types.h +++ b/library/include/hipsparse_types.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - /// \cond DO_NOT_DOCUMENT // Forward declarations struct bsrsv2Info; diff --git a/library/include/level1/hipsparse_axpyi.h b/library/include/level1/hipsparse_axpyi.h index 7f9fea1f..f59aa6fd 100644 --- a/library/include/level1/hipsparse_axpyi.h +++ b/library/include/level1/hipsparse_axpyi.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_dotci.h b/library/include/level1/hipsparse_dotci.h index daedecc6..2cbfb079 100644 --- a/library/include/level1/hipsparse_dotci.h +++ b/library/include/level1/hipsparse_dotci.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_doti.h b/library/include/level1/hipsparse_doti.h index f5b660bb..eb8b6098 100644 --- a/library/include/level1/hipsparse_doti.h +++ b/library/include/level1/hipsparse_doti.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_gthr.h b/library/include/level1/hipsparse_gthr.h index 37579548..3dc96989 100644 --- a/library/include/level1/hipsparse_gthr.h +++ b/library/include/level1/hipsparse_gthr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_gthrz.h b/library/include/level1/hipsparse_gthrz.h index 298017b2..dfc013fa 100644 --- a/library/include/level1/hipsparse_gthrz.h +++ b/library/include/level1/hipsparse_gthrz.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_roti.h b/library/include/level1/hipsparse_roti.h index 4d161374..5b266488 100644 --- a/library/include/level1/hipsparse_roti.h +++ b/library/include/level1/hipsparse_roti.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level1/hipsparse_sctr.h b/library/include/level1/hipsparse_sctr.h index 205723d6..a1d03128 100644 --- a/library/include/level1/hipsparse_sctr.h +++ b/library/include/level1/hipsparse_sctr.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_bsrmv.h b/library/include/level2/hipsparse_bsrmv.h index 2fabb015..6463cb9e 100644 --- a/library/include/level2/hipsparse_bsrmv.h +++ b/library/include/level2/hipsparse_bsrmv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_bsrsv.h b/library/include/level2/hipsparse_bsrsv.h index e4d56b75..eef9fde2 100644 --- a/library/include/level2/hipsparse_bsrsv.h +++ b/library/include/level2/hipsparse_bsrsv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif @@ -182,7 +181,6 @@ hipsparseStatus_t hipsparseZbsrsv2_bufferSizeExt(hipsparseHandle_t handl size_t* pBufferSizeInBytes); /**@}*/ - #if(!defined(CUDART_VERSION) || CUDART_VERSION < 13000) /*! \ingroup level2_module * \brief Sparse triangular solve using BSR storage format diff --git a/library/include/level2/hipsparse_bsrxmv.h b/library/include/level2/hipsparse_bsrxmv.h index 16363a30..87c458f4 100644 --- a/library/include/level2/hipsparse_bsrxmv.h +++ b/library/include/level2/hipsparse_bsrxmv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_csrmv.h b/library/include/level2/hipsparse_csrmv.h index 70fa019d..6ed39d70 100644 --- a/library/include/level2/hipsparse_csrmv.h +++ b/library/include/level2/hipsparse_csrmv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_csrsv.h b/library/include/level2/hipsparse_csrsv.h index 52edd7dc..40044f9c 100644 --- a/library/include/level2/hipsparse_csrsv.h +++ b/library/include/level2/hipsparse_csrsv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_gemvi.h b/library/include/level2/hipsparse_gemvi.h index f4f8814b..f2d2a83c 100644 --- a/library/include/level2/hipsparse_gemvi.h +++ b/library/include/level2/hipsparse_gemvi.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level2/hipsparse_hybmv.h b/library/include/level2/hipsparse_hybmv.h index 493c85b0..c3e5e3a8 100644 --- a/library/include/level2/hipsparse_hybmv.h +++ b/library/include/level2/hipsparse_hybmv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_bsrmm.h b/library/include/level3/hipsparse_bsrmm.h index 484bdfee..60f6e0e3 100644 --- a/library/include/level3/hipsparse_bsrmm.h +++ b/library/include/level3/hipsparse_bsrmm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_bsrsm.h b/library/include/level3/hipsparse_bsrsm.h index 3bc96cba..bb24af6b 100644 --- a/library/include/level3/hipsparse_bsrsm.h +++ b/library/include/level3/hipsparse_bsrsm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_csrmm.h b/library/include/level3/hipsparse_csrmm.h index 92d38b53..2abe2e96 100644 --- a/library/include/level3/hipsparse_csrmm.h +++ b/library/include/level3/hipsparse_csrmm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif @@ -229,7 +228,6 @@ hipsparseStatus_t hipsparseZcsrmm(hipsparseHandle_t handle, /**@}*/ #endif - #if(!defined(CUDART_VERSION) || CUDART_VERSION < 11000) /*! \ingroup level3_module * \brief Sparse matrix dense matrix multiplication using CSR storage format diff --git a/library/include/level3/hipsparse_csrsm.h b/library/include/level3/hipsparse_csrsm.h index a725bed8..87d00cc4 100644 --- a/library/include/level3/hipsparse_csrsm.h +++ b/library/include/level3/hipsparse_csrsm.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/level3/hipsparse_gemmi.h b/library/include/level3/hipsparse_gemmi.h index aa377338..09aea259 100644 --- a/library/include/level3/hipsparse_gemmi.h +++ b/library/include/level3/hipsparse_gemmi.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_bsric0.h b/library/include/precond/hipsparse_bsric0.h index ba95948b..59d9e788 100644 --- a/library/include/precond/hipsparse_bsric0.h +++ b/library/include/precond/hipsparse_bsric0.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_bsrilu0.h b/library/include/precond/hipsparse_bsrilu0.h index 281c4c64..be641664 100644 --- a/library/include/precond/hipsparse_bsrilu0.h +++ b/library/include/precond/hipsparse_bsrilu0.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_csric0.h b/library/include/precond/hipsparse_csric0.h index 2fdce72d..b7f974c3 100644 --- a/library/include/precond/hipsparse_csric0.h +++ b/library/include/precond/hipsparse_csric0.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_csrilu0.h b/library/include/precond/hipsparse_csrilu0.h index 2471e3cc..09e8e106 100644 --- a/library/include/precond/hipsparse_csrilu0.h +++ b/library/include/precond/hipsparse_csrilu0.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gpsv_interleaved_batch.h b/library/include/precond/hipsparse_gpsv_interleaved_batch.h index 3d72d198..6b46b033 100644 --- a/library/include/precond/hipsparse_gpsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gpsv_interleaved_batch.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv.h b/library/include/precond/hipsparse_gtsv.h index 62dab298..c4ded098 100644 --- a/library/include/precond/hipsparse_gtsv.h +++ b/library/include/precond/hipsparse_gtsv.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv_interleaved_batch.h b/library/include/precond/hipsparse_gtsv_interleaved_batch.h index 12f5505d..03419d85 100644 --- a/library/include/precond/hipsparse_gtsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gtsv_interleaved_batch.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv_nopivot.h b/library/include/precond/hipsparse_gtsv_nopivot.h index 4740d7c2..5bfa3aa5 100644 --- a/library/include/precond/hipsparse_gtsv_nopivot.h +++ b/library/include/precond/hipsparse_gtsv_nopivot.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/precond/hipsparse_gtsv_strided_batch.h b/library/include/precond/hipsparse_gtsv_strided_batch.h index a1afe5a1..904c127a 100644 --- a/library/include/precond/hipsparse_gtsv_strided_batch.h +++ b/library/include/precond/hipsparse_gtsv_strided_batch.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif diff --git a/library/include/reorder/hipsparse_csrcolor.h b/library/include/reorder/hipsparse_csrcolor.h index 462c3428..aef34bee 100644 --- a/library/include/reorder/hipsparse_csrcolor.h +++ b/library/include/reorder/hipsparse_csrcolor.h @@ -23,7 +23,6 @@ * ************************************************************************ */ #pragma once - #ifdef __cplusplus extern "C" { #endif From d95265388def3b35d9134f6270a9eab39b96cfe8 Mon Sep 17 00:00:00 2001 From: jsandham Date: Thu, 18 Apr 2024 21:27:09 +0000 Subject: [PATCH 4/8] Ensure all include header files are copied to install idrectory --- library/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 6d5665cb..58f1d8ff 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -35,8 +35,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/hipsparse-version.h.in" "${PROJECT_BINARY_DIR}/include/hipsparse/hipsparse-version.h") # Copy Header files to build directory -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/hipsparse.h" - "${PROJECT_BINARY_DIR}/include/hipsparse/hipsparse.h" COPYONLY) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include/hipsparse") # Public hipSPARSE headers set(hipsparse_headers_public From fe1acb02d8cfd2f61519c260b673225fcbc313f7 Mon Sep 17 00:00:00 2001 From: jsandham Date: Thu, 18 Apr 2024 21:46:30 +0000 Subject: [PATCH 5/8] Fix compilation error --- library/include/hipsparse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/include/hipsparse.h b/library/include/hipsparse.h index c0c8d32d..e28a927e 100644 --- a/library/include/hipsparse.h +++ b/library/include/hipsparse.h @@ -85,8 +85,8 @@ #endif #endif -#include "hipsparse_auxiliary.h" #include "hipsparse_types.h" +#include "hipsparse_auxiliary.h" /* * =========================================================================== From 1e52fd0546130aab00d3894fa8e71ecf85bf2dd0 Mon Sep 17 00:00:00 2001 From: jsandham Date: Thu, 18 Apr 2024 22:02:47 +0000 Subject: [PATCH 6/8] Clang formatting --- library/include/hipsparse.h | 1 + 1 file changed, 1 insertion(+) diff --git a/library/include/hipsparse.h b/library/include/hipsparse.h index e28a927e..ba6a5bfd 100644 --- a/library/include/hipsparse.h +++ b/library/include/hipsparse.h @@ -86,6 +86,7 @@ #endif #include "hipsparse_types.h" + #include "hipsparse_auxiliary.h" /* From 9ca01e75d40dc784cc5912a67dc3d507d58ce18c Mon Sep 17 00:00:00 2001 From: jsandham Date: Mon, 22 Apr 2024 22:43:16 +0000 Subject: [PATCH 7/8] Ensure newline exists at the end of header files --- library/include/conversion/hipsparse_bsr2csr.h | 2 +- library/include/conversion/hipsparse_coo2csr.h | 2 +- library/include/conversion/hipsparse_coosort.h | 2 +- .../include/conversion/hipsparse_create_identity_permutation.h | 2 +- library/include/conversion/hipsparse_csc2dense.h | 2 +- library/include/conversion/hipsparse_cscsort.h | 2 +- library/include/conversion/hipsparse_csr2bsr.h | 2 +- library/include/conversion/hipsparse_csr2coo.h | 2 +- library/include/conversion/hipsparse_csr2csc.h | 2 +- library/include/conversion/hipsparse_csr2csr_compress.h | 2 +- library/include/conversion/hipsparse_csr2csru.h | 2 +- library/include/conversion/hipsparse_csr2dense.h | 2 +- library/include/conversion/hipsparse_csr2gebsr.h | 2 +- library/include/conversion/hipsparse_csr2hyb.h | 2 +- library/include/conversion/hipsparse_csrsort.h | 2 +- library/include/conversion/hipsparse_csru2csr.h | 2 +- library/include/conversion/hipsparse_dense2csc.h | 2 +- library/include/conversion/hipsparse_dense2csr.h | 2 +- library/include/conversion/hipsparse_gebsr2gebsc.h | 2 +- library/include/conversion/hipsparse_gebsr2gebsr.h | 2 +- library/include/conversion/hipsparse_hyb2csr.h | 2 +- library/include/conversion/hipsparse_nnz.h | 2 +- library/include/conversion/hipsparse_nnz_compress.h | 2 +- library/include/conversion/hipsparse_prune_csr2csr.h | 2 +- .../include/conversion/hipsparse_prune_csr2csr_by_percentage.h | 2 +- library/include/conversion/hipsparse_prune_dense2csr.h | 2 +- .../conversion/hipsparse_prune_dense2csr_by_percentage.h | 2 +- library/include/extra/hipsparse_csrgeam.h | 2 +- library/include/extra/hipsparse_csrgemm.h | 2 +- library/include/generic/hipsparse_axpby.h | 2 +- library/include/generic/hipsparse_dense2sparse.h | 2 +- library/include/generic/hipsparse_gather.h | 2 +- library/include/generic/hipsparse_rot.h | 2 +- library/include/generic/hipsparse_scatter.h | 2 +- library/include/generic/hipsparse_sddmm.h | 2 +- library/include/generic/hipsparse_sparse2dense.h | 2 +- library/include/generic/hipsparse_spgemm.h | 2 +- library/include/generic/hipsparse_spgemm_reuse.h | 2 +- library/include/generic/hipsparse_spmm.h | 2 +- library/include/generic/hipsparse_spmv.h | 2 +- library/include/generic/hipsparse_spsm.h | 2 +- library/include/generic/hipsparse_spsv.h | 2 +- library/include/generic/hipsparse_spvv.h | 2 +- library/include/hipsparse_auxiliary.h | 2 +- library/include/hipsparse_generic_auxiliary.h | 2 +- library/include/hipsparse_generic_types.h | 2 +- library/include/level1/hipsparse_axpyi.h | 2 +- library/include/level1/hipsparse_dotci.h | 2 +- library/include/level1/hipsparse_doti.h | 2 +- library/include/level1/hipsparse_gthr.h | 2 +- library/include/level1/hipsparse_gthrz.h | 2 +- library/include/level1/hipsparse_roti.h | 2 +- library/include/level1/hipsparse_sctr.h | 2 +- library/include/level2/hipsparse_bsrmv.h | 2 +- library/include/level2/hipsparse_bsrsv.h | 2 +- library/include/level2/hipsparse_bsrxmv.h | 2 +- library/include/level2/hipsparse_csrmv.h | 2 +- library/include/level2/hipsparse_csrsv.h | 2 +- library/include/level2/hipsparse_gemvi.h | 2 +- library/include/level2/hipsparse_hybmv.h | 2 +- library/include/level3/hipsparse_bsrmm.h | 2 +- library/include/level3/hipsparse_bsrsm.h | 2 +- library/include/level3/hipsparse_csrmm.h | 2 +- library/include/level3/hipsparse_csrsm.h | 2 +- library/include/level3/hipsparse_gemmi.h | 2 +- library/include/precond/hipsparse_bsric0.h | 2 +- library/include/precond/hipsparse_bsrilu0.h | 2 +- library/include/precond/hipsparse_csric0.h | 2 +- library/include/precond/hipsparse_csrilu0.h | 2 +- library/include/precond/hipsparse_gpsv_interleaved_batch.h | 2 +- library/include/precond/hipsparse_gtsv.h | 2 +- library/include/precond/hipsparse_gtsv_interleaved_batch.h | 2 +- library/include/precond/hipsparse_gtsv_nopivot.h | 2 +- library/include/precond/hipsparse_gtsv_strided_batch.h | 2 +- library/include/reorder/hipsparse_csrcolor.h | 2 +- 75 files changed, 75 insertions(+), 75 deletions(-) diff --git a/library/include/conversion/hipsparse_bsr2csr.h b/library/include/conversion/hipsparse_bsr2csr.h index 5b8422f2..916a9986 100644 --- a/library/include/conversion/hipsparse_bsr2csr.h +++ b/library/include/conversion/hipsparse_bsr2csr.h @@ -102,4 +102,4 @@ hipsparseStatus_t hipsparseZbsr2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_coo2csr.h b/library/include/conversion/hipsparse_coo2csr.h index 8039b50d..0e5fec29 100644 --- a/library/include/conversion/hipsparse_coo2csr.h +++ b/library/include/conversion/hipsparse_coo2csr.h @@ -53,4 +53,4 @@ hipsparseStatus_t hipsparseXcoo2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_coosort.h b/library/include/conversion/hipsparse_coosort.h index 564580bd..70ce281d 100644 --- a/library/include/conversion/hipsparse_coosort.h +++ b/library/include/conversion/hipsparse_coosort.h @@ -106,4 +106,4 @@ hipsparseStatus_t hipsparseXcoosortByColumn(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_create_identity_permutation.h b/library/include/conversion/hipsparse_create_identity_permutation.h index 9c553be7..268f619d 100644 --- a/library/include/conversion/hipsparse_create_identity_permutation.h +++ b/library/include/conversion/hipsparse_create_identity_permutation.h @@ -53,4 +53,4 @@ hipsparseStatus_t hipsparseCreateIdentityPermutation(hipsparseHandle_t handle, i #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csc2dense.h b/library/include/conversion/hipsparse_csc2dense.h index 282bb765..a0d410c1 100644 --- a/library/include/conversion/hipsparse_csc2dense.h +++ b/library/include/conversion/hipsparse_csc2dense.h @@ -83,4 +83,4 @@ hipsparseStatus_t hipsparseZcsc2dense(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_cscsort.h b/library/include/conversion/hipsparse_cscsort.h index 2dfb1a6b..167941e7 100644 --- a/library/include/conversion/hipsparse_cscsort.h +++ b/library/include/conversion/hipsparse_cscsort.h @@ -75,4 +75,4 @@ hipsparseStatus_t hipsparseXcscsort(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2bsr.h b/library/include/conversion/hipsparse_csr2bsr.h index 146c93ff..f9ef094b 100644 --- a/library/include/conversion/hipsparse_csr2bsr.h +++ b/library/include/conversion/hipsparse_csr2bsr.h @@ -123,4 +123,4 @@ hipsparseStatus_t hipsparseZcsr2bsr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2coo.h b/library/include/conversion/hipsparse_csr2coo.h index e803803a..193da194 100644 --- a/library/include/conversion/hipsparse_csr2coo.h +++ b/library/include/conversion/hipsparse_csr2coo.h @@ -52,4 +52,4 @@ hipsparseStatus_t hipsparseXcsr2coo(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2csc.h b/library/include/conversion/hipsparse_csr2csc.h index 21b0350d..a602ec24 100644 --- a/library/include/conversion/hipsparse_csr2csc.h +++ b/library/include/conversion/hipsparse_csr2csc.h @@ -208,4 +208,4 @@ hipsparseStatus_t hipsparseCsr2cscEx2(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2csr_compress.h b/library/include/conversion/hipsparse_csr2csr_compress.h index 01010d0d..6d85a0b2 100644 --- a/library/include/conversion/hipsparse_csr2csr_compress.h +++ b/library/include/conversion/hipsparse_csr2csr_compress.h @@ -98,4 +98,4 @@ hipsparseStatus_t hipsparseZcsr2csr_compress(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2csru.h b/library/include/conversion/hipsparse_csr2csru.h index b8cf3f4b..d864b1c1 100644 --- a/library/include/conversion/hipsparse_csr2csru.h +++ b/library/include/conversion/hipsparse_csr2csru.h @@ -90,4 +90,4 @@ hipsparseStatus_t hipsparseZcsr2csru(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2dense.h b/library/include/conversion/hipsparse_csr2dense.h index 8794b21e..81060a24 100644 --- a/library/include/conversion/hipsparse_csr2dense.h +++ b/library/include/conversion/hipsparse_csr2dense.h @@ -83,4 +83,4 @@ hipsparseStatus_t hipsparseZcsr2dense(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2gebsr.h b/library/include/conversion/hipsparse_csr2gebsr.h index 468cc885..d3f66b98 100644 --- a/library/include/conversion/hipsparse_csr2gebsr.h +++ b/library/include/conversion/hipsparse_csr2gebsr.h @@ -197,4 +197,4 @@ hipsparseStatus_t hipsparseZcsr2gebsr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csr2hyb.h b/library/include/conversion/hipsparse_csr2hyb.h index 4aa639ed..b466037c 100644 --- a/library/include/conversion/hipsparse_csr2hyb.h +++ b/library/include/conversion/hipsparse_csr2hyb.h @@ -97,4 +97,4 @@ hipsparseStatus_t hipsparseZcsr2hyb(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csrsort.h b/library/include/conversion/hipsparse_csrsort.h index bd88dbfa..613f4dcf 100644 --- a/library/include/conversion/hipsparse_csrsort.h +++ b/library/include/conversion/hipsparse_csrsort.h @@ -75,4 +75,4 @@ hipsparseStatus_t hipsparseXcsrsort(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_csru2csr.h b/library/include/conversion/hipsparse_csru2csr.h index 56211e4b..9131b29c 100644 --- a/library/include/conversion/hipsparse_csru2csr.h +++ b/library/include/conversion/hipsparse_csru2csr.h @@ -147,4 +147,4 @@ hipsparseStatus_t hipsparseZcsru2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_dense2csc.h b/library/include/conversion/hipsparse_dense2csc.h index f24a186e..e1dff57b 100644 --- a/library/include/conversion/hipsparse_dense2csc.h +++ b/library/include/conversion/hipsparse_dense2csc.h @@ -89,4 +89,4 @@ hipsparseStatus_t hipsparseZdense2csc(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_dense2csr.h b/library/include/conversion/hipsparse_dense2csr.h index 8518c2b2..41040c64 100644 --- a/library/include/conversion/hipsparse_dense2csr.h +++ b/library/include/conversion/hipsparse_dense2csr.h @@ -87,4 +87,4 @@ hipsparseStatus_t hipsparseZdense2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsc.h b/library/include/conversion/hipsparse_gebsr2gebsc.h index 3b02f48f..0d2319aa 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsc.h +++ b/library/include/conversion/hipsparse_gebsr2gebsc.h @@ -174,4 +174,4 @@ hipsparseStatus_t hipsparseZgebsr2gebsc(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_gebsr2gebsr.h b/library/include/conversion/hipsparse_gebsr2gebsr.h index dd046596..aa08d026 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsr.h +++ b/library/include/conversion/hipsparse_gebsr2gebsr.h @@ -226,4 +226,4 @@ hipsparseStatus_t hipsparseZgebsr2gebsr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_hyb2csr.h b/library/include/conversion/hipsparse_hyb2csr.h index 47ca3801..729f22aa 100644 --- a/library/include/conversion/hipsparse_hyb2csr.h +++ b/library/include/conversion/hipsparse_hyb2csr.h @@ -76,4 +76,4 @@ hipsparseStatus_t hipsparseZhyb2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_nnz.h b/library/include/conversion/hipsparse_nnz.h index 6fc56af8..ea9cba15 100644 --- a/library/include/conversion/hipsparse_nnz.h +++ b/library/include/conversion/hipsparse_nnz.h @@ -83,4 +83,4 @@ hipsparseStatus_t hipsparseZnnz(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_nnz_compress.h b/library/include/conversion/hipsparse_nnz_compress.h index 70083f1e..e69a10f7 100644 --- a/library/include/conversion/hipsparse_nnz_compress.h +++ b/library/include/conversion/hipsparse_nnz_compress.h @@ -82,4 +82,4 @@ hipsparseStatus_t hipsparseZnnz_compress(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_prune_csr2csr.h b/library/include/conversion/hipsparse_prune_csr2csr.h index a7d4c11f..38d57e97 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr.h +++ b/library/include/conversion/hipsparse_prune_csr2csr.h @@ -215,4 +215,4 @@ hipsparseStatus_t hipsparseDpruneCsr2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h index 1d72b3a0..f9aea701 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h @@ -226,4 +226,4 @@ hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage(hipsparseHandle_t h #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_prune_dense2csr.h b/library/include/conversion/hipsparse_prune_dense2csr.h index da97e467..4c6b163b 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr.h +++ b/library/include/conversion/hipsparse_prune_dense2csr.h @@ -187,4 +187,4 @@ hipsparseStatus_t hipsparseDpruneDense2csr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h index 4a03fcd8..09415d9d 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h @@ -276,4 +276,4 @@ hipsparseStatus_t hipsparseDpruneDense2csrByPercentage(hipsparseHandle_t #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/extra/hipsparse_csrgeam.h b/library/include/extra/hipsparse_csrgeam.h index 6ae44ff0..2f8242a7 100644 --- a/library/include/extra/hipsparse_csrgeam.h +++ b/library/include/extra/hipsparse_csrgeam.h @@ -419,4 +419,4 @@ hipsparseStatus_t hipsparseZcsrgeam2(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/extra/hipsparse_csrgemm.h b/library/include/extra/hipsparse_csrgemm.h index f91d2119..8fe0f0f1 100644 --- a/library/include/extra/hipsparse_csrgemm.h +++ b/library/include/extra/hipsparse_csrgemm.h @@ -522,4 +522,4 @@ hipsparseStatus_t hipsparseZcsrgemm2(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_axpby.h b/library/include/generic/hipsparse_axpby.h index ae5329d5..e1366f95 100644 --- a/library/include/generic/hipsparse_axpby.h +++ b/library/include/generic/hipsparse_axpby.h @@ -137,4 +137,4 @@ hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_dense2sparse.h b/library/include/generic/hipsparse_dense2sparse.h index 1334bce5..e4236762 100644 --- a/library/include/generic/hipsparse_dense2sparse.h +++ b/library/include/generic/hipsparse_dense2sparse.h @@ -99,4 +99,4 @@ hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t han #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_gather.h b/library/include/generic/hipsparse_gather.h index c3df4e4b..5ad5865f 100644 --- a/library/include/generic/hipsparse_gather.h +++ b/library/include/generic/hipsparse_gather.h @@ -118,4 +118,4 @@ hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_rot.h b/library/include/generic/hipsparse_rot.h index 52427c97..644a9377 100644 --- a/library/include/generic/hipsparse_rot.h +++ b/library/include/generic/hipsparse_rot.h @@ -134,4 +134,4 @@ hipsparseStatus_t hipsparseRot(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_scatter.h b/library/include/generic/hipsparse_scatter.h index 5371f191..1d1d094f 100644 --- a/library/include/generic/hipsparse_scatter.h +++ b/library/include/generic/hipsparse_scatter.h @@ -121,4 +121,4 @@ hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_sddmm.h b/library/include/generic/hipsparse_sddmm.h index 11f570d6..6de9492c 100644 --- a/library/include/generic/hipsparse_sddmm.h +++ b/library/include/generic/hipsparse_sddmm.h @@ -165,4 +165,4 @@ hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_sparse2dense.h b/library/include/generic/hipsparse_sparse2dense.h index 1faebf73..ce199031 100644 --- a/library/include/generic/hipsparse_sparse2dense.h +++ b/library/include/generic/hipsparse_sparse2dense.h @@ -75,4 +75,4 @@ hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spgemm.h b/library/include/generic/hipsparse_spgemm.h index 3c7f94f3..00c3b6aa 100644 --- a/library/include/generic/hipsparse_spgemm.h +++ b/library/include/generic/hipsparse_spgemm.h @@ -298,4 +298,4 @@ hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spgemm_reuse.h b/library/include/generic/hipsparse_spgemm_reuse.h index b81fa3d4..7996d634 100644 --- a/library/include/generic/hipsparse_spgemm_reuse.h +++ b/library/include/generic/hipsparse_spgemm_reuse.h @@ -425,4 +425,4 @@ hipsparseStatus_t hipsparseSpGEMMreuse_compute(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spmm.h b/library/include/generic/hipsparse_spmm.h index 4ba4e599..31f53ac7 100644 --- a/library/include/generic/hipsparse_spmm.h +++ b/library/include/generic/hipsparse_spmm.h @@ -255,4 +255,4 @@ hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spmv.h b/library/include/generic/hipsparse_spmv.h index 405ee180..44cbe063 100644 --- a/library/include/generic/hipsparse_spmv.h +++ b/library/include/generic/hipsparse_spmv.h @@ -243,4 +243,4 @@ hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spsm.h b/library/include/generic/hipsparse_spsm.h index 94797fe2..f62fed23 100644 --- a/library/include/generic/hipsparse_spsm.h +++ b/library/include/generic/hipsparse_spsm.h @@ -184,4 +184,4 @@ hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spsv.h b/library/include/generic/hipsparse_spsv.h index 5451a86a..6f2e8284 100644 --- a/library/include/generic/hipsparse_spsv.h +++ b/library/include/generic/hipsparse_spsv.h @@ -166,4 +166,4 @@ hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/generic/hipsparse_spvv.h b/library/include/generic/hipsparse_spvv.h index a57aaadf..6d3f9a3a 100644 --- a/library/include/generic/hipsparse_spvv.h +++ b/library/include/generic/hipsparse_spvv.h @@ -171,4 +171,4 @@ hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/hipsparse_auxiliary.h b/library/include/hipsparse_auxiliary.h index 79d1af30..fe961eed 100644 --- a/library/include/hipsparse_auxiliary.h +++ b/library/include/hipsparse_auxiliary.h @@ -586,4 +586,4 @@ hipsparseStatus_t hipsparseDestroyPruneInfo(pruneInfo_t info); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/hipsparse_generic_auxiliary.h b/library/include/hipsparse_generic_auxiliary.h index c42b504e..afb2c4d9 100644 --- a/library/include/hipsparse_generic_auxiliary.h +++ b/library/include/hipsparse_generic_auxiliary.h @@ -950,4 +950,4 @@ hipsparseStatus_t hipsparseDnMatSetStridedBatch(hipsparseDnMatDescr_t dnMatDescr #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/hipsparse_generic_types.h b/library/include/hipsparse_generic_types.h index d04b09d4..ef29e237 100644 --- a/library/include/hipsparse_generic_types.h +++ b/library/include/hipsparse_generic_types.h @@ -536,4 +536,4 @@ typedef enum HIPSPARSE_SPGEMM_DEFAULT = 0 } hipsparseSpGEMMAlg_t; #endif -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_axpyi.h b/library/include/level1/hipsparse_axpyi.h index f59aa6fd..d73dee18 100644 --- a/library/include/level1/hipsparse_axpyi.h +++ b/library/include/level1/hipsparse_axpyi.h @@ -144,4 +144,4 @@ hipsparseStatus_t hipsparseZaxpyi(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_dotci.h b/library/include/level1/hipsparse_dotci.h index 2cbfb079..8c1495aa 100644 --- a/library/include/level1/hipsparse_dotci.h +++ b/library/include/level1/hipsparse_dotci.h @@ -74,4 +74,4 @@ hipsparseStatus_t hipsparseZdotci(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_doti.h b/library/include/level1/hipsparse_doti.h index eb8b6098..86123d64 100644 --- a/library/include/level1/hipsparse_doti.h +++ b/library/include/level1/hipsparse_doti.h @@ -138,4 +138,4 @@ hipsparseStatus_t hipsparseZdoti(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_gthr.h b/library/include/level1/hipsparse_gthr.h index 3dc96989..75bbddb2 100644 --- a/library/include/level1/hipsparse_gthr.h +++ b/library/include/level1/hipsparse_gthr.h @@ -132,4 +132,4 @@ hipsparseStatus_t hipsparseZgthr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_gthrz.h b/library/include/level1/hipsparse_gthrz.h index dfc013fa..cc461eaf 100644 --- a/library/include/level1/hipsparse_gthrz.h +++ b/library/include/level1/hipsparse_gthrz.h @@ -88,4 +88,4 @@ hipsparseStatus_t hipsparseZgthrz(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_roti.h b/library/include/level1/hipsparse_roti.h index 5b266488..fea00fb4 100644 --- a/library/include/level1/hipsparse_roti.h +++ b/library/include/level1/hipsparse_roti.h @@ -133,4 +133,4 @@ hipsparseStatus_t hipsparseDroti(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level1/hipsparse_sctr.h b/library/include/level1/hipsparse_sctr.h index a1d03128..b6016acb 100644 --- a/library/include/level1/hipsparse_sctr.h +++ b/library/include/level1/hipsparse_sctr.h @@ -134,4 +134,4 @@ hipsparseStatus_t hipsparseZsctr(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_bsrmv.h b/library/include/level2/hipsparse_bsrmv.h index 6463cb9e..3cc77333 100644 --- a/library/include/level2/hipsparse_bsrmv.h +++ b/library/include/level2/hipsparse_bsrmv.h @@ -226,4 +226,4 @@ hipsparseStatus_t hipsparseZbsrmv(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_bsrsv.h b/library/include/level2/hipsparse_bsrsv.h index eef9fde2..65f801ac 100644 --- a/library/include/level2/hipsparse_bsrsv.h +++ b/library/include/level2/hipsparse_bsrsv.h @@ -547,4 +547,4 @@ hipsparseStatus_t hipsparseZbsrsv2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_bsrxmv.h b/library/include/level2/hipsparse_bsrxmv.h index 87c458f4..b9fd0616 100644 --- a/library/include/level2/hipsparse_bsrxmv.h +++ b/library/include/level2/hipsparse_bsrxmv.h @@ -149,4 +149,4 @@ hipsparseStatus_t hipsparseZbsrxmv(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_csrmv.h b/library/include/level2/hipsparse_csrmv.h index 6ed39d70..096d16f9 100644 --- a/library/include/level2/hipsparse_csrmv.h +++ b/library/include/level2/hipsparse_csrmv.h @@ -223,4 +223,4 @@ hipsparseStatus_t hipsparseZcsrmv(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_csrsv.h b/library/include/level2/hipsparse_csrsv.h index 40044f9c..7b4372f3 100644 --- a/library/include/level2/hipsparse_csrsv.h +++ b/library/include/level2/hipsparse_csrsv.h @@ -480,4 +480,4 @@ hipsparseStatus_t hipsparseZcsrsv2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_gemvi.h b/library/include/level2/hipsparse_gemvi.h index f2d2a83c..a33c17a6 100644 --- a/library/include/level2/hipsparse_gemvi.h +++ b/library/include/level2/hipsparse_gemvi.h @@ -168,4 +168,4 @@ hipsparseStatus_t hipsparseZgemvi(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level2/hipsparse_hybmv.h b/library/include/level2/hipsparse_hybmv.h index c3e5e3a8..a07cc914 100644 --- a/library/include/level2/hipsparse_hybmv.h +++ b/library/include/level2/hipsparse_hybmv.h @@ -176,4 +176,4 @@ hipsparseStatus_t hipsparseZhybmv(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level3/hipsparse_bsrmm.h b/library/include/level3/hipsparse_bsrmm.h index 60f6e0e3..a4474e93 100644 --- a/library/include/level3/hipsparse_bsrmm.h +++ b/library/include/level3/hipsparse_bsrmm.h @@ -238,4 +238,4 @@ hipsparseStatus_t hipsparseZbsrmm(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level3/hipsparse_bsrsm.h b/library/include/level3/hipsparse_bsrsm.h index bb24af6b..82c2d5d3 100644 --- a/library/include/level3/hipsparse_bsrsm.h +++ b/library/include/level3/hipsparse_bsrsm.h @@ -553,4 +553,4 @@ hipsparseStatus_t hipsparseZbsrsm2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level3/hipsparse_csrmm.h b/library/include/level3/hipsparse_csrmm.h index 2abe2e96..77fcd4b5 100644 --- a/library/include/level3/hipsparse_csrmm.h +++ b/library/include/level3/hipsparse_csrmm.h @@ -362,4 +362,4 @@ hipsparseStatus_t hipsparseZcsrmm2(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level3/hipsparse_csrsm.h b/library/include/level3/hipsparse_csrsm.h index 87d00cc4..49ce5aad 100644 --- a/library/include/level3/hipsparse_csrsm.h +++ b/library/include/level3/hipsparse_csrsm.h @@ -538,4 +538,4 @@ hipsparseStatus_t hipsparseZcsrsm2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/level3/hipsparse_gemmi.h b/library/include/level3/hipsparse_gemmi.h index 09aea259..11b6236a 100644 --- a/library/include/level3/hipsparse_gemmi.h +++ b/library/include/level3/hipsparse_gemmi.h @@ -134,4 +134,4 @@ hipsparseStatus_t hipsparseZgemmi(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_bsric0.h b/library/include/precond/hipsparse_bsric0.h index 59d9e788..0270ec3c 100644 --- a/library/include/precond/hipsparse_bsric0.h +++ b/library/include/precond/hipsparse_bsric0.h @@ -280,4 +280,4 @@ hipsparseStatus_t hipsparseZbsric02(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_bsrilu0.h b/library/include/precond/hipsparse_bsrilu0.h index be641664..738483d3 100644 --- a/library/include/precond/hipsparse_bsrilu0.h +++ b/library/include/precond/hipsparse_bsrilu0.h @@ -336,4 +336,4 @@ hipsparseStatus_t hipsparseZbsrilu02(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_csric0.h b/library/include/precond/hipsparse_csric0.h index b7f974c3..b10bf7a7 100644 --- a/library/include/precond/hipsparse_csric0.h +++ b/library/include/precond/hipsparse_csric0.h @@ -313,4 +313,4 @@ hipsparseStatus_t hipsparseZcsric02(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_csrilu0.h b/library/include/precond/hipsparse_csrilu0.h index 09e8e106..42f40ca2 100644 --- a/library/include/precond/hipsparse_csrilu0.h +++ b/library/include/precond/hipsparse_csrilu0.h @@ -363,4 +363,4 @@ hipsparseStatus_t hipsparseZcsrilu02(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_gpsv_interleaved_batch.h b/library/include/precond/hipsparse_gpsv_interleaved_batch.h index 6b46b033..18920e07 100644 --- a/library/include/precond/hipsparse_gpsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gpsv_interleaved_batch.h @@ -157,4 +157,4 @@ hipsparseStatus_t hipsparseZgpsvInterleavedBatch(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_gtsv.h b/library/include/precond/hipsparse_gtsv.h index c4ded098..a222b09b 100644 --- a/library/include/precond/hipsparse_gtsv.h +++ b/library/include/precond/hipsparse_gtsv.h @@ -139,4 +139,4 @@ hipsparseStatus_t hipsparseZgtsv2(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_gtsv_interleaved_batch.h b/library/include/precond/hipsparse_gtsv_interleaved_batch.h index 03419d85..9014b986 100644 --- a/library/include/precond/hipsparse_gtsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gtsv_interleaved_batch.h @@ -139,4 +139,4 @@ hipsparseStatus_t hipsparseZgtsvInterleavedBatch(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_gtsv_nopivot.h b/library/include/precond/hipsparse_gtsv_nopivot.h index 5bfa3aa5..d3389da5 100644 --- a/library/include/precond/hipsparse_gtsv_nopivot.h +++ b/library/include/precond/hipsparse_gtsv_nopivot.h @@ -139,4 +139,4 @@ hipsparseStatus_t hipsparseZgtsv2_nopivot(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/precond/hipsparse_gtsv_strided_batch.h b/library/include/precond/hipsparse_gtsv_strided_batch.h index 904c127a..4c21b26e 100644 --- a/library/include/precond/hipsparse_gtsv_strided_batch.h +++ b/library/include/precond/hipsparse_gtsv_strided_batch.h @@ -139,4 +139,4 @@ hipsparseStatus_t hipsparseZgtsv2StridedBatch(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/library/include/reorder/hipsparse_csrcolor.h b/library/include/reorder/hipsparse_csrcolor.h index aef34bee..29a91e37 100644 --- a/library/include/reorder/hipsparse_csrcolor.h +++ b/library/include/reorder/hipsparse_csrcolor.h @@ -99,4 +99,4 @@ hipsparseStatus_t hipsparseZcsrcolor(hipsparseHandle_t handle, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif From b42094ca6b0f516cb942976e31023f23bf0c921a Mon Sep 17 00:00:00 2001 From: jsandham Date: Mon, 22 Apr 2024 22:46:39 +0000 Subject: [PATCH 8/8] Dont use pragma once in public headers --- library/include/conversion/hipsparse_bsr2csr.h | 5 ++++- library/include/conversion/hipsparse_coo2csr.h | 5 ++++- library/include/conversion/hipsparse_coosort.h | 5 ++++- .../conversion/hipsparse_create_identity_permutation.h | 5 ++++- library/include/conversion/hipsparse_csc2dense.h | 5 ++++- library/include/conversion/hipsparse_cscsort.h | 5 ++++- library/include/conversion/hipsparse_csr2bsr.h | 5 ++++- library/include/conversion/hipsparse_csr2coo.h | 5 ++++- library/include/conversion/hipsparse_csr2csc.h | 5 ++++- library/include/conversion/hipsparse_csr2csr_compress.h | 5 ++++- library/include/conversion/hipsparse_csr2csru.h | 5 ++++- library/include/conversion/hipsparse_csr2dense.h | 5 ++++- library/include/conversion/hipsparse_csr2gebsr.h | 5 ++++- library/include/conversion/hipsparse_csr2hyb.h | 5 ++++- library/include/conversion/hipsparse_csrsort.h | 5 ++++- library/include/conversion/hipsparse_csru2csr.h | 5 ++++- library/include/conversion/hipsparse_dense2csc.h | 5 ++++- library/include/conversion/hipsparse_dense2csr.h | 5 ++++- library/include/conversion/hipsparse_gebsr2csr.h | 5 ++++- library/include/conversion/hipsparse_gebsr2gebsc.h | 5 ++++- library/include/conversion/hipsparse_gebsr2gebsr.h | 5 ++++- library/include/conversion/hipsparse_hyb2csr.h | 5 ++++- library/include/conversion/hipsparse_nnz.h | 5 ++++- library/include/conversion/hipsparse_nnz_compress.h | 5 ++++- library/include/conversion/hipsparse_prune_csr2csr.h | 5 ++++- .../conversion/hipsparse_prune_csr2csr_by_percentage.h | 5 ++++- library/include/conversion/hipsparse_prune_dense2csr.h | 5 ++++- .../conversion/hipsparse_prune_dense2csr_by_percentage.h | 5 ++++- library/include/extra/hipsparse_csrgeam.h | 5 ++++- library/include/extra/hipsparse_csrgemm.h | 5 ++++- library/include/generic/hipsparse_axpby.h | 5 ++++- library/include/generic/hipsparse_dense2sparse.h | 5 ++++- library/include/generic/hipsparse_gather.h | 5 ++++- library/include/generic/hipsparse_rot.h | 5 ++++- library/include/generic/hipsparse_scatter.h | 5 ++++- library/include/generic/hipsparse_sddmm.h | 5 ++++- library/include/generic/hipsparse_sparse2dense.h | 5 ++++- library/include/generic/hipsparse_spgemm.h | 5 ++++- library/include/generic/hipsparse_spgemm_reuse.h | 5 ++++- library/include/generic/hipsparse_spmm.h | 5 ++++- library/include/generic/hipsparse_spmv.h | 5 ++++- library/include/generic/hipsparse_spsm.h | 5 ++++- library/include/generic/hipsparse_spsv.h | 5 ++++- library/include/generic/hipsparse_spvv.h | 5 ++++- library/include/hipsparse_auxiliary.h | 5 ++++- library/include/hipsparse_generic_auxiliary.h | 5 ++++- library/include/hipsparse_generic_types.h | 5 ++++- library/include/hipsparse_types.h | 5 ++++- library/include/level1/hipsparse_axpyi.h | 5 ++++- library/include/level1/hipsparse_dotci.h | 5 ++++- library/include/level1/hipsparse_doti.h | 5 ++++- library/include/level1/hipsparse_gthr.h | 5 ++++- library/include/level1/hipsparse_gthrz.h | 5 ++++- library/include/level1/hipsparse_roti.h | 5 ++++- library/include/level1/hipsparse_sctr.h | 5 ++++- library/include/level2/hipsparse_bsrmv.h | 5 ++++- library/include/level2/hipsparse_bsrsv.h | 5 ++++- library/include/level2/hipsparse_bsrxmv.h | 5 ++++- library/include/level2/hipsparse_csrmv.h | 5 ++++- library/include/level2/hipsparse_csrsv.h | 5 ++++- library/include/level2/hipsparse_gemvi.h | 5 ++++- library/include/level2/hipsparse_hybmv.h | 5 ++++- library/include/level3/hipsparse_bsrmm.h | 5 ++++- library/include/level3/hipsparse_bsrsm.h | 5 ++++- library/include/level3/hipsparse_csrmm.h | 5 ++++- library/include/level3/hipsparse_csrsm.h | 5 ++++- library/include/level3/hipsparse_gemmi.h | 5 ++++- library/include/precond/hipsparse_bsric0.h | 5 ++++- library/include/precond/hipsparse_bsrilu0.h | 5 ++++- library/include/precond/hipsparse_csric0.h | 5 ++++- library/include/precond/hipsparse_csrilu0.h | 5 ++++- library/include/precond/hipsparse_gpsv_interleaved_batch.h | 5 ++++- library/include/precond/hipsparse_gtsv.h | 5 ++++- library/include/precond/hipsparse_gtsv_interleaved_batch.h | 5 ++++- library/include/precond/hipsparse_gtsv_nopivot.h | 5 ++++- library/include/precond/hipsparse_gtsv_strided_batch.h | 5 ++++- library/include/reorder/hipsparse_csrcolor.h | 5 ++++- 77 files changed, 308 insertions(+), 77 deletions(-) diff --git a/library/include/conversion/hipsparse_bsr2csr.h b/library/include/conversion/hipsparse_bsr2csr.h index 916a9986..7a79e5df 100644 --- a/library/include/conversion/hipsparse_bsr2csr.h +++ b/library/include/conversion/hipsparse_bsr2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_BSR2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_BSR2CSR_H #ifdef __cplusplus extern "C" { @@ -103,3 +104,5 @@ hipsparseStatus_t hipsparseZbsr2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_BSR2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_coo2csr.h b/library/include/conversion/hipsparse_coo2csr.h index 0e5fec29..002ef647 100644 --- a/library/include/conversion/hipsparse_coo2csr.h +++ b/library/include/conversion/hipsparse_coo2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_COO2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_COO2CSR_H #ifdef __cplusplus extern "C" { @@ -54,3 +55,5 @@ hipsparseStatus_t hipsparseXcoo2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_COO2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_coosort.h b/library/include/conversion/hipsparse_coosort.h index 70ce281d..5a75bab4 100644 --- a/library/include/conversion/hipsparse_coosort.h +++ b/library/include/conversion/hipsparse_coosort.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_COOSORT_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_COOSORT_H #ifdef __cplusplus extern "C" { @@ -107,3 +108,5 @@ hipsparseStatus_t hipsparseXcoosortByColumn(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_COOSORT_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_create_identity_permutation.h b/library/include/conversion/hipsparse_create_identity_permutation.h index 268f619d..37c03d9b 100644 --- a/library/include/conversion/hipsparse_create_identity_permutation.h +++ b/library/include/conversion/hipsparse_create_identity_permutation.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CREATE_IDENTITY_PERMUTATION_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CREATE_IDENTITY_PERMUTATION_H #ifdef __cplusplus extern "C" { @@ -54,3 +55,5 @@ hipsparseStatus_t hipsparseCreateIdentityPermutation(hipsparseHandle_t handle, i #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CREATE_IDENTITY_PERMUTATION_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csc2dense.h b/library/include/conversion/hipsparse_csc2dense.h index a0d410c1..40733bb0 100644 --- a/library/include/conversion/hipsparse_csc2dense.h +++ b/library/include/conversion/hipsparse_csc2dense.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSC2DENSE_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSC2DENSE_H #ifdef __cplusplus extern "C" { @@ -84,3 +85,5 @@ hipsparseStatus_t hipsparseZcsc2dense(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSC2DENSE_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_cscsort.h b/library/include/conversion/hipsparse_cscsort.h index 167941e7..51823412 100644 --- a/library/include/conversion/hipsparse_cscsort.h +++ b/library/include/conversion/hipsparse_cscsort.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSCSORT_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSCSORT_H #ifdef __cplusplus extern "C" { @@ -76,3 +77,5 @@ hipsparseStatus_t hipsparseXcscsort(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSCSORT_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2bsr.h b/library/include/conversion/hipsparse_csr2bsr.h index f9ef094b..8e7b9c81 100644 --- a/library/include/conversion/hipsparse_csr2bsr.h +++ b/library/include/conversion/hipsparse_csr2bsr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2BSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2BSR_H #ifdef __cplusplus extern "C" { @@ -124,3 +125,5 @@ hipsparseStatus_t hipsparseZcsr2bsr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2BSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2coo.h b/library/include/conversion/hipsparse_csr2coo.h index 193da194..665dce57 100644 --- a/library/include/conversion/hipsparse_csr2coo.h +++ b/library/include/conversion/hipsparse_csr2coo.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2COO_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2COO_H #ifdef __cplusplus extern "C" { @@ -53,3 +54,5 @@ hipsparseStatus_t hipsparseXcsr2coo(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2COO_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2csc.h b/library/include/conversion/hipsparse_csr2csc.h index a602ec24..b8b6a3d5 100644 --- a/library/include/conversion/hipsparse_csr2csc.h +++ b/library/include/conversion/hipsparse_csr2csc.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSC_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSC_H #ifdef __cplusplus extern "C" { @@ -209,3 +210,5 @@ hipsparseStatus_t hipsparseCsr2cscEx2(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSC_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2csr_compress.h b/library/include/conversion/hipsparse_csr2csr_compress.h index 6d85a0b2..45f5d2e9 100644 --- a/library/include/conversion/hipsparse_csr2csr_compress.h +++ b/library/include/conversion/hipsparse_csr2csr_compress.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSR_COMPRESS_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSR_COMPRESS_H #ifdef __cplusplus extern "C" { @@ -99,3 +100,5 @@ hipsparseStatus_t hipsparseZcsr2csr_compress(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSR_COMPRESS_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2csru.h b/library/include/conversion/hipsparse_csr2csru.h index d864b1c1..92e06e52 100644 --- a/library/include/conversion/hipsparse_csr2csru.h +++ b/library/include/conversion/hipsparse_csr2csru.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSRU_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSRU_H #ifdef __cplusplus extern "C" { @@ -91,3 +92,5 @@ hipsparseStatus_t hipsparseZcsr2csru(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2CSRU_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2dense.h b/library/include/conversion/hipsparse_csr2dense.h index 81060a24..6c882b91 100644 --- a/library/include/conversion/hipsparse_csr2dense.h +++ b/library/include/conversion/hipsparse_csr2dense.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2DENSE_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2DENSE_H #ifdef __cplusplus extern "C" { @@ -84,3 +85,5 @@ hipsparseStatus_t hipsparseZcsr2dense(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2DENSE_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2gebsr.h b/library/include/conversion/hipsparse_csr2gebsr.h index d3f66b98..a92a64be 100644 --- a/library/include/conversion/hipsparse_csr2gebsr.h +++ b/library/include/conversion/hipsparse_csr2gebsr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2GEBSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2GEBSR_H #ifdef __cplusplus extern "C" { @@ -198,3 +199,5 @@ hipsparseStatus_t hipsparseZcsr2gebsr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2GEBSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csr2hyb.h b/library/include/conversion/hipsparse_csr2hyb.h index b466037c..a4d69ce8 100644 --- a/library/include/conversion/hipsparse_csr2hyb.h +++ b/library/include/conversion/hipsparse_csr2hyb.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSR2HYB_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSR2HYB_H #ifdef __cplusplus extern "C" { @@ -98,3 +99,5 @@ hipsparseStatus_t hipsparseZcsr2hyb(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSR2HYB_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csrsort.h b/library/include/conversion/hipsparse_csrsort.h index 613f4dcf..1cf161cb 100644 --- a/library/include/conversion/hipsparse_csrsort.h +++ b/library/include/conversion/hipsparse_csrsort.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSRSORT_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSRSORT_H #ifdef __cplusplus extern "C" { @@ -76,3 +77,5 @@ hipsparseStatus_t hipsparseXcsrsort(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSRSORT_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_csru2csr.h b/library/include/conversion/hipsparse_csru2csr.h index 9131b29c..d71b9bca 100644 --- a/library/include/conversion/hipsparse_csru2csr.h +++ b/library/include/conversion/hipsparse_csru2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CSRU2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_CSRU2CSR_H #ifdef __cplusplus extern "C" { @@ -148,3 +149,5 @@ hipsparseStatus_t hipsparseZcsru2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CSRU2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_dense2csc.h b/library/include/conversion/hipsparse_dense2csc.h index e1dff57b..f183db63 100644 --- a/library/include/conversion/hipsparse_dense2csc.h +++ b/library/include/conversion/hipsparse_dense2csc.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_DENSE2CSC_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_DENSE2CSC_H #ifdef __cplusplus extern "C" { @@ -90,3 +91,5 @@ hipsparseStatus_t hipsparseZdense2csc(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_DENSE2CSC_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_dense2csr.h b/library/include/conversion/hipsparse_dense2csr.h index 41040c64..ca2250ee 100644 --- a/library/include/conversion/hipsparse_dense2csr.h +++ b/library/include/conversion/hipsparse_dense2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_DENSE2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_DENSE2CSR_H #ifdef __cplusplus extern "C" { @@ -88,3 +89,5 @@ hipsparseStatus_t hipsparseZdense2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_DENSE2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_gebsr2csr.h b/library/include/conversion/hipsparse_gebsr2csr.h index a4fe3bb2..12788e65 100644 --- a/library/include/conversion/hipsparse_gebsr2csr.h +++ b/library/include/conversion/hipsparse_gebsr2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2CSR_H #ifdef __cplusplus extern "C" { @@ -107,3 +108,5 @@ hipsparseStatus_t hipsparseZgebsr2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_gebsr2gebsc.h b/library/include/conversion/hipsparse_gebsr2gebsc.h index 0d2319aa..15b1d819 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsc.h +++ b/library/include/conversion/hipsparse_gebsr2gebsc.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2GEBSC_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2GEBSC_H #ifdef __cplusplus extern "C" { @@ -175,3 +176,5 @@ hipsparseStatus_t hipsparseZgebsr2gebsc(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2GEBSC_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_gebsr2gebsr.h b/library/include/conversion/hipsparse_gebsr2gebsr.h index aa08d026..6d171469 100644 --- a/library/include/conversion/hipsparse_gebsr2gebsr.h +++ b/library/include/conversion/hipsparse_gebsr2gebsr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2GEBSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2GEBSR_H #ifdef __cplusplus extern "C" { @@ -227,3 +228,5 @@ hipsparseStatus_t hipsparseZgebsr2gebsr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_GEBSR2GEBSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_hyb2csr.h b/library/include/conversion/hipsparse_hyb2csr.h index 729f22aa..9517c743 100644 --- a/library/include/conversion/hipsparse_hyb2csr.h +++ b/library/include/conversion/hipsparse_hyb2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_HYB2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_HYB2CSR_H #ifdef __cplusplus extern "C" { @@ -77,3 +78,5 @@ hipsparseStatus_t hipsparseZhyb2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_HYB2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_nnz.h b/library/include/conversion/hipsparse_nnz.h index ea9cba15..2b5c26bb 100644 --- a/library/include/conversion/hipsparse_nnz.h +++ b/library/include/conversion/hipsparse_nnz.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_NNZ_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_NNZ_H #ifdef __cplusplus extern "C" { @@ -84,3 +85,5 @@ hipsparseStatus_t hipsparseZnnz(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_NNZ_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_nnz_compress.h b/library/include/conversion/hipsparse_nnz_compress.h index e69a10f7..2e38fb76 100644 --- a/library/include/conversion/hipsparse_nnz_compress.h +++ b/library/include/conversion/hipsparse_nnz_compress.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_NNZ_COMPRESS_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_NNZ_COMPRESS_H #ifdef __cplusplus extern "C" { @@ -83,3 +84,5 @@ hipsparseStatus_t hipsparseZnnz_compress(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_NNZ_COMPRESS_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_csr2csr.h b/library/include/conversion/hipsparse_prune_csr2csr.h index 38d57e97..d97015b2 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr.h +++ b/library/include/conversion/hipsparse_prune_csr2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_CSR2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_CSR2CSR_H #ifdef __cplusplus extern "C" { @@ -216,3 +217,5 @@ hipsparseStatus_t hipsparseDpruneCsr2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_CSR2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h index f9aea701..0dea525c 100644 --- a/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_csr2csr_by_percentage.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_CSR2CSR_BY_PERCENTAGE_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_CSR2CSR_BY_PERCENTAGE_H #ifdef __cplusplus extern "C" { @@ -227,3 +228,5 @@ hipsparseStatus_t hipsparseDpruneCsr2csrByPercentage(hipsparseHandle_t h #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_CSR2CSR_BY_PERCENTAGE_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_dense2csr.h b/library/include/conversion/hipsparse_prune_dense2csr.h index 4c6b163b..a5754619 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr.h +++ b/library/include/conversion/hipsparse_prune_dense2csr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_DENSE2CSR_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_DENSE2CSR_H #ifdef __cplusplus extern "C" { @@ -188,3 +189,5 @@ hipsparseStatus_t hipsparseDpruneDense2csr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_DENSE2CSR_H */ \ No newline at end of file diff --git a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h index 09415d9d..2cfed980 100644 --- a/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h +++ b/library/include/conversion/hipsparse_prune_dense2csr_by_percentage.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_DENSE2CSR_BY_PERCENTAGE_H +#define HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_DENSE2CSR_BY_PERCENTAGE_H #ifdef __cplusplus extern "C" { @@ -277,3 +278,5 @@ hipsparseStatus_t hipsparseDpruneDense2csrByPercentage(hipsparseHandle_t #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_PRUNE_DENSE2CSR_BY_PERCENTAGE_H */ \ No newline at end of file diff --git a/library/include/extra/hipsparse_csrgeam.h b/library/include/extra/hipsparse_csrgeam.h index 2f8242a7..e5ec47a6 100644 --- a/library/include/extra/hipsparse_csrgeam.h +++ b/library/include/extra/hipsparse_csrgeam.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_EXTRA_HIPSPARSE_CSRGEAM_H +#define HIPSPARSE_EXTRA_HIPSPARSE_CSRGEAM_H #ifdef __cplusplus extern "C" { @@ -420,3 +421,5 @@ hipsparseStatus_t hipsparseZcsrgeam2(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_EXTRA_HIPSPARSE_CSRGEAM_H */ \ No newline at end of file diff --git a/library/include/extra/hipsparse_csrgemm.h b/library/include/extra/hipsparse_csrgemm.h index 8fe0f0f1..9037a5b8 100644 --- a/library/include/extra/hipsparse_csrgemm.h +++ b/library/include/extra/hipsparse_csrgemm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_EXTRA_HIPSPARSE_CSRGEMM_H +#define HIPSPARSE_EXTRA_HIPSPARSE_CSRGEMM_H #ifdef __cplusplus extern "C" { @@ -523,3 +524,5 @@ hipsparseStatus_t hipsparseZcsrgemm2(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_EXTRA_HIPSPARSE_CSRGEMM_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_axpby.h b/library/include/generic/hipsparse_axpby.h index e1366f95..fb5f1876 100644 --- a/library/include/generic/hipsparse_axpby.h +++ b/library/include/generic/hipsparse_axpby.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_AXPBY_H +#define HIPSPARSE_GENERIC_HIPSPARSE_AXPBY_H #ifdef __cplusplus extern "C" { @@ -138,3 +139,5 @@ hipsparseStatus_t hipsparseAxpby(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_AXPBY_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_dense2sparse.h b/library/include/generic/hipsparse_dense2sparse.h index e4236762..f5d7b171 100644 --- a/library/include/generic/hipsparse_dense2sparse.h +++ b/library/include/generic/hipsparse_dense2sparse.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_DENSE2SPARSE_H +#define HIPSPARSE_GENERIC_HIPSPARSE_DENSE2SPARSE_H #ifdef __cplusplus extern "C" { @@ -100,3 +101,5 @@ hipsparseStatus_t hipsparseDenseToSparse_convert(hipsparseHandle_t han #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_DENSE2SPARSE_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_gather.h b/library/include/generic/hipsparse_gather.h index 5ad5865f..dc371cbe 100644 --- a/library/include/generic/hipsparse_gather.h +++ b/library/include/generic/hipsparse_gather.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_GATHER_H +#define HIPSPARSE_GENERIC_HIPSPARSE_GATHER_H #ifdef __cplusplus extern "C" { @@ -119,3 +120,5 @@ hipsparseStatus_t hipsparseGather(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_GATHER_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_rot.h b/library/include/generic/hipsparse_rot.h index 644a9377..60fec055 100644 --- a/library/include/generic/hipsparse_rot.h +++ b/library/include/generic/hipsparse_rot.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_ROT_H +#define HIPSPARSE_GENERIC_HIPSPARSE_ROT_H #ifdef __cplusplus extern "C" { @@ -135,3 +136,5 @@ hipsparseStatus_t hipsparseRot(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_ROT_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_scatter.h b/library/include/generic/hipsparse_scatter.h index 1d1d094f..4fc12d30 100644 --- a/library/include/generic/hipsparse_scatter.h +++ b/library/include/generic/hipsparse_scatter.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SCATTER_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SCATTER_H #ifdef __cplusplus extern "C" { @@ -122,3 +123,5 @@ hipsparseStatus_t hipsparseScatter(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SCATTER_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_sddmm.h b/library/include/generic/hipsparse_sddmm.h index 6de9492c..57a22500 100644 --- a/library/include/generic/hipsparse_sddmm.h +++ b/library/include/generic/hipsparse_sddmm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SDDMM_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SDDMM_H #ifdef __cplusplus extern "C" { @@ -166,3 +167,5 @@ hipsparseStatus_t hipsparseSDDMM(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SDDMM_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_sparse2dense.h b/library/include/generic/hipsparse_sparse2dense.h index ce199031..ad79fc4d 100644 --- a/library/include/generic/hipsparse_sparse2dense.h +++ b/library/include/generic/hipsparse_sparse2dense.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPARSE2DENSE_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPARSE2DENSE_H #ifdef __cplusplus extern "C" { @@ -76,3 +77,5 @@ hipsparseStatus_t hipsparseSparseToDense(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPARSE2DENSE_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spgemm.h b/library/include/generic/hipsparse_spgemm.h index 00c3b6aa..705b15e1 100644 --- a/library/include/generic/hipsparse_spgemm.h +++ b/library/include/generic/hipsparse_spgemm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPGEMM_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPGEMM_H #ifdef __cplusplus extern "C" { @@ -299,3 +300,5 @@ hipsparseStatus_t hipsparseSpGEMM_copy(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPGEMM_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spgemm_reuse.h b/library/include/generic/hipsparse_spgemm_reuse.h index 7996d634..c1724e8d 100644 --- a/library/include/generic/hipsparse_spgemm_reuse.h +++ b/library/include/generic/hipsparse_spgemm_reuse.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPGEMM_REUSE_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPGEMM_REUSE_H #ifdef __cplusplus extern "C" { @@ -426,3 +427,5 @@ hipsparseStatus_t hipsparseSpGEMMreuse_compute(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPGEMM_REUSE_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spmm.h b/library/include/generic/hipsparse_spmm.h index 31f53ac7..16a353e2 100644 --- a/library/include/generic/hipsparse_spmm.h +++ b/library/include/generic/hipsparse_spmm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPMM_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPMM_H #ifdef __cplusplus extern "C" { @@ -256,3 +257,5 @@ hipsparseStatus_t hipsparseSpMM(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPMM_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spmv.h b/library/include/generic/hipsparse_spmv.h index 44cbe063..5b2403d0 100644 --- a/library/include/generic/hipsparse_spmv.h +++ b/library/include/generic/hipsparse_spmv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPMV_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPMV_H #ifdef __cplusplus extern "C" { @@ -244,3 +245,5 @@ hipsparseStatus_t hipsparseSpMV(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPMV_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spsm.h b/library/include/generic/hipsparse_spsm.h index f62fed23..ff657597 100644 --- a/library/include/generic/hipsparse_spsm.h +++ b/library/include/generic/hipsparse_spsm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPSM_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPSM_H #ifdef __cplusplus extern "C" { @@ -185,3 +186,5 @@ hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPSM_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spsv.h b/library/include/generic/hipsparse_spsv.h index 6f2e8284..b972a35f 100644 --- a/library/include/generic/hipsparse_spsv.h +++ b/library/include/generic/hipsparse_spsv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPSV_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPSV_H #ifdef __cplusplus extern "C" { @@ -167,3 +168,5 @@ hipsparseStatus_t hipsparseSpSV_solve(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPSV_H */ \ No newline at end of file diff --git a/library/include/generic/hipsparse_spvv.h b/library/include/generic/hipsparse_spvv.h index 6d3f9a3a..9b98cf90 100644 --- a/library/include/generic/hipsparse_spvv.h +++ b/library/include/generic/hipsparse_spvv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_GENERIC_HIPSPARSE_SPVV_H +#define HIPSPARSE_GENERIC_HIPSPARSE_SPVV_H #ifdef __cplusplus extern "C" { @@ -172,3 +173,5 @@ hipsparseStatus_t hipsparseSpVV(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_GENERIC_HIPSPARSE_SPVV_H */ \ No newline at end of file diff --git a/library/include/hipsparse_auxiliary.h b/library/include/hipsparse_auxiliary.h index fe961eed..041639c9 100644 --- a/library/include/hipsparse_auxiliary.h +++ b/library/include/hipsparse_auxiliary.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_HIPSPARSE_AUXILIARY_H +#define HIPSPARSE_HIPSPARSE_AUXILIARY_H #ifdef __cplusplus extern "C" { @@ -587,3 +588,5 @@ hipsparseStatus_t hipsparseDestroyPruneInfo(pruneInfo_t info); #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_HIPSPARSE_AUXILIARY_H */ \ No newline at end of file diff --git a/library/include/hipsparse_generic_auxiliary.h b/library/include/hipsparse_generic_auxiliary.h index afb2c4d9..881bc7ed 100644 --- a/library/include/hipsparse_generic_auxiliary.h +++ b/library/include/hipsparse_generic_auxiliary.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_HIPSPARSE_GENERIC_AUXILIARY_H +#define HIPSPARSE_HIPSPARSE_GENERIC_AUXILIARY_H #ifdef __cplusplus extern "C" { @@ -951,3 +952,5 @@ hipsparseStatus_t hipsparseDnMatSetStridedBatch(hipsparseDnMatDescr_t dnMatDescr #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_HIPSPARSE_GENERIC_AUXILIARY_H */ \ No newline at end of file diff --git a/library/include/hipsparse_generic_types.h b/library/include/hipsparse_generic_types.h index ef29e237..daea4af9 100644 --- a/library/include/hipsparse_generic_types.h +++ b/library/include/hipsparse_generic_types.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_HIPSPARSE_GENERIC_TYPES_H +#define HIPSPARSE_HIPSPARSE_GENERIC_TYPES_H /*! \ingroup types_module * \brief Generic API opaque structure holding information for a sparse vector @@ -537,3 +538,5 @@ typedef enum } hipsparseSpGEMMAlg_t; #endif #endif + +#endif /* HIPSPARSE_HIPSPARSE_GENERIC_TYPES_H */ \ No newline at end of file diff --git a/library/include/hipsparse_types.h b/library/include/hipsparse_types.h index bd30f046..fa961592 100644 --- a/library/include/hipsparse_types.h +++ b/library/include/hipsparse_types.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_HIPSPARSE_TYPES_H +#define HIPSPARSE_HIPSPARSE_TYPES_H /// \cond DO_NOT_DOCUMENT // Forward declarations @@ -415,3 +416,5 @@ typedef enum { } hipsparseDirection_t; // clang-format on + +#endif /* HIPSPARSE_HIPSPARSE_TYPES_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_axpyi.h b/library/include/level1/hipsparse_axpyi.h index d73dee18..cb8123e4 100644 --- a/library/include/level1/hipsparse_axpyi.h +++ b/library/include/level1/hipsparse_axpyi.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_AXPYI_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_AXPYI_H #ifdef __cplusplus extern "C" { @@ -145,3 +146,5 @@ hipsparseStatus_t hipsparseZaxpyi(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_AXPYI_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_dotci.h b/library/include/level1/hipsparse_dotci.h index 8c1495aa..191eced8 100644 --- a/library/include/level1/hipsparse_dotci.h +++ b/library/include/level1/hipsparse_dotci.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_DOTCI_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_DOTCI_H #ifdef __cplusplus extern "C" { @@ -75,3 +76,5 @@ hipsparseStatus_t hipsparseZdotci(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_DOTCI_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_doti.h b/library/include/level1/hipsparse_doti.h index 86123d64..2313ae52 100644 --- a/library/include/level1/hipsparse_doti.h +++ b/library/include/level1/hipsparse_doti.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_DOTI_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_DOTI_H #ifdef __cplusplus extern "C" { @@ -139,3 +140,5 @@ hipsparseStatus_t hipsparseZdoti(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_DOTI_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_gthr.h b/library/include/level1/hipsparse_gthr.h index 75bbddb2..c09e4163 100644 --- a/library/include/level1/hipsparse_gthr.h +++ b/library/include/level1/hipsparse_gthr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_GTHR_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_GTHR_H #ifdef __cplusplus extern "C" { @@ -133,3 +134,5 @@ hipsparseStatus_t hipsparseZgthr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_GTHR_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_gthrz.h b/library/include/level1/hipsparse_gthrz.h index cc461eaf..386e827a 100644 --- a/library/include/level1/hipsparse_gthrz.h +++ b/library/include/level1/hipsparse_gthrz.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_GTHRZ_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_GTHRZ_H #ifdef __cplusplus extern "C" { @@ -89,3 +90,5 @@ hipsparseStatus_t hipsparseZgthrz(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_GTHRZ_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_roti.h b/library/include/level1/hipsparse_roti.h index fea00fb4..7a5f5dd4 100644 --- a/library/include/level1/hipsparse_roti.h +++ b/library/include/level1/hipsparse_roti.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_ROTI_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_ROTI_H #ifdef __cplusplus extern "C" { @@ -134,3 +135,5 @@ hipsparseStatus_t hipsparseDroti(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_ROTI_H */ \ No newline at end of file diff --git a/library/include/level1/hipsparse_sctr.h b/library/include/level1/hipsparse_sctr.h index b6016acb..90ae14f3 100644 --- a/library/include/level1/hipsparse_sctr.h +++ b/library/include/level1/hipsparse_sctr.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL1_HIPSPARSE_SCTR_H +#define HIPSPARSE_LEVEL1_HIPSPARSE_SCTR_H #ifdef __cplusplus extern "C" { @@ -135,3 +136,5 @@ hipsparseStatus_t hipsparseZsctr(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL1_HIPSPARSE_SCTR_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_bsrmv.h b/library/include/level2/hipsparse_bsrmv.h index 3cc77333..c4ac101b 100644 --- a/library/include/level2/hipsparse_bsrmv.h +++ b/library/include/level2/hipsparse_bsrmv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_BSRMV_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_BSRMV_H #ifdef __cplusplus extern "C" { @@ -227,3 +228,5 @@ hipsparseStatus_t hipsparseZbsrmv(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_BSRMV_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_bsrsv.h b/library/include/level2/hipsparse_bsrsv.h index 65f801ac..7a9153f1 100644 --- a/library/include/level2/hipsparse_bsrsv.h +++ b/library/include/level2/hipsparse_bsrsv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_BSRSV_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_BSRSV_H #ifdef __cplusplus extern "C" { @@ -548,3 +549,5 @@ hipsparseStatus_t hipsparseZbsrsv2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_BSRSV_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_bsrxmv.h b/library/include/level2/hipsparse_bsrxmv.h index b9fd0616..282c5950 100644 --- a/library/include/level2/hipsparse_bsrxmv.h +++ b/library/include/level2/hipsparse_bsrxmv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_BSRXMV_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_BSRXMV_H #ifdef __cplusplus extern "C" { @@ -150,3 +151,5 @@ hipsparseStatus_t hipsparseZbsrxmv(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_BSRXMV_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_csrmv.h b/library/include/level2/hipsparse_csrmv.h index 096d16f9..c6dab652 100644 --- a/library/include/level2/hipsparse_csrmv.h +++ b/library/include/level2/hipsparse_csrmv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_CSRMV_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_CSRMV_H #ifdef __cplusplus extern "C" { @@ -224,3 +225,5 @@ hipsparseStatus_t hipsparseZcsrmv(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_CSRMV_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_csrsv.h b/library/include/level2/hipsparse_csrsv.h index 7b4372f3..07b7e0a2 100644 --- a/library/include/level2/hipsparse_csrsv.h +++ b/library/include/level2/hipsparse_csrsv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_CSRSV_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_CSRSV_H #ifdef __cplusplus extern "C" { @@ -481,3 +482,5 @@ hipsparseStatus_t hipsparseZcsrsv2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_CSRSV_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_gemvi.h b/library/include/level2/hipsparse_gemvi.h index a33c17a6..0e1b5266 100644 --- a/library/include/level2/hipsparse_gemvi.h +++ b/library/include/level2/hipsparse_gemvi.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_GEMVI_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_GEMVI_H #ifdef __cplusplus extern "C" { @@ -169,3 +170,5 @@ hipsparseStatus_t hipsparseZgemvi(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_GEMVI_H */ \ No newline at end of file diff --git a/library/include/level2/hipsparse_hybmv.h b/library/include/level2/hipsparse_hybmv.h index a07cc914..5e3618cd 100644 --- a/library/include/level2/hipsparse_hybmv.h +++ b/library/include/level2/hipsparse_hybmv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL2_HIPSPARSE_HYBMV_H +#define HIPSPARSE_LEVEL2_HIPSPARSE_HYBMV_H #ifdef __cplusplus extern "C" { @@ -177,3 +178,5 @@ hipsparseStatus_t hipsparseZhybmv(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL2_HIPSPARSE_HYBMV_H */ \ No newline at end of file diff --git a/library/include/level3/hipsparse_bsrmm.h b/library/include/level3/hipsparse_bsrmm.h index a4474e93..d347c6c8 100644 --- a/library/include/level3/hipsparse_bsrmm.h +++ b/library/include/level3/hipsparse_bsrmm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL3_HIPSPARSE_BSRMM_H +#define HIPSPARSE_LEVEL3_HIPSPARSE_BSRMM_H #ifdef __cplusplus extern "C" { @@ -239,3 +240,5 @@ hipsparseStatus_t hipsparseZbsrmm(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL3_HIPSPARSE_BSRMM_H */ \ No newline at end of file diff --git a/library/include/level3/hipsparse_bsrsm.h b/library/include/level3/hipsparse_bsrsm.h index 82c2d5d3..2b55fd5b 100644 --- a/library/include/level3/hipsparse_bsrsm.h +++ b/library/include/level3/hipsparse_bsrsm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL3_HIPSPARSE_BSRSM_H +#define HIPSPARSE_LEVEL3_HIPSPARSE_BSRSM_H #ifdef __cplusplus extern "C" { @@ -554,3 +555,5 @@ hipsparseStatus_t hipsparseZbsrsm2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL3_HIPSPARSE_BSRSM_H */ \ No newline at end of file diff --git a/library/include/level3/hipsparse_csrmm.h b/library/include/level3/hipsparse_csrmm.h index 77fcd4b5..326830f5 100644 --- a/library/include/level3/hipsparse_csrmm.h +++ b/library/include/level3/hipsparse_csrmm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL3_HIPSPARSE_CSRMM_H +#define HIPSPARSE_LEVEL3_HIPSPARSE_CSRMM_H #ifdef __cplusplus extern "C" { @@ -363,3 +364,5 @@ hipsparseStatus_t hipsparseZcsrmm2(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL3_HIPSPARSE_CSRMM_H */ \ No newline at end of file diff --git a/library/include/level3/hipsparse_csrsm.h b/library/include/level3/hipsparse_csrsm.h index 49ce5aad..2b609833 100644 --- a/library/include/level3/hipsparse_csrsm.h +++ b/library/include/level3/hipsparse_csrsm.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL3_HIPSPARSE_CSRSM_H +#define HIPSPARSE_LEVEL3_HIPSPARSE_CSRSM_H #ifdef __cplusplus extern "C" { @@ -539,3 +540,5 @@ hipsparseStatus_t hipsparseZcsrsm2_solve(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL3_HIPSPARSE_CSRSM_H */ \ No newline at end of file diff --git a/library/include/level3/hipsparse_gemmi.h b/library/include/level3/hipsparse_gemmi.h index 11b6236a..2719d4c3 100644 --- a/library/include/level3/hipsparse_gemmi.h +++ b/library/include/level3/hipsparse_gemmi.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_LEVEL3_HIPSPARSE_GEMMI_H +#define HIPSPARSE_LEVEL3_HIPSPARSE_GEMMI_H #ifdef __cplusplus extern "C" { @@ -135,3 +136,5 @@ hipsparseStatus_t hipsparseZgemmi(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_LEVEL3_HIPSPARSE_GEMMI_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_bsric0.h b/library/include/precond/hipsparse_bsric0.h index 0270ec3c..1f7691ad 100644 --- a/library/include/precond/hipsparse_bsric0.h +++ b/library/include/precond/hipsparse_bsric0.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_BSRIC0_H +#define HIPSPARSE_PRECOND_HIPSPARSE_BSRIC0_H #ifdef __cplusplus extern "C" { @@ -281,3 +282,5 @@ hipsparseStatus_t hipsparseZbsric02(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_BSRIC0_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_bsrilu0.h b/library/include/precond/hipsparse_bsrilu0.h index 738483d3..4454fd01 100644 --- a/library/include/precond/hipsparse_bsrilu0.h +++ b/library/include/precond/hipsparse_bsrilu0.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_BSRILU0_H +#define HIPSPARSE_PRECOND_HIPSPARSE_BSRILU0_H #ifdef __cplusplus extern "C" { @@ -337,3 +338,5 @@ hipsparseStatus_t hipsparseZbsrilu02(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_BSRILU0_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_csric0.h b/library/include/precond/hipsparse_csric0.h index b10bf7a7..750407bd 100644 --- a/library/include/precond/hipsparse_csric0.h +++ b/library/include/precond/hipsparse_csric0.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_CSRIC0_H +#define HIPSPARSE_PRECOND_HIPSPARSE_CSRIC0_H #ifdef __cplusplus extern "C" { @@ -314,3 +315,5 @@ hipsparseStatus_t hipsparseZcsric02(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_CSRIC0_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_csrilu0.h b/library/include/precond/hipsparse_csrilu0.h index 42f40ca2..07713acb 100644 --- a/library/include/precond/hipsparse_csrilu0.h +++ b/library/include/precond/hipsparse_csrilu0.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_CSRILU0_H +#define HIPSPARSE_PRECOND_HIPSPARSE_CSRILU0_H #ifdef __cplusplus extern "C" { @@ -364,3 +365,5 @@ hipsparseStatus_t hipsparseZcsrilu02(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_CSRILU0_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_gpsv_interleaved_batch.h b/library/include/precond/hipsparse_gpsv_interleaved_batch.h index 18920e07..6ef122a3 100644 --- a/library/include/precond/hipsparse_gpsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gpsv_interleaved_batch.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_GPSV_INTERLEAVED_BATCH_H +#define HIPSPARSE_PRECOND_HIPSPARSE_GPSV_INTERLEAVED_BATCH_H #ifdef __cplusplus extern "C" { @@ -158,3 +159,5 @@ hipsparseStatus_t hipsparseZgpsvInterleavedBatch(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_GPSV_INTERLEAVED_BATCH_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv.h b/library/include/precond/hipsparse_gtsv.h index a222b09b..e9614317 100644 --- a/library/include/precond/hipsparse_gtsv.h +++ b/library/include/precond/hipsparse_gtsv.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_GTSV_H +#define HIPSPARSE_PRECOND_HIPSPARSE_GTSV_H #ifdef __cplusplus extern "C" { @@ -140,3 +141,5 @@ hipsparseStatus_t hipsparseZgtsv2(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_GTSV_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv_interleaved_batch.h b/library/include/precond/hipsparse_gtsv_interleaved_batch.h index 9014b986..6d2edc64 100644 --- a/library/include/precond/hipsparse_gtsv_interleaved_batch.h +++ b/library/include/precond/hipsparse_gtsv_interleaved_batch.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_GTSV_INTERLEAVED_BATCH_H +#define HIPSPARSE_PRECOND_HIPSPARSE_GTSV_INTERLEAVED_BATCH_H #ifdef __cplusplus extern "C" { @@ -140,3 +141,5 @@ hipsparseStatus_t hipsparseZgtsvInterleavedBatch(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_GTSV_INTERLEAVED_BATCH_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv_nopivot.h b/library/include/precond/hipsparse_gtsv_nopivot.h index d3389da5..946885a6 100644 --- a/library/include/precond/hipsparse_gtsv_nopivot.h +++ b/library/include/precond/hipsparse_gtsv_nopivot.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_GTSV_NOPIVOT_H +#define HIPSPARSE_PRECOND_HIPSPARSE_GTSV_NOPIVOT_H #ifdef __cplusplus extern "C" { @@ -140,3 +141,5 @@ hipsparseStatus_t hipsparseZgtsv2_nopivot(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_GTSV_NOPIVOT_H */ \ No newline at end of file diff --git a/library/include/precond/hipsparse_gtsv_strided_batch.h b/library/include/precond/hipsparse_gtsv_strided_batch.h index 4c21b26e..0d47686d 100644 --- a/library/include/precond/hipsparse_gtsv_strided_batch.h +++ b/library/include/precond/hipsparse_gtsv_strided_batch.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_PRECOND_HIPSPARSE_GTSV_STRIDED_BATCH_H +#define HIPSPARSE_PRECOND_HIPSPARSE_GTSV_STRIDED_BATCH_H #ifdef __cplusplus extern "C" { @@ -140,3 +141,5 @@ hipsparseStatus_t hipsparseZgtsv2StridedBatch(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_PRECOND_HIPSPARSE_GTSV_STRIDED_BATCH_H */ \ No newline at end of file diff --git a/library/include/reorder/hipsparse_csrcolor.h b/library/include/reorder/hipsparse_csrcolor.h index 29a91e37..37287d48 100644 --- a/library/include/reorder/hipsparse_csrcolor.h +++ b/library/include/reorder/hipsparse_csrcolor.h @@ -21,7 +21,8 @@ * THE SOFTWARE. * * ************************************************************************ */ -#pragma once +#ifndef HIPSPARSE_REORDER_HIPSPARSE_CSRCOLOR_H +#define HIPSPARSE_REORDER_HIPSPARSE_CSRCOLOR_H #ifdef __cplusplus extern "C" { @@ -100,3 +101,5 @@ hipsparseStatus_t hipsparseZcsrcolor(hipsparseHandle_t handle, #ifdef __cplusplus } #endif + +#endif /* HIPSPARSE_REORDER_HIPSPARSE_CSRCOLOR_H */ \ No newline at end of file