Debian Codegraph @

tests/unit_tests/synthetic/libraries/cusparse2hipsparse_12000.cu

raw
1 // RUN: %run_test hipify "%s" "%t" %hipify_args 2 --skip-excluded-preprocessor-conditional-blocks --experimental %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 "hipsparse.h"
9 #include "cusparse.h"
10 // CHECK-NOT: #include "hipsparse.h"
11
12 #if defined(_WIN32) && CUDA_VERSION < 9000
13 typedef signed __int64 int64_t;
14 typedef unsigned __int64 uint64_t;
15 #endif
16
17 int main() {
18 printf("17.12000. cuSPARSE API to hipSPARSE API synthetic test\n");
19
20 // CHECK: hipsparseStatus_t status_t;
21 cusparseStatus_t status_t;
22
23 // CHECK: hipsparseHandle_t handle_t;
24 cusparseHandle_t handle_t;
25
26 // CHECK: hipsparseMatDescr_t matDescr_t, matDescr_t_2, matDescr_A, matDescr_B, matDescr_C, matDescr_D;
27 cusparseMatDescr_t matDescr_t, matDescr_t_2, matDescr_A, matDescr_B, matDescr_C, matDescr_D;
28
29 // CHECK: hipsparseOperation_t opA, opB, opX;
30 cusparseOperation_t opA, opB, opX;
31
32 // CHECK: hipsparseSolvePolicy_t solvePolicy_t;
33 cusparseSolvePolicy_t solvePolicy_t;
34
35 int m = 0;
36 int n = 0;
37 int k = 0;
38 int innz = 0;
39 int nnza = 0;
40 int nnzb = 0;
41 int nnzc = 0;
42 int nnzd = 0;
43 int csrRowPtrA = 0;
44 int csrRowPtrB = 0;
45 int csrRowPtrC = 0;
46 int csrRowPtrD = 0;
47 int csrColIndA = 0;
48 int csrColIndB = 0;
49 int csrColIndC = 0;
50 int csrColIndD = 0;
51 int bufferSizeInBytes = 0;
52 size_t bufferSize = 0;
53 double dA = 0.f;
54 double dB = 0.f;
55 double dAlpha = 0.f;
56 double dF = 0.f;
57 double dX = 0.f;
58 double dcsrSortedValA = 0.f;
59 double dcsrSortedValB = 0.f;
60 double dcsrSortedValC = 0.f;
61 double dcsrSortedValD = 0.f;
62 float fAlpha = 0.f;
63 float fA = 0.f;
64 float fB = 0.f;
65 float fF = 0.f;
66 float fX = 0.f;
67 float csrSortedValA = 0.f;
68 float csrSortedValB = 0.f;
69 float csrSortedValC = 0.f;
70 float csrSortedValD = 0.f;
71 void *alpha = nullptr;
72 void *pBuffer = nullptr;
73 void *tempBuffer = nullptr;
74
75 // CHECK: hipDoubleComplex 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;
76 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;
77
78 // CHECK: hipComplex 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;
79 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;
80
81 #if CUDA_VERSION >= 8000
82 // CHECK: hipDataType dataType_t;
83 // CHECK-NEXT: hipDataType dataType;
84 cudaDataType_t dataType_t;
85 cudaDataType dataType;
86 #endif
87
88 #if (CUDA_VERSION >= 10010 && CUDA_VERSION < 11000 && !defined(_WIN32)) || CUDA_VERSION >= 11000
89 // CHECK: hipsparseSpMatDescr_t spMatDescr_t, spmatA, spmatB, spmatC;
90 cusparseSpMatDescr_t spMatDescr_t, spmatA, spmatB, spmatC;
91
92 // CHECK: hipsparseDnMatDescr_t dnMatDescr_t, dnmatA, dnmatB, dnmatC;
93 cusparseDnMatDescr_t dnMatDescr_t, dnmatA, dnmatB, dnmatC;
94 #endif
95
96 #if CUDA_VERSION >= 11030 && CUSPARSE_VERSION >= 11600
97 // CHECK: hipsparseSpSMAlg_t spSMAlg_t;
98 cusparseSpSMAlg_t spSMAlg_t;
99
100 // CHECK: hipsparseSpSMDescr_t spSMDescr;
101 cusparseSpSMDescr_t spSMDescr;
102 #endif
103
104 #if CUDA_VERSION >= 12000
105 // CHECK: hipsparseCsr2CscAlg_t CSR2CSC_ALG_DEFAULT = HIPSPARSE_CSR2CSC_ALG_DEFAULT;
106 cusparseCsr2CscAlg_t CSR2CSC_ALG_DEFAULT = CUSPARSE_CSR2CSC_ALG_DEFAULT;
107
108 // CHECK: hipsparseConstSpVecDescr_t constSpVecDescr = nullptr;
109 cusparseConstSpVecDescr_t constSpVecDescr = nullptr;
110
111 // CHECK: hipsparseConstSpMatDescr_t constSpMatDescr = nullptr;
112 // CHECK-NEXT: hipsparseConstSpMatDescr_t constSpMatDescrB = nullptr;
113 cusparseConstSpMatDescr_t constSpMatDescr = nullptr;
114 cusparseConstSpMatDescr_t constSpMatDescrB = nullptr;
115
116 // CHECK: hipsparseConstDnVecDescr_t constDnVecDescr = nullptr;
117 cusparseConstDnVecDescr_t constDnVecDescr = nullptr;
118
119 // CHECK: hipsparseConstDnMatDescr_t constDnMatDescr = nullptr;
120 // CHECK-NEXT: hipsparseConstDnMatDescr_t constDnMatDescrB = nullptr;
121 cusparseConstDnMatDescr_t constDnMatDescr = nullptr;
122 cusparseConstDnMatDescr_t constDnMatDescrB = nullptr;
123
124 // CUDA: cusparseStatus_t CUSPARSEAPI cusparseSpSM_solve(cusparseHandle_t handle, cusparseOperation_t opA, cusparseOperation_t opB, const void* alpha, cusparseConstSpMatDescr_t matA, cusparseConstDnMatDescr_t matB, cusparseDnMatDescr_t matC, cudaDataType computeType, cusparseSpSMAlg_t alg, cusparseSpSMDescr_t spsmDescr);
125 // HIP: HIPSPARSE_EXPORT hipsparseStatus_t hipsparseSpSM_solve(hipsparseHandle_t handle, hipsparseOperation_t opA, hipsparseOperation_t opB, const void* alpha, hipsparseConstSpMatDescr_t matA, hipsparseConstDnMatDescr_t matB, const hipsparseDnMatDescr_t matC, hipDataType computeType, hipsparseSpSMAlg_t alg, hipsparseSpSMDescr_t spsmDescr, void* externalBuffer);
126 // CHECK: status_t = hipsparseSpSM_solve(handle_t, opA, opB, alpha, constSpMatDescr, constDnMatDescrB, dnmatC, dataType, spSMAlg_t, spSMDescr, nullptr);
127 status_t = cusparseSpSM_solve(handle_t, opA, opB, alpha, constSpMatDescr, constDnMatDescrB, dnmatC, dataType, spSMAlg_t, spSMDescr);
128 #endif
129
130 return 0;
131 }