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

Denseconversions #97

Merged
merged 16 commits into from
Apr 5, 2020
16 changes: 16 additions & 0 deletions clients/common/arg_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@
} \
}

void verify_hipsparse_status(hipsparseStatus_t status,
hipsparseStatus_t expected_status,
const char* message)
{
#ifdef GOOGLE_TEST
ASSERT_EQ(status, expected_status);
#else
if(status != expected_status)
{
std::cerr << "rocSPARSE TEST ERROR: status(=" << status
<< ") != expected_status(= " << expected_status << "), ";
std::cerr << message << std::endl;
}
#endif
}

void verify_hipsparse_status_invalid_pointer(hipsparseStatus_t status, const char* message)
{
#ifdef GOOGLE_TEST
Expand Down
231 changes: 231 additions & 0 deletions clients/common/hipsparse_template_specialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,237 @@ namespace hipsparse
handle, dirA, m, n, descrA, A, lda, nnzPerRowColumn, nnzTotalDevHostPtr);
}

template <>
hipsparseStatus_t hipsparseXdense2csr(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const float* A,
int ld,
const int* nnzPerRow,
float* csrVal,
int* csrRowPtr,
int* csrColInd)
{
return hipsparseSdense2csr(
handle, m, n, descr, A, ld, nnzPerRow, csrVal, csrRowPtr, csrColInd);
}

template <>
hipsparseStatus_t hipsparseXdense2csr(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const double* A,
int ld,
const int* nnzPerRow,
double* csrVal,
int* csrRowPtr,
int* csrColInd)
{
return hipsparseDdense2csr(
handle, m, n, descr, A, ld, nnzPerRow, csrVal, csrRowPtr, csrColInd);
}

template <>
hipsparseStatus_t hipsparseXdense2csr(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipComplex* A,
int ld,
const int* nnzPerRow,
hipComplex* csrVal,
int* csrRowPtr,
int* csrColInd)
{
return hipsparseCdense2csr(
handle, m, n, descr, A, ld, nnzPerRow, csrVal, csrRowPtr, csrColInd);
}

template <>
hipsparseStatus_t hipsparseXdense2csr(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipDoubleComplex* A,
int ld,
const int* nnzPerRow,
hipDoubleComplex* csrVal,
int* csrRowPtr,
int* csrColInd)
{
return hipsparseZdense2csr(
handle, m, n, descr, A, ld, nnzPerRow, csrVal, csrRowPtr, csrColInd);
}

template <>
hipsparseStatus_t hipsparseXdense2csc(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const float* A,
int ld,
const int* nnz_per_columns,
float* cscVal,
int* cscRowInd,
int* cscColPtr)
{
return hipsparseSdense2csc(
handle, m, n, descr, A, ld, nnz_per_columns, cscVal, cscRowInd, cscColPtr);
}
template <>
hipsparseStatus_t hipsparseXdense2csc(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const double* A,
int ld,
const int* nnz_per_columns,
double* cscVal,
int* cscRowInd,
int* cscColPtr)
{
return hipsparseDdense2csc(
handle, m, n, descr, A, ld, nnz_per_columns, cscVal, cscRowInd, cscColPtr);
}
template <>
hipsparseStatus_t hipsparseXdense2csc(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipComplex* A,
int ld,
const int* nnz_per_columns,
hipComplex* cscVal,
int* cscRowInd,
int* cscColPtr)
{
return hipsparseCdense2csc(
handle, m, n, descr, A, ld, nnz_per_columns, cscVal, cscRowInd, cscColPtr);
}
template <>
hipsparseStatus_t hipsparseXdense2csc(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipDoubleComplex* A,
int ld,
const int* nnz_per_columns,
hipDoubleComplex* cscVal,
int* cscRowInd,
int* cscColPtr)
{
return hipsparseZdense2csc(
handle, m, n, descr, A, ld, nnz_per_columns, cscVal, cscRowInd, cscColPtr);
}

