Files
TheRock/rocm-libraries/projects/hipsparse/library/include/internal/conversion/hipsparse_gebsr2csr.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

198 lines
9.0 KiB
C

/*! \file */
/* ************************************************************************
* Copyright (C) 2025 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.
*
* ************************************************************************ */
#ifndef HIPSPARSE_GEBSR2CSR_H
#define HIPSPARSE_GEBSR2CSR_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \ingroup conv_module
* \brief Convert a sparse GEBSR matrix into a sparse CSR matrix.
*
* \details
* \p hipsparseXgebsr2csr converts a GEBSR matrix into a CSR matrix. It is assumed
* that \p csrValC, \p csrColIndC, and \p csrRowPtrC are already allocated prior to
* calling \p hipsparseXgebsr2csr. Allocation size for \p csrRowPtrC equals
* \p m+1 where:
*
* \f[
* \begin{align}
* \text{m} &= \text{mb * rowBlockDim} \\
* \text{n} &= \text{nb * colBlockDim}
* \end{align}
* \f]
*
* Allocation size for \p csrValC and \p csrColIndC is computed by the the number of blocks in the GEBSR
* matrix, \p nnzb, multiplied by the product of the block dimensions, that is, \p nnz=nnzb*rocBlockDim*colBlockDim.
*
* For example, given the GEBSR matrix:
* \f[
* \left[
* \begin{array}{c | c | c}
* \begin{array}{c c}
* 6 & 2 \\
* 1 & 4 \\
* 5 & 4
* \end{array} &
* \begin{array}{c c}
* 0 & 3 \\
* 5 & 0 \\
* 0 & 7
* \end{array} &
* \begin{array}{c c}
* 0 & 0 \\
* 0 & 0 \\
* 0 & 0
* \end{array} \\
* \hline
* \begin{array}{c c}
* 0 & 0 \\
* 0 & 0 \\
* 0 & 0
* \end{array} &
* \begin{array}{c c}
* 3 & 0 \\
* 0 & 0 \\
* 0 & 7
* \end{array} &
* \begin{array}{c c}
* 2 & 2 \\
* 4 & 3 \\
* 1 & 4
* \end{array} \\
* \end{array}
* \right]
* \f]
*
* \note
* This function is non-blocking and executed asynchronously with respect to the host.
* It can return before the actual computation has finished.
*
* @param[in]
* handle handle to the hipSPARSE library context queue.
* @param[in]
* dirA the storage format of the blocks, \ref HIPSPARSE_DIRECTION_ROW or \ref HIPSPARSE_DIRECTION_COLUMN.
* @param[in]
* mb number of block rows in the sparse general BSR matrix.
* @param[in]
* nb number of block columns in the sparse general BSR matrix.
* @param[in]
* descrA descriptor of the sparse general BSR matrix. Currently, only
* \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported.
* @param[in]
* bsrValA array of \p nnzb*rowBlockDim*colBlockDim containing the values of the sparse BSR matrix.
* @param[in]
* bsrRowPtrA array of \p mb+1 elements that point to the start of every block row of the
* sparse BSR matrix.
* @param[in]
* bsrColIndA array of \p nnzb elements containing the block column indices of the sparse BSR matrix.
* @param[in]
* rowBlockDim row size of the blocks in the sparse general BSR matrix.
* @param[in]
* colBlockDim column size of the blocks in the sparse general BSR matrix.
* @param[in]
* descrC descriptor of the sparse CSR matrix. Currently, only
* \ref HIPSPARSE_MATRIX_TYPE_GENERAL is supported.
* @param[out]
* csrValC array of \p nnzb*rowBlockDim*colBlockDim elements containing the values of the sparse CSR matrix.
* @param[out]
* csrRowPtrC array of \p m+1 where \p m=mb*rowBlockDim elements that point to the start of every row of the
* sparse CSR matrix.
* @param[out]
* csrColIndC array of \p nnzb*block_dim*block_dim elements containing the column indices of the sparse CSR matrix.
*
* \retval HIPSPARSE_STATUS_SUCCESS the operation completed successfully.
* \retval HIPSPARSE_STATUS_INVALID_VALUE \p handle, \p mb, \p nb, \p block_dim, \p bsrValA,
* \p bsrRowPtrA, \p bsrColIndA, \p csrValC, \p csrRowPtrC, or \p csrColIndC pointer is invalid.
*/
/**@{*/
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
#endif /* HIPSPARSE_GEBSR2CSR_H */