| 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.10010. cuSPARSE API to rocSPARSE API synthetic test\n"); |
| 14 |
|
| 15 |
// CHECK: _rocsparse_handle *handle = nullptr; |
| 16 |
// CHECK-NEXT: rocsparse_handle handle_t; |
| 17 |
cusparseContext *handle = nullptr; |
| 18 |
cusparseHandle_t handle_t; |
| 19 |
|
| 20 |
// CHECK: rocsparse_status status_t; |
| 21 |
cusparseStatus_t status_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_action action_t; |
| 29 |
cusparseAction_t action_t; |
| 30 |
|
| 31 |
// CHECK: rocsparse_index_base indexBase_t; |
| 32 |
cusparseIndexBase_t indexBase_t; |
| 33 |
|
| 34 |
int m = 0; |
| 35 |
int n = 0; |
| 36 |
int innz = 0; |
| 37 |
int csrRowPtrA = 0; |
| 38 |
int csrRowPtrB = 0; |
| 39 |
int csrRowPtrC = 0; |
| 40 |
int cscRowIndA = 0; |
| 41 |
int csrColIndA = 0; |
| 42 |
int csrColIndB = 0; |
| 43 |
int csrColIndC = 0; |
| 44 |
int cscColPtrA = 0; |
| 45 |
size_t bufferSize = 0; |
| 46 |
void *pcsrVal = nullptr; |
| 47 |
void *pcscVal = nullptr; |
| 48 |
|
| 49 |
#if CUDA_VERSION >= 8000 |
| 50 |
// TODO: [#899] There should be rocsparse_datatype instead of hipDataType |
| 51 |
cudaDataType_t dataType_t; |
| 52 |
cudaDataType dataType; |
| 53 |
#endif |
| 54 |
|
| 55 |
#if CUDA_VERSION >= 10010 |
| 56 |
// TODO: cusparseCsr2CscAlg_t has no analogue in rocSPARSE. The deletion of declaration and usage is needed to be implemented |
| 57 |
cusparseCsr2CscAlg_t Csr2CscAlg_t; |
| 58 |
|
| 59 |
// CUDA: cusparseStatus_t CUSPARSEAPI cusparseCsr2cscEx2_bufferSize(cusparseHandle_t handle, int m, int n, int nnz, const void* csrVal, const int* csrRowPtr, const int* csrColInd, void* cscVal, int* cscColPtr, int* cscRowInd, cudaDataType valType, cusparseAction_t copyValues, cusparseIndexBase_t idxBase, cusparseCsr2CscAlg_t alg, size_t* bufferSize); |
| 60 |
// ROC: ROCSPARSE_EXPORT rocsparse_status rocsparse_csr2csc_buffer_size(rocsparse_handle handle, rocsparse_int m, rocsparse_int n, rocsparse_int nnz, const rocsparse_int* csr_row_ptr, const rocsparse_int* csr_col_ind, rocsparse_action copy_values, size_t* buffer_size); |
| 61 |
// CHECK: status_t = rocsparse_csr2csc_buffer_size(handle_t, m, n, innz, &csrRowPtrA, &csrColIndA, action_t, &bufferSize); |
| 62 |
status_t = cusparseCsr2cscEx2_bufferSize(handle_t, m, n, innz, pcsrVal, &csrRowPtrA, &csrColIndA, pcscVal, &cscColPtrA, &cscRowIndA, dataType, action_t, indexBase_t, Csr2CscAlg_t, &bufferSize); |
| 63 |
#endif |
| 64 |
|
| 65 |
return 0; |
| 66 |
} |