Debian Codegraph @

tests/unit_tests/synthetic/libraries/cusparse2rocsparse_11030_12000.cu

raw
1 // RUN: %run_test hipify "%s" "%t" %hipify_args 3 --skip-excluded-preprocessor-conditional-blocks --experimental --roc %clang_args -ferror-limit=500
2
3 // CHECK: #include <hip/hip_runtime.h>
4 #include <cuda_runtime.h>
5 // CHECK: #include "hip/hip_complex.h"
6 #include "cuComplex.h"
7 #include <stdio.h>
8 // CHECK: #include "rocsparse.h"
9 #include "cusparse.h"
10 // CHECK-NOT: #include "rocsparse.h"
11
12 int main() {
13 printf("18.11030.12000. cuSPARSE API to rocSPARSE API synthetic test\n");
14
15 // CHECK: rocsparse_status status_t;
16 cusparseStatus_t status_t;
17
18 // CHECK: _rocsparse_handle *handle = nullptr;
19 // CHECK-NEXT: rocsparse_handle handle_t;
20 cusparseContext *handle = nullptr;
21 cusparseHandle_t handle_t;
22
23 // CHECK: _rocsparse_mat_descr *matDescr = nullptr;
24 // CHECK-NEXT: rocsparse_mat_descr matDescr_t, matDescr_t_2, matDescr_A, matDescr_B, matDescr_C, matDescr_D;
25 cusparseMatDescr *matDescr = nullptr;
26 cusparseMatDescr_t matDescr_t, matDescr_t_2, matDescr_A, matDescr_B, matDescr_C, matDescr_D;
27
28 // CHECK: rocsparse_operation opA, opB, opX;
29 cusparseOperation_t opA, opB, opX;
30
31 // CHECK: rocsparse_solve_policy solvePolicy_t;
32 cusparseSolvePolicy_t solvePolicy_t;
33
34 int m = 0;
35 int n = 0;
36 int k = 0;
37 int innz = 0;
38 int nnza = 0;
39 int nnzb = 0;
40 int nnzc = 0;
41 int nnzd = 0;
42 int csrRowPtrA = 0;
43 int csrRowPtrB = 0;
44 int csrRowPtrC = 0;
45 int csrRowPtrD = 0;
46 int csrColIndA = 0;
47 int csrColIndB = 0;
48 int csrColIndC = 0;
49 int csrColIndD = 0;
50 int bufferSizeInBytes = 0;
51 size_t bufferSize = 0;
52 double dA = 0.f;
53 double dB = 0.f;
54 double dAlpha = 0.f;
55 double dF = 0.f;
56 double dX = 0.f;
57 double dcsrSortedValA = 0.f;
58 double dcsrSortedValB = 0.f;
59 double dcsrSortedValC = 0.f;
60 double dcsrSortedValD = 0.f;
61 float fAlpha = 0.f;
62 float fA = 0.f;
63 float fB = 0.f;
64 float fF = 0.f;
65 float fX = 0.f;
66 float csrSortedValA = 0.f;
67 float csrSortedValB = 0.f;
68 float csrSortedValC = 0.f;
69 float csrSortedValD = 0.f;
70 void *alpha = nullptr;
71 void *pBuffer = nullptr;
72 void *tempBuffer = nullptr;
73
74 // TODO: should be rocsparse_double_complex
75 // TODO: add to TypeOverloads cuDoubleComplex -> rocsparse_double_complex under a new option --sparse
76 // CHECK: rocblas_double_complex dcomplex, dcomplexA, dcomplexAlpha, dcomplexB, dcomplexBeta, dcomplexC, dcomplexF, dcomplexX, dcomplexY, dComplexbsrSortedValA, dComplexbsrSortedValC, dComplexcsrSortedValA, dComplexcsrSortedValB, dComplexcsrSortedValC, dComplexcsrSortedValD, dcomplextol, dComplexbsrSortedVal, dComplexbscVal, dComplexcscSortedVal, dcomplexds, dcomplexdl, dcomplexd, dcomplexdu, dcomplexdw, dcomplexx, dcomplex_boost_val;
77 cuDoubleComplex dcomplex, dcomplexA, dcomplexAlpha, dcomplexB, dcomplexBeta, dcomplexC, dcomplexF, dcomplexX, dcomplexY, dComplexbsrSortedValA, dComplexbsrSortedValC, dComplexcsrSortedValA, dComplexcsrSortedValB, dComplexcsrSortedValC, dComplexcsrSortedValD, dcomplextol, dComplexbsrSortedVal, dComplexbscVal, dComplexcscSortedVal, dcomplexds, dcomplexdl, dcomplexd, dcomplexdu, dcomplexdw, dcomplexx, dcomplex_boost_val;
78
79 // TODO: should be rocsparse_double_complex
80 // TODO: add to TypeOverloads cuComplex -> rocsparse_float_complex under a new option --sparse
81 // CHECK: rocblas_float_complex complex, complexA, complexAlpha, complexB, complexBeta, complexC, complexF, complexX, complexY, complexbsrValA, complexbsrSortedValC, complexcsrSortedValA, complexcsrSortedValB, complexcsrSortedValC, complexcsrSortedValD, complextol, complexbsrSortedVal, complexbscVal, complexcscSortedVal, complexds, complexdl, complexd, complexdu, complexdw, complexx, complex_boost_val;
82 cuComplex complex, complexA, complexAlpha, complexB, complexBeta, complexC, complexF, complexX, complexY, complexbsrValA, complexbsrSortedValC, complexcsrSortedValA, complexcsrSortedValB, complexcsrSortedValC, complexcsrSortedValD, complextol, complexbsrSortedVal, complexbscVal, complexcscSortedVal, complexds, complexdl, complexd, complexdu, complexdw, complexx, complex_boost_val;
83
84 #if CUDA_VERSION >= 8000
85 // TODO: [#899] There should be rocsparse_datatype instead of hipDataType
86 cudaDataType_t dataType_t;
87 cudaDataType dataType;
88 #endif
89
90 #if (CUDA_VERSION >= 10010 && CUDA_VERSION < 11000 && !defined(_WIN32)) || CUDA_VERSION >= 11000
91 // CHECK: rocsparse_spmat_descr spMatDescr_t, spmatA, spmatB, spmatC;
92 cusparseSpMatDescr_t spMatDescr_t, spmatA, spmatB, spmatC;
93
94 // CHECK: rocsparse_dnmat_descr dnMatDescr_t, dnmatA, dnmatB, dnmatC;
95 cusparseDnMatDescr_t dnMatDescr_t, dnmatA, dnmatB, dnmatC;
96 #endif
97
98 #if CUDA_VERSION >= 11030 && CUSPARSE_VERSION >= 11600
99 // CHECK: rocsparse_spsm_alg spSMAlg_t;
100 cusparseSpSMAlg_t spSMAlg_t;
101
102 // NOTE:cusparseSpSMDescr_t doesn't have a correspondence in rocSPARSE, the corresponding function argument is removed in the hipified call of the rocsparse_spsm function
103 cusparseSpSMDescr_t spSMDescr;
104
105 #if CUDA_VERSION < 12000
106 // CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpSM_analysis(cusparseHandle_t handle, cusparseOperation_t opA, cusparseOperation_t opB, const void* alpha, cusparseSpMatDescr_t matA, cusparseDnMatDescr_t matB, cusparseDnMatDescr_t matC, cudaDataType computeType, cusparseSpSMAlg_t alg, cusparseSpSMDescr_t spsmDescr, void* externalBuffer);
107 // ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_spsm(rocsparse_handle handle, rocsparse_operation trans_A, rocsparse_operation trans_B, const void* alpha, const rocsparse_spmat_descr matA, const rocsparse_dnmat_descr matB, const rocsparse_dnmat_descr matC, rocsparse_datatype compute_type, rocsparse_spsm_alg alg, rocsparse_spsm_stage stage, size_t* buffer_size, void* temp_buffer);
108 // CHECK: status_t = rocsparse_spsm(handle_t, opA, opB, alpha, spmatA, dnmatB, dnmatC, dataType, spSMAlg_t, rocsparse_spsm_stage_compute, nullptr, tempBuffer);
109 status_t = cusparseSpSM_analysis(handle_t, opA, opB, alpha, spmatA, dnmatB, dnmatC, dataType, spSMAlg_t, spSMDescr, tempBuffer);
110
111 // CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpSM_solve(cusparseHandle_t handle, cusparseOperation_t opA, cusparseOperation_t opB, const void* alpha, cusparseSpMatDescr_t matA, cusparseDnMatDescr_t matB, cusparseDnMatDescr_t matC, cudaDataType computeType, cusparseSpSMAlg_t alg, cusparseSpSMDescr_t spsmDescr);
112 // ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_spsm(rocsparse_handle handle, rocsparse_operation trans_A, rocsparse_operation trans_B, const void* alpha, const rocsparse_spmat_descr matA, const rocsparse_dnmat_descr matB, const rocsparse_dnmat_descr matC, rocsparse_datatype compute_type, rocsparse_spsm_alg alg, rocsparse_spsm_stage stage, size_t* buffer_size, void* temp_buffer);
113 // CHECK: status_t = rocsparse_spsm(handle_t, opA, opB, alpha, spmatA, dnmatB, dnmatC, dataType, spSMAlg_t, rocsparse_spsm_stage_compute, nullptr, nullptr);
114 status_t = cusparseSpSM_solve(handle_t, opA, opB, alpha, spmatA, dnmatB, dnmatC, dataType, spSMAlg_t, spSMDescr);
115 #endif
116 #endif
117
118 return 0;
119 }