| 1 |
// RUN: %run_test hipify "%s" "%t" %hipify_args 4 --amap --skip-excluded-preprocessor-conditional-blocks --experimental --roc %clang_args -D__CUDA_API_VERSION_INTERNAL -ferror-limit=500 |
| 2 |
|
| 3 |
// CHECK: #include <hip/hip_runtime.h> |
| 4 |
#include <cuda_runtime.h> |
| 5 |
#include <stdio.h> |
| 6 |
// CHECK: #include "rocsolver/rocsolver.h" |
| 7 |
#include "cusolverDn.h" |
| 8 |
|
| 9 |
int main() { |
| 10 |
printf("20. cuSOLVER API to rocSOLVER API synthetic test\n"); |
| 11 |
|
| 12 |
int m = 0; |
| 13 |
int n = 0; |
| 14 |
int nrhs = 0; |
| 15 |
int lda = 0; |
| 16 |
int ldb = 0; |
| 17 |
int Lwork = 0; |
| 18 |
int devIpiv = 0; |
| 19 |
int devInfo = 0; |
| 20 |
float fA = 0.f; |
| 21 |
float fB = 0.f; |
| 22 |
float fX = 0.f; |
| 23 |
double dA = 0.f; |
| 24 |
double dB = 0.f; |
| 25 |
double dX = 0.f; |
| 26 |
float fWorkspace = 0.f; |
| 27 |
double dWorkspace = 0.f; |
| 28 |
void *Workspace = nullptr; |
| 29 |
size_t lwork_bytes = 0; |
| 30 |
|
| 31 |
// CHECK: rocblas_double_complex dComplexA, dComplexB, dComplexX, dComplexWorkspace; |
| 32 |
cuDoubleComplex dComplexA, dComplexB, dComplexX, dComplexWorkspace; |
| 33 |
|
| 34 |
// CHECK: rocblas_float_complex complexA, complexB, complexX, complexWorkspace; |
| 35 |
cuComplex complexA, complexB, complexX, complexWorkspace; |
| 36 |
|
| 37 |
// CHECK: rocblas_handle handle; |
| 38 |
cusolverDnHandle_t handle; |
| 39 |
|
| 40 |
// CHECK: hipStream_t stream_t; |
| 41 |
cudaStream_t stream_t; |
| 42 |
|
| 43 |
// CHECK: rocblas_fill fillMode; |
| 44 |
cublasFillMode_t fillMode; |
| 45 |
|
| 46 |
// CHECK: rocblas_status status; |
| 47 |
// CHECK-NEXT: rocblas_status STATUS_SUCCESS = rocblas_status_success; |
| 48 |
// CHECK-NEXT: rocblas_status STATUS_NOT_INITIALIZED = rocblas_status_invalid_handle; |
| 49 |
// CHECK-NEXT: rocblas_status STATUS_ALLOC_FAILED = rocblas_status_memory_error; |
| 50 |
// CHECK-NEXT: rocblas_status STATUS_INVALID_VALUE = rocblas_status_invalid_value; |
| 51 |
// CHECK-NEXT: rocblas_status STATUS_ARCH_MISMATCH = rocblas_status_arch_mismatch; |
| 52 |
// CHECK-NEXT: rocblas_status STATUS_MAPPING_ERROR = rocblas_status_not_implemented; |
| 53 |
// CHECK-NEXT: rocblas_status STATUS_EXECUTION_FAILED = rocblas_status_not_implemented; |
| 54 |
// CHECK-NEXT: rocblas_status STATUS_INTERNAL_ERROR = rocblas_status_internal_error; |
| 55 |
// CHECK-NEXT: rocblas_status STATUS_NOT_SUPPORTED = rocblas_status_not_implemented; |
| 56 |
// CHECK-NEXT: rocblas_status STATUS_ZERO_PIVOT = rocblas_status_not_implemented; |
| 57 |
cusolverStatus_t status; |
| 58 |
cusolverStatus_t STATUS_SUCCESS = CUSOLVER_STATUS_SUCCESS; |
| 59 |
cusolverStatus_t STATUS_NOT_INITIALIZED = CUSOLVER_STATUS_NOT_INITIALIZED; |
| 60 |
cusolverStatus_t STATUS_ALLOC_FAILED = CUSOLVER_STATUS_ALLOC_FAILED; |
| 61 |
cusolverStatus_t STATUS_INVALID_VALUE = CUSOLVER_STATUS_INVALID_VALUE; |
| 62 |
cusolverStatus_t STATUS_ARCH_MISMATCH = CUSOLVER_STATUS_ARCH_MISMATCH; |
| 63 |
cusolverStatus_t STATUS_MAPPING_ERROR = CUSOLVER_STATUS_MAPPING_ERROR; |
| 64 |
cusolverStatus_t STATUS_EXECUTION_FAILED = CUSOLVER_STATUS_EXECUTION_FAILED; |
| 65 |
cusolverStatus_t STATUS_INTERNAL_ERROR = CUSOLVER_STATUS_INTERNAL_ERROR; |
| 66 |
cusolverStatus_t STATUS_NOT_SUPPORTED = CUSOLVER_STATUS_NOT_SUPPORTED; |
| 67 |
cusolverStatus_t STATUS_ZERO_PIVOT = CUSOLVER_STATUS_ZERO_PIVOT; |
| 68 |
|
| 69 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnCreate(cusolverDnHandle_t *handle); |
| 70 |
// ROC: ROCBLAS_EXPORT rocblas_status rocblas_create_handle(rocblas_handle* handle); |
| 71 |
// CHECK: status = rocblas_create_handle(&handle); |
| 72 |
status = cusolverDnCreate(&handle); |
| 73 |
|
| 74 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnDestroy(cusolverDnHandle_t handle); |
| 75 |
// ROC: ROCBLAS_EXPORT rocblas_status rocblas_destroy_handle(rocblas_handle handle); |
| 76 |
// CHECK: status = rocblas_destroy_handle(handle); |
| 77 |
status = cusolverDnDestroy(handle); |
| 78 |
|
| 79 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnSetStream(cusolverDnHandle_t handle, cudaStream_t streamId); |
| 80 |
// ROC: ROCBLAS_EXPORT rocblas_status rocblas_set_stream(rocblas_handle handle, hipStream_t stream); |
| 81 |
// CHECK: status = rocblas_set_stream(handle, stream_t); |
| 82 |
status = cusolverDnSetStream(handle, stream_t); |
| 83 |
|
| 84 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnGetStream(cusolverDnHandle_t handle, cudaStream_t *streamId); |
| 85 |
// ROC: ROCBLAS_EXPORT rocblas_status rocblas_get_stream(rocblas_handle handle, hipStream_t* stream); |
| 86 |
// CHECK: status = rocblas_get_stream(handle, &stream_t); |
| 87 |
status = cusolverDnGetStream(handle, &stream_t); |
| 88 |
|
| 89 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnSpotrf(cusolverDnHandle_t handle, cublasFillMode_t uplo, int n, float * A, int lda, float * Workspace, int Lwork, int * devInfo); |
| 90 |
// ROC: ROCSOLVER_EXPORT rocblas_status rocsolver_spotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, float* A, const rocblas_int lda, rocblas_int* info); |
| 91 |
// CHECK: status = rocsolver_spotrf(handle, fillMode, n, &fA, lda, &fWorkspace, Lwork, &devInfo); |
| 92 |
status = cusolverDnSpotrf(handle, fillMode, n, &fA, lda, &fWorkspace, Lwork, &devInfo); |
| 93 |
|
| 94 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnDpotrf(cusolverDnHandle_t handle, cublasFillMode_t uplo, int n, double * A, int lda, double * Workspace, int Lwork, int * devInfo); |
| 95 |
// ROC: ROCSOLVER_EXPORT rocblas_status rocsolver_dpotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, double* A, const rocblas_int lda, rocblas_int* info); |
| 96 |
// CHECK: status = rocsolver_dpotrf(handle, fillMode, n, &dA, lda, &dWorkspace, Lwork, &devInfo); |
| 97 |
status = cusolverDnDpotrf(handle, fillMode, n, &dA, lda, &dWorkspace, Lwork, &devInfo); |
| 98 |
|
| 99 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnCpotrf(cusolverDnHandle_t handle, cublasFillMode_t uplo, int n, cuComplex * A, int lda, cuComplex * Workspace, int Lwork, int * devInfo); |
| 100 |
// ROC: ROCSOLVER_EXPORT rocblas_status rocsolver_cpotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, rocblas_float_complex* A, const rocblas_int lda, rocblas_int* info); |
| 101 |
// CHECK: status = rocsolver_cpotrf(handle, fillMode, n, &complexA, lda, &complexWorkspace, Lwork, &devInfo); |
| 102 |
status = cusolverDnCpotrf(handle, fillMode, n, &complexA, lda, &complexWorkspace, Lwork, &devInfo); |
| 103 |
|
| 104 |
// CUDA: cusolverStatus_t CUSOLVERAPI cusolverDnZpotrf(cusolverDnHandle_t handle, cublasFillMode_t uplo, int n, cuDoubleComplex * A, int lda, cuDoubleComplex * Workspace, int Lwork, int * devInfo); |
| 105 |
// ROC: ROCSOLVER_EXPORT rocblas_status rocsolver_zpotrf(rocblas_handle handle, const rocblas_fill uplo, const rocblas_int n, rocblas_double_complex* A, const rocblas_int lda, rocblas_int* info); |
| 106 |
// CHECK: status = rocsolver_zpotrf(handle, fillMode, n, &dComplexA, lda, &dComplexWorkspace, Lwork, &devInfo); |
| 107 |
status = cusolverDnZpotrf(handle, fillMode, n, &dComplexA, lda, &dComplexWorkspace, Lwork, &devInfo); |
| 108 |
|
| 109 |
#if CUDA_VERSION >= 8000 |
| 110 |
// CHECK: rocblas_eform eigType; |
| 111 |
// CHECK-NEXT: rocblas_eform EIG_TYPE_1 = rocblas_eform_ax; |
| 112 |
// CHECK-NEXT: rocblas_eform EIG_TYPE_2 = rocblas_eform_abx; |
| 113 |
// CHECK-NEXT: rocblas_eform EIG_TYPE_3 = rocblas_eform_bax; |
| 114 |
cusolverEigType_t eigType; |
| 115 |
cusolverEigType_t EIG_TYPE_1 = CUSOLVER_EIG_TYPE_1; |
| 116 |
cusolverEigType_t EIG_TYPE_2 = CUSOLVER_EIG_TYPE_2; |
| 117 |
cusolverEigType_t EIG_TYPE_3 = CUSOLVER_EIG_TYPE_3; |
| 118 |
|
| 119 |
// CHECK: rocblas_evect eigMode; |
| 120 |
// CHECK-NEXT: rocblas_evect SOLVER_EIG_MODE_NOVECTOR = rocblas_evect_none; |
| 121 |
// CHECK-NEXT: rocblas_evect SOLVER_EIG_MODE_VECTOR = rocblas_evect_original; |
| 122 |
cusolverEigMode_t eigMode; |
| 123 |
cusolverEigMode_t SOLVER_EIG_MODE_NOVECTOR = CUSOLVER_EIG_MODE_NOVECTOR; |
| 124 |
cusolverEigMode_t SOLVER_EIG_MODE_VECTOR = CUSOLVER_EIG_MODE_VECTOR; |
| 125 |
#endif |
| 126 |
|
| 127 |
#if CUDA_VERSION >= 10010 |
| 128 |
// CHECK: rocblas_erange eigRange; |
| 129 |
// CHECK-NEXT: rocblas_erange EIG_RANGE_ALL = rocblas_erange_all; |
| 130 |
// CHECK-NEXT: rocblas_erange EIG_RANGE_I = rocblas_erange_index; |
| 131 |
// CHECK-NEXT: rocblas_erange EIG_RANGE_V = rocblas_erange_value; |
| 132 |
cusolverEigRange_t eigRange; |
| 133 |
cusolverEigRange_t EIG_RANGE_ALL = CUSOLVER_EIG_RANGE_ALL; |
| 134 |
cusolverEigRange_t EIG_RANGE_I = CUSOLVER_EIG_RANGE_I; |
| 135 |
cusolverEigRange_t EIG_RANGE_V = CUSOLVER_EIG_RANGE_V; |
| 136 |
#endif |
| 137 |
|
| 138 |
return 0; |
| 139 |
} |