template <>
hipsparseStatus_t hipsparseXcsr2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const float* csrVal,
const int* csrRowPtr,
const int* csrColInd,
float* A,
int ld)
{
return hipsparseScsr2dense(handle, m, n, descr, csrVal, csrRowPtr, csrColInd, A, ld);
}
template <>
hipsparseStatus_t hipsparseXcsr2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const double* csrVal,
const int* csrRowPtr,
const int* csrColInd,
double* A,
int ld)
{
return hipsparseDcsr2dense(handle, m, n, descr, csrVal, csrRowPtr, csrColInd, A, ld);
}
template <>
hipsparseStatus_t hipsparseXcsr2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipComplex* csrVal,
const int* csrRowPtr,
const int* csrColInd,
hipComplex* A,
int ld)
{
return hipsparseCcsr2dense(handle, m, n, descr, csrVal, csrRowPtr, csrColInd, A, ld);
}
template <>
hipsparseStatus_t hipsparseXcsr2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipDoubleComplex* csrVal,
const int* csrRowPtr,
const int* csrColInd,
hipDoubleComplex* A,
int ld)
{
return hipsparseZcsr2dense(handle, m, n, descr, csrVal, csrRowPtr, csrColInd, A, ld);
}

template <>
hipsparseStatus_t hipsparseXcsc2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const float* cscVal,
const int* cscRowInd,
const int* cscColPtr,
float* A,
int ld)
{
return hipsparseScsc2dense(handle, m, n, descr, cscVal, cscRowInd, cscColPtr, A, ld);
}
template <>
hipsparseStatus_t hipsparseXcsc2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const double* cscVal,
const int* cscRowInd,
const int* cscColPtr,
double* A,
int ld)
{
return hipsparseDcsc2dense(handle, m, n, descr, cscVal, cscRowInd, cscColPtr, A, ld);
}
template <>
hipsparseStatus_t hipsparseXcsc2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipComplex* cscVal,
const int* cscRowInd,
const int* cscColPtr,
hipComplex* A,
int ld)
{
return hipsparseCcsc2dense(handle, m, n, descr, cscVal, cscRowInd, cscColPtr, A, ld);
}
template <>
hipsparseStatus_t hipsparseXcsc2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const hipDoubleComplex* cscVal,
const int* cscRowInd,
const int* cscColPtr,
hipDoubleComplex* A,
int ld)
{
return hipsparseZcsc2dense(handle, m, n, descr, cscVal, cscRowInd, cscColPtr, A, ld);
}

template <>
hipsparseStatus_t hipsparseXcsr2csc(hipsparseHandle_t handle,
int m,
Expand Down
4 changes: 4 additions & 0 deletions clients/include/arg_check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

#include <hipsparse.h>

void verify_hipsparse_status(hipsparseStatus_t status,
hipsparseStatus_t expected_status,
const char* message);

void verify_hipsparse_status_invalid_pointer(hipsparseStatus_t status, const char* message);

void verify_hipsparse_status_invalid_size(hipsparseStatus_t status, const char* message);
Expand Down
46 changes: 46 additions & 0 deletions clients/include/hipsparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,52 @@ namespace hipsparse
int* nnzPerRowColumn,
int* nnzTotalDevHostPtr);

template <typename T>
hipsparseStatus_t hipsparseXdense2csr(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const T* A,
int ld,
const int* nnzPerRow,
T* csrVal,
int* csrRowPtr,
int* csrColInd);

template <typename T>
hipsparseStatus_t hipsparseXdense2csc(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const T* A,
int ld,
const int* nnzPerColumn,
T* cscVal,
int* cscRowInd,
int* cscColPtr);

template <typename T>
hipsparseStatus_t hipsparseXcsr2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const T* csrVal,
const int* csrRowPtr,
const int* csrColInd,
T* A,
int ld);

template <typename T>
hipsparseStatus_t hipsparseXcsc2dense(hipsparseHandle_t handle,
int m,
int n,
const hipsparseMatDescr_t descr,
const T* cscVal,
const int* cscRowInd,
const int* cscColPtr,
T* A,
int ld);

template <typename T>
hipsparseStatus_t hipsparseXcsr2csc(hipsparseHandle_t handle,
int m,
Expand Down
Loading