Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize hipsparse header #461

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute_process doesn't put any information into the generated Makefile about what input files affect what output files. I think this may break your incremental builds, as your headers will not get recopied when you change them.


# Public hipSPARSE headers
set(hipsparse_headers_public
Expand Down
108 changes: 108 additions & 0 deletions library/include/conversion/hipsparse_bsr2csr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*! \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.
*
* ************************************************************************ */
#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_BSR2CSR_H
#define HIPSPARSE_CONVERSION_HIPSPARSE_BSR2CSR_H

#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

#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_BSR2CSR_H */
59 changes: 59 additions & 0 deletions library/include/conversion/hipsparse_coo2csr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*! \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.
*
* ************************************************************************ */
#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_COO2CSR_H
#define HIPSPARSE_CONVERSION_HIPSPARSE_COO2CSR_H

#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

#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_COO2CSR_H */
112 changes: 112 additions & 0 deletions library/include/conversion/hipsparse_coosort.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*! \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.
*
* ************************************************************************ */
#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_COOSORT_H
#define HIPSPARSE_CONVERSION_HIPSPARSE_COOSORT_H

#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

#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_COOSORT_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*! \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.
*
* ************************************************************************ */
#ifndef HIPSPARSE_CONVERSION_HIPSPARSE_CREATE_IDENTITY_PERMUTATION_H
#define HIPSPARSE_CONVERSION_HIPSPARSE_CREATE_IDENTITY_PERMUTATION_H

#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

#endif /* HIPSPARSE_CONVERSION_HIPSPARSE_CREATE_IDENTITY_PERMUTATION_H */
Loading