Skip to content

Commit

Permalink
deprecate KOKKOS_CUSPARSE_SAFE_CALL -> KOKKOSPARSE_IMPL_CUSPARSE_SAFE…
Browse files Browse the repository at this point in the history
…_CALL

Signed-off-by: Carl Pearson <[email protected]>
  • Loading branch information
cwpearson committed Nov 11, 2024
1 parent 618a2c2 commit da27d73
Show file tree
Hide file tree
Showing 19 changed files with 292 additions and 278 deletions.
24 changes: 12 additions & 12 deletions perf_test/batched/sparse/cusolver/KokkosBatched_Test_cusolverSp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ struct Functor_Test_SparseCuSolveQR {
const size_t m = _r.extent(0) - 1;

cusparseMatDescr_t descrA = 0;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));

double tol = 1e-18;
int reorder = 0;
Expand Down Expand Up @@ -146,9 +146,9 @@ struct Functor_Test_Block_SparseCuSolveQR {
const size_t block_m = N * m;

cusparseMatDescr_t descrA = 0;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));

double tol = 1e-18;
int reorder = 0;
Expand Down Expand Up @@ -229,9 +229,9 @@ struct Functor_Test_SparseCuSolveChol {
const size_t m = _r.extent(0) - 1;

cusparseMatDescr_t descrA = 0;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));

double tol = 1e-18;
int reorder = 0;
Expand Down Expand Up @@ -284,9 +284,9 @@ struct Functor_Test_Block_SparseCuSolveChol {
const size_t block_m = N * m;

cusparseMatDescr_t descrA = 0;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&descrA));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ZERO));

double tol = 1e-18;
int reorder = 0;
Expand Down
42 changes: 21 additions & 21 deletions perf_test/sparse/KokkosSparse_spadd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,20 @@ void run_experiment(int argc, char** argv, CommonInputParams) {
const double alphabeta = 1.0;

if (params.use_cusparse) {
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreate(&cusparseHandle));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetPointerMode(cusparseHandle, CUSPARSE_POINTER_MODE_HOST));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&A_cusparse));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&B_cusparse));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&C_cusparse));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(A_cusparse, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(B_cusparse, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatType(C_cusparse, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(A_cusparse, CUSPARSE_DIAG_TYPE_NON_UNIT));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(B_cusparse, CUSPARSE_DIAG_TYPE_NON_UNIT));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(C_cusparse, CUSPARSE_DIAG_TYPE_NON_UNIT));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(A_cusparse, CUSPARSE_INDEX_BASE_ZERO));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(B_cusparse, CUSPARSE_INDEX_BASE_ZERO));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(C_cusparse, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreate(&cusparseHandle));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetPointerMode(cusparseHandle, CUSPARSE_POINTER_MODE_HOST));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&A_cusparse));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&B_cusparse));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateMatDescr(&C_cusparse));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(A_cusparse, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(B_cusparse, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatType(C_cusparse, CUSPARSE_MATRIX_TYPE_GENERAL));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(A_cusparse, CUSPARSE_DIAG_TYPE_NON_UNIT));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(B_cusparse, CUSPARSE_DIAG_TYPE_NON_UNIT));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatDiagType(C_cusparse, CUSPARSE_DIAG_TYPE_NON_UNIT));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(A_cusparse, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(B_cusparse, CUSPARSE_INDEX_BASE_ZERO));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSetMatIndexBase(C_cusparse, CUSPARSE_INDEX_BASE_ZERO));
}
#endif
#ifdef KOKKOSKERNELS_ENABLE_TPL_MKL
Expand Down Expand Up @@ -320,16 +320,16 @@ void run_experiment(int argc, char** argv, CommonInputParams) {
if constexpr (std::is_same_v<lno_t, int> && std::is_same_v<size_type, int>) {
// Symbolic phase: compute buffer size, then compute nnz
size_t bufferSize;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseDcsrgeam2_bufferSizeExt(
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseDcsrgeam2_bufferSizeExt(
cusparseHandle, A.numRows(), A.numCols(), &alphabeta, A_cusparse, A.nnz(), A.values.data(),
A.graph.row_map.data(), A.graph.entries.data(), &alphabeta, B_cusparse, B.nnz(), B.values.data(),
B.graph.row_map.data(), B.graph.entries.data(), C_cusparse, NULL, row_mapC.data(), NULL, &bufferSize));
// Allocate work buffer
KOKKOS_IMPL_CUDA_SAFE_CALL(cudaMalloc((void**)&cusparseBuffer, bufferSize));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseXcsrgeam2Nnz(cusparseHandle, m, n, A_cusparse, A.nnz(),
A.graph.row_map.data(), A.graph.entries.data(), B_cusparse,
B.nnz(), B.graph.row_map.data(), B.graph.entries.data(),
C_cusparse, row_mapC.data(), &c_nnz, cusparseBuffer));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(
cusparseXcsrgeam2Nnz(cusparseHandle, m, n, A_cusparse, A.nnz(), A.graph.row_map.data(),
A.graph.entries.data(), B_cusparse, B.nnz(), B.graph.row_map.data(),
B.graph.entries.data(), C_cusparse, row_mapC.data(), &c_nnz, cusparseBuffer));
} else {
throw std::runtime_error(
"Must enable int as both ordinal and offset type in KokkosKernels "
Expand All @@ -351,7 +351,7 @@ void run_experiment(int argc, char** argv, CommonInputParams) {
if (params.use_cusparse) {
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUSPARSE
if constexpr (std::is_same_v<lno_t, int> && std::is_same_v<size_type, int>) {
KOKKOS_CUSPARSE_SAFE_CALL(cusparseDcsrgeam2(
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseDcsrgeam2(
cusparseHandle, m, n, &alphabeta, A_cusparse, A.nnz(), A.values.data(), A.graph.row_map.data(),
A.graph.entries.data(), &alphabeta, B_cusparse, B.nnz(), B.values.data(), B.graph.row_map.data(),
B.graph.entries.data(), C_cusparse, valuesC.data(), row_mapC.data(), entriesC.data(), cusparseBuffer));
Expand Down Expand Up @@ -379,7 +379,7 @@ void run_experiment(int argc, char** argv, CommonInputParams) {
}

#ifdef KOKKOSKERNELS_ENABLE_TPL_CUSPARSE
if (params.use_cusparse) KOKKOS_CUSPARSE_SAFE_CALL(cusparseDestroy(cusparseHandle));
if (params.use_cusparse) KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseDestroy(cusparseHandle));
#endif

#ifdef KOKKOSKERNELS_ENABLE_TPL_MKL
Expand Down
25 changes: 14 additions & 11 deletions perf_test/sparse/KokkosSparse_spmv_struct_tuning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,16 @@ int main(int argc, char** argv) {

/* create matrix */
cusparseSpMatDescr_t A_cusparse;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateCsr(
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseCreateCsr(
&A_cusparse, A.numRows(), A.numCols(), A.nnz(), (void*)A.graph.row_map.data(), (void*)A.graph.entries.data(),
(void*)A.values.data(), myCusparseOffsetType, myCusparseEntryType, CUSPARSE_INDEX_BASE_ZERO, myCudaDataType));

/* create lhs and rhs */
cusparseDnVecDescr_t vecX, vecY;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateDnVec(&vecX, x1.extent_int(0), (void*)x1.data(), myCudaDataType));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseCreateDnVec(&vecY, y1.extent_int(0), (void*)y1.data(), myCudaDataType));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(
cusparseCreateDnVec(&vecX, x1.extent_int(0), (void*)x1.data(), myCudaDataType));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(
cusparseCreateDnVec(&vecY, y1.extent_int(0), (void*)y1.data(), myCudaDataType));

const double alpha = 1.0, beta = 1.0;
size_t bufferSize = 0;
Expand All @@ -528,9 +530,9 @@ int main(int argc, char** argv) {
#else
cusparseSpMVAlg_t alg = CUSPARSE_MV_ALG_DEFAULT;
#endif
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSpMV_bufferSize(controls.getCusparseHandle(), CUSPARSE_OPERATION_NON_TRANSPOSE,
&alpha, A_cusparse, vecX, &beta, vecY, myCudaDataType, alg,
&bufferSize));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(
cusparseSpMV_bufferSize(controls.getCusparseHandle(), CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha, A_cusparse,
vecX, &beta, vecY, myCudaDataType, alg, &bufferSize));
KOKKOS_IMPL_CUDA_SAFE_CALL(cudaMalloc(&dBuffer, bufferSize));

/* perform SpMV */
Expand All @@ -540,8 +542,9 @@ int main(int argc, char** argv) {
double ave_time = 0.0;
for (int i = 0; i < loop; i++) {
Kokkos::Timer timer;
KOKKOS_CUSPARSE_SAFE_CALL(cusparseSpMV(controls.getCusparseHandle(), CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha,
A_cusparse, vecX, &beta, vecY, myCudaDataType, alg, dBuffer));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseSpMV(controls.getCusparseHandle(),
CUSPARSE_OPERATION_NON_TRANSPOSE, &alpha, A_cusparse, vecX,
&beta, vecY, myCudaDataType, alg, dBuffer));
Kokkos::fence();
double time = timer.seconds();
ave_time += time;
Expand All @@ -565,9 +568,9 @@ int main(int argc, char** argv) {
Kokkos::Profiling::popRegion();

KOKKOS_IMPL_CUDA_SAFE_CALL(cudaFree(dBuffer));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseDestroyDnVec(vecX));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseDestroyDnVec(vecY));
KOKKOS_CUSPARSE_SAFE_CALL(cusparseDestroySpMat(A_cusparse));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseDestroyDnVec(vecX));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseDestroyDnVec(vecY));
KOKKOSSPARSE_IMPL_CUSPARSE_SAFE_CALL(cusparseDestroySpMat(A_cusparse));
#else
// The data needs to be reformatted for cusparse before launching the
// kernel. Step one, extract raw data
Expand Down
Loading

0 comments on commit da27d73

Please sign in to comment.