Merge pull request #1 from ROCm-Developer-Tools/master

Updating fork with latest code from origin
Этот коммит содержится в:
amd-stanley
2018-12-06 13:28:25 -07:00
коммит произвёл GitHub
родитель 0a1584b075 d3654e12e4
Коммит 418af2245c
88 изменённых файлов: 9343 добавлений и 723 удалений
+19
Просмотреть файл
@@ -150,6 +150,23 @@ if(NOT DEFINED COMPILE_HIP_ATP_MARKER)
endif()
add_to_config(_buildInfo COMPILE_HIP_ATP_MARKER)
################
# Detect profiling API
################
if(USE_PROF_API EQUAL 1)
if(NOT DEFINED PROF_API_HEADER_PATH)
set(PROF_API_HEADER_PATH /opt/rocm/roctracer/include/ext)
endif ()
find_path(PROF_API_HEADER_DIR NAMES prof_protocol.h PATHS ${PROF_API_HEADER_PATH} NO_DEFAULT_PATH)
if(NOT PROF_API_HEADER_DIR)
MESSAGE("PROF_API_HEADER_PATH = ${PROF_API_HEADER_PATH}")
MESSAGE(FATAL_ERROR "Profiling API header not found, use -DPROF_API_HEADER_PATH=<path to prof_protocol.h header>")
else()
add_definitions(-DUSE_PROF_API=1)
include_directories ( ${PROF_API_HEADER_DIR} )
MESSAGE(STATUS "Profiling API: ${PROF_API_HEADER_DIR}")
endif()
endif()
#############################
# Build steps
@@ -196,6 +213,7 @@ if(HIP_PLATFORM STREQUAL "hcc")
src/hip_device.cpp
src/hip_error.cpp
src/hip_event.cpp
src/hip_fatbin.cpp
src/hip_memory.cpp
src/hip_peer.cpp
src/hip_stream.cpp
@@ -204,6 +222,7 @@ if(HIP_PLATFORM STREQUAL "hcc")
src/grid_launch.cpp
src/hip_texture.cpp
src/hip_surface.cpp
src/hip_intercept.cpp
src/env.cpp
src/program_state.cpp)
поставляемый
+46 -3
Просмотреть файл
@@ -167,8 +167,6 @@ def docker_build_inside_image( def build_image, String inside_args, String platf
}
// Cap the maximum amount of testing, in case of hangs
// Excluding hipVectorTypes test from automation; due to regression from HCC commit 2367133
// Excluding hipFloatMath test from automation; due to regression from ROCDL commit 2fc04e1
timeout(time: 1, unit: 'HOURS')
{
stage("${platform} unit testing")
@@ -178,7 +176,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf
cd ${build_dir_rel}
make install -j\$(nproc)
make build_tests -i -j\$(nproc)
ctest -E "(hipVectorTypes.tst|hipVectorTypesDevice.tst|hipFloatMath.tst)"
ctest
"""
// If unit tests output a junit or xunit file in the future, jenkins can parse that file
// to display test results on the dashboard
@@ -342,6 +340,51 @@ parallel rocm_1_9:
*/
}
},
rocm_2_0:
{
node('hip-rocm')
{
String hcc_ver = 'rocm-2.0.x'
String from_image = 'ci_test_nodes/rocm-2.0.x/ubuntu-16.04:latest'
String inside_args = '--device=/dev/kfd --device=/dev/dri --group-add=video'
// Checkout source code, dependencies and version files
String source_hip_rel = checkout_and_version( hcc_ver )
// Create/reuse a docker image that represents the hip build environment
def hip_build_image = docker_build_image( hcc_ver, 'hip', '', source_hip_rel, from_image )
// Print system information for the log
hip_build_image.inside( inside_args )
{
sh """#!/usr/bin/env bash
set -x
/opt/rocm/bin/rocm_agent_enumerator -t ALL
/opt/rocm/bin/hcc --version
"""
}
// Conctruct a binary directory path based on build config
String build_hip_rel = build_directory_rel( build_config );
// Build hip inside of the build environment
docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel )
// Clean docker build image
docker_clean_images( 'hip', docker_build_image_name( ) )
// After a successful build, upload a docker image of the results
/*
String hip_image_name = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel )
if( params.push_image_to_docker_hub )
{
docker_upload_dockerhub( job_name, hip_image_name, 'rocm' )
docker_clean_images( 'rocm', hip_image_name )
}
docker_clean_images( job_name, hip_image_name )
*/
}
},
rocm_head:
{
node('hip-rocm')
+16 -4
Просмотреть файл
@@ -95,15 +95,19 @@ $HIP_VERSION= `$HIP_PATH/bin/hipconfig --version`;
($HIP_VERSION_MAJOR, $HIP_VERSION_MINOR, $HIP_VERSION_PATCH) = split(/\./, $HIP_VERSION);
if (defined $HIP_VDI_HOME) {
my $bits = "";
if (-d "$HIP_VDI_HOME/bin/x86_64") {
$bits = "/x86_64";
}
if (!defined $HIP_CLANG_PATH) {
$HIP_CLANG_PATH = "$HIP_VDI_HOME/bin/x86_64";
$HIP_CLANG_PATH = "$HIP_VDI_HOME/bin" . $bits;
}
if (!defined $DEVICE_LIB_PATH) {
$DEVICE_LIB_PATH = "$HIP_VDI_HOME/lib/x86_64/bitcode";
$DEVICE_LIB_PATH = "$HIP_VDI_HOME/lib" . $bits . "/bitcode";
}
$HIP_CLANG_INCLUDE_PATH = "$HIP_VDI_HOME/include/clang";
$HIP_INCLUDE_PATH = "$HIP_VDI_HOME/include";
$HIP_LIB_PATH = "$HIP_VDI_HOME/lib/x86_64";
$HIP_LIB_PATH = "$HIP_VDI_HOME/lib" . $bits;
}
if (defined $HIP_CLANG_PATH) {
@@ -334,7 +338,7 @@ foreach $arg (@ARGV)
$trimarg = $arg;
$trimarg =~ s/^\s+|\s+$//g; # Remive whitespace
my $swallowArg = 0;
if ($arg eq '-c') {
if ($arg eq '-c' or $arg eq '--genco') {
$compileOnly = 1;
$needCXXFLAGS = 1;
$needLDFLAGS = 0;
@@ -386,6 +390,10 @@ foreach $arg (@ARGV)
$swallowArg = 1;
}
if (($arg =~ /--genco/) and $HIP_PLATFORM eq 'clang' ) {
$arg = "--cuda-device-only";
}
if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0))
{
$HIPCXXFLAGS .= $HCC_WA_FLAGS;
@@ -498,6 +506,10 @@ foreach $arg (@ARGV)
$obj = "$tmpdir/$obj";
my $fileType = `file $obj`;
my $isObj = ($fileType =~ m/ELF/ or $fileType =~ m/COFF/);
if ($fileType =~ m/ELF/) {
my $sections = `readelf -e -W $obj`;
$isObj = !($sections =~ m/__CLANG_OFFLOAD_BUNDLE__/);
}
$allIsObj = ($allIsObj and $isObj);
if ($isObj) {
$realObjs = ($realObjs . " " . $obj);
+3
Просмотреть файл
@@ -287,6 +287,9 @@ while (@ARGV) {
$ft{'mem'} += s/\bcudaMemcpy2DToArray\b/hipMemcpy2DToArray/g;
$ft{'mem'} += s/\bcudaMemcpyToArray\b/hipMemcpyToArray/g;
$ft{'mem'} += s/\bcudaGetSymbolAddress\b/hipGetSymbolAddress/g;
$ft{'mem'} += s/\bcudaGetSymbolSize\b/hipGetSymbolSize/g;
#--------
# Memory management:
$ft{'mem'} += s/\bcudaMalloc\b/hipMalloc/g;
+24 -19
Просмотреть файл
@@ -22,8 +22,8 @@
| typedef |`CUDA_RESOURCE_VIEW_DESC_st` | |
| struct |`CUDA_TEXTURE_DESC` | |
| typedef |`CUDA_TEXTURE_DESC_st` | |
| struct |`CUdevprop` |`hipDeviceProp_t` |
| typedef |`CUdevprop_st` |`hipDeviceProp_t` |
| struct |`CUdevprop` | |
| typedef |`CUdevprop_st` | |
| struct |`CUipcEventHandle` |`ihipIpcEventHandle_t` |
| typedef |`CUipcEventHandle_st` |`ihipIpcEventHandle_t` |
| struct |`CUipcMemHandle` |`hipIpcMemHandle_t` |
@@ -763,6 +763,7 @@
| `cuDeviceGetName` | `hipDeviceGetName` |
| `cuDeviceTotalMem` | `hipDeviceTotalMem` |
| `cuDeviceGetLuid` | |
| `cuDeviceGetUuid` | |
## **6. Device Management [DEPRECATED]**
@@ -792,9 +793,9 @@
| `cuCtxGetCurrent` | `hipCtxGetCurrent` |
| `cuCtxGetDevice` | `hipCtxGetDevice` |
| `cuCtxGetFlags` | `hipCtxGetFlags` |
| `cuCtxGetLimit` | |
| `cuCtxGetLimit` | `hipDeviceGetLimit` |
| `cuCtxGetSharedMemConfig` | `hipCtxGetSharedMemConfig` |
| `cuCtxGetStreamPriorityRange` | |
| `cuCtxGetStreamPriorityRange` | `hipDeviceGetStreamPriorityRange`|
| `cuCtxPopCurrent` | `hipCtxPopCurrent` |
| `cuCtxPushCurrent` | `hipCtxPushCurrent` |
| `cuCtxSetCacheConfig` | `hipCtxSetCacheConfig` |
@@ -835,16 +836,16 @@
|-----------------------------------------------------------|-------------------------------|
| `cuArray3DCreate` | `hipArray3DCreate` |
| `cuArray3DGetDescriptor` | |
| `cuArrayCreate` | |
| `cuArrayCreate` | `hipArrayCreate` |
| `cuArrayDestroy` | |
| `cuArrayGetDescriptor` | |
| `cuDeviceGetByPCIBusId` | `hipDeviceGetByPCIBusId` |
| `cuDeviceGetPCIBusId` | `hipDeviceGetPCIBusId` |
| `cuIpcCloseMemHandle` | |
| `cuIpcCloseMemHandle` | `hipIpcCloseMemHandle` |
| `cuIpcGetEventHandle` | |
| `cuIpcGetMemHandle` | |
| `cuIpcGetMemHandle` | `hipIpcGetMemHandle` |
| `cuIpcOpenEventHandle` | |
| `cuIpcOpenMemHandle` | |
| `cuIpcOpenMemHandle` | `hipIpcOpenMemHandle` |
| `cuMemAlloc` | `hipMalloc` |
| `cuMemAllocHost` | |
| `cuMemAllocManaged` | |
@@ -867,7 +868,7 @@
| `cuMemcpyDtoDAsync` | `hipMemcpyDtoDAsync` |
| `cuMemcpyDtoH` | `hipMemcpyDtoH` |
| `cuMemcpyDtoHAsync` | `hipMemcpyDtoHAsync` |
| `cuMemcpyHtoA` | |
| `cuMemcpyHtoA` | `hipMemcpyHtoA` |
| `cuMemcpyHtoAAsync` | |
| `cuMemcpyHtoD` | `hipMemcpyHtoD` |
| `cuMemcpyHtoDAsync` | `hipMemcpyHtoDAsync` |
@@ -875,11 +876,11 @@
| `cuMemcpyPeerAsync` | |
| `cuMemFree` | `hipFree` |
| `cuMemFreeHost` | `hipFreeHost` |
| `cuMemGetAddressRange` | |
| `cuMemGetAddressRange` | `hipMemGetAddressRange` |
| `cuMemGetInfo` | `hipMemGetInfo` |
| `cuMemHostAlloc` | `hipHostMalloc` |
| `cuMemHostGetDevicePointer` | |
| `cuMemHostGetFlags` | |
| `cuMemHostGetDevicePointer` | `hipHostGetDevicePointer` |
| `cuMemHostGetFlags` | `hipHostGetFlags` |
| `cuMemHostRegister` | `hipHostRegister` |
| `cuMemHostUnregister` | `hipHostUnregister` |
| `cuMemsetD16` | |
@@ -892,8 +893,8 @@
| `cuMemsetD2D8Async` | |
| `cuMemsetD32` | `hipMemset` |
| `cuMemsetD32Async` | `hipMemsetAsync` |
| `cuMemsetD2D8` | |
| `cuMemsetD2D8Async` | |
| `cuMemsetD8` | `hipMemsetD8` |
| `cuMemsetD8Async` | |
| `cuMipmappedArrayCreate` | |
| `cuMipmappedArrayDestroy` | |
| `cuMipmappedArrayGetLevel` | |
@@ -916,8 +917,8 @@
|-----------------------------------------------------------|-------------------------------|
| `cuStreamAddCallback` | `hipStreamAddCallback` |
| `cuStreamAttachMemAsync` | |
| `cuStreamCreate` | |
| `cuStreamCreateWithPriority` | |
| `cuStreamCreate` | `hipStreamCreateWithFlags` |
| `cuStreamCreateWithPriority` | `hipStreamCreateWithPriority` |
| `cuStreamDestroy` | `hipStreamDestroy` |
| `cuStreamGetFlags` | `hipStreamGetFlags` |
| `cuStreamGetPriority` | `hipStreamGetPriority` |
@@ -932,7 +933,7 @@
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------|
| `cuEventCreate` | `hipEventCreate` |
| `cuEventCreate` | `hipEventCreateWithFlags` |
| `cuEventDestroy` | `hipEventDestroy` |
| `cuEventElapsedTime` | `hipEventElapsedTime` |
| `cuEventQuery` | `hipEventQuery` |
@@ -967,10 +968,13 @@
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------|
| `cuFuncGetAttribute` | |
| `cuFuncSetAttribute` | |
| `cuFuncSetCacheConfig` | `hipFuncSetCacheConfig` |
| `cuFuncSetSharedMemConfig` | |
| `cuLaunchKernel` | `hipModuleLaunchKernel` |
| `cuLaunchHostFunc` | |
| `cuLaunchCooperativeKernel` | |
| `cuLaunchCooperativeKernelMultiDevice` | |
## **18. Execution Control [DEPRECATED]**
@@ -1047,8 +1051,8 @@
| `cuTexRefGetMipmapLevelBias` | |
| `cuTexRefGetMipmapLevelClamp` | |
| `cuTexRefGetMipmappedArray` | |
| `cuTexRefSetAddress` | |
| `cuTexRefSetAddress2D` | |
| `cuTexRefSetAddress` | `hipTexRefSetAddress` |
| `cuTexRefSetAddress2D` | `hipTexRefSetAddress2D` |
| `cuTexRefSetAddressMode` | `hipTexRefSetAddressMode` |
| `cuTexRefSetArray` | `hipTexRefSetArray` |
| `cuTexRefSetBorderColor` | |
@@ -1233,3 +1237,4 @@
| `cuEGLStreamProducerReturnFrame` | |
| `cuGraphicsEGLRegisterImage` | |
| `cuGraphicsResourceGetMappedEglFrame` | |
| `cuEventCreateFromEGLSync` | |
+19 -9
Просмотреть файл
@@ -11,7 +11,7 @@
| `cudaDeviceGetLimit` | `hipDeviceGetLimit` |
| `cudaDeviceGetPCIBusId` | `hipDeviceGetPCIBusId` |
| `cudaDeviceGetSharedMemConfig` | `hipDeviceGetSharedMemConfig` |
| `cudaDeviceGetStreamPriorityRange` | |
| `cudaDeviceGetStreamPriorityRange` | `hipDeviceGetStreamPriorityRange` |
| `cudaDeviceReset` | `hipDeviceReset` |
| `cudaDeviceSetCacheConfig` | `hipDeviceSetCacheConfig` |
| `cudaDeviceSetLimit` | `hipDeviceSetLimit` |
@@ -19,7 +19,7 @@
| `cudaDeviceSynchronize` | `hipDeviceSynchronize` |
| `cudaGetDevice` | `hipGetDevice` |
| `cudaGetDeviceCount` | `hipGetDeviceCount` |
| `cudaGetDeviceFlags` | |
| `cudaGetDeviceFlags` | `hipCtxGetFlags` |
| `cudaGetDeviceProperties` | `hipGetDeviceProperties` |
| `cudaIpcCloseMemHandle` | `hipIpcCloseMemHandle` |
| `cudaIpcGetEventHandle` | `hipIpcGetEventHandle` |
@@ -56,12 +56,15 @@
|-----------------------------------------------------------|-------------------------------|
| `cudaStreamAddCallback` | `hipStreamAddCallback` |
| `cudaStreamAttachMemAsync` | |
| `cudaStreamBeginCapture` | |
| `cudaStreamEndCapture` | |
| `cudaStreamIsCapturing` | |
| `cudaStreamCreate` | `hipStreamCreate` |
| `cudaStreamCreateWithFlags` | `hipStreamCreateWithFlags` |
| `cudaStreamCreateWithPriority` | |
| `cudaStreamCreateWithPriority` | `hipStreamCreateWithPriority` |
| `cudaStreamDestroy` | `hipStreamDestroy` |
| `cudaStreamGetFlags` | `hipStreamGetFlags` |
| `cudaStreamGetPriority` | |
| `cudaStreamGetPriority` | `hipStreamGetPriority` |
| `cudaStreamQuery` | `hipStreamQuery` |
| `cudaStreamSynchronize` | `hipStreamSynchronize` |
| `cudaStreamWaitEvent` | `hipStreamWaitEvent` |
@@ -82,7 +85,14 @@
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------|
| `cudaSignalExternalSemaphoresAsync` | |
| `cudaWaitExternalSemaphoresAsync` | |
| `cudaImportExternalMemory` | |
| `cudaExternalMemoryGetMappedBuffer` | |
| `cudaExternalMemoryGetMappedMipmappedArray` | |
| `cudaDestroyExternalMemory` | |
| `cudaImportExternalSemaphore` | |
| `cudaDestroyExternalSemaphore` | |
## **7. Execution Control**
@@ -122,8 +132,8 @@
| `cudaFreeHost` | `hipHostFree` |
| `cudaFreeMipmappedArray` | |
| `cudaGetMipmappedArrayLevel` | |
| `cudaGetSymbolAddress` | |
| `cudaGetSymbolSize` | |
| `cudaGetSymbolAddress` | `hipGetSymbolAddress` |
| `cudaGetSymbolSize` | `hipGetSymbolSize` |
| `cudaHostAlloc` | `hipHostMalloc` |
| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` |
| `cudaHostGetFlags` | `hipHostGetFlags` |
@@ -373,8 +383,8 @@
| `cudaCreateChannelDesc` | `hipCreateChannelDesc` |
| `cudaFuncGetAttributes` | |
| `cudaFuncSetCacheConfig` | |
| `cudaGetSymbolAddress` | |
| `cudaGetSymbolSize` | |
| `cudaGetSymbolAddress` | `hipGetSymbolAddress` |
| `cudaGetSymbolSize` | `hipGetSymbolSize` |
| `cudaGetTextureAlignmentOffset` | |
| `cudaLaunch` | |
| `cudaLaunchKernel` | |
+618
Просмотреть файл
@@ -0,0 +1,618 @@
# CUSPARSE API supported by HIP
## **1. cuSPARSE Data types**
| **type** | **CUDA** | **HIP** |
|-------------:|---------------------------------------------------------------|------------------------------------------------------------|
| enum |***`cusparseAction_t`*** |***`hipsparseAction_t`*** |
| 0 |*`CUSPARSE_ACTION_SYMBOLIC`* |*`HIPSPARSE_ACTION_SYMBOLIC`* |
| 1 |*`CUSPARSE_ACTION_NUMERIC`* |*`HIPSPARSE_ACTION_NUMERIC`* |
| enum |***`cusparseDirection_t`*** | |
| 0 |*`CUSPARSE_DIRECTION_ROW`* | |
| 1 |*`CUSPARSE_DIRECTION_COLUMN`* | |
| enum |***`cusparseHybPartition_t`*** |***`hipsparseHybPartition_t`*** |
| 0 |*`CUSPARSE_HYB_PARTITION_AUTO`* |*`HIPSPARSE_HYB_PARTITION_AUTO`* |
| 1 |*`CUSPARSE_HYB_PARTITION_USER`* |*`HIPSPARSE_HYB_PARTITION_USER`* |
| 2 |*`CUSPARSE_HYB_PARTITION_MAX`* |*`HIPSPARSE_HYB_PARTITION_MAX`* |
| enum |***`cusparseDiagType_t`*** |***`hipsparseDiagType_t`*** |
| 0 |*`CUSPARSE_DIAG_TYPE_NON_UNIT`* |*`HIPSPARSE_DIAG_TYPE_NON_UNIT`* |
| 1 |*`CUSPARSE_DIAG_TYPE_UNIT`* |*`HIPSPARSE_DIAG_TYPE_UNIT`* |
| enum |***`cusparseFillMode_t`*** |***`hipsparseFillMode_t`*** |
| 0 |*`CUSPARSE_FILL_MODE_LOWER`* |*`HIPSPARSE_FILL_MODE_LOWER`* |
| 1 |*`CUSPARSE_FILL_MODE_UPPER`* |*`HIPSPARSE_FILL_MODE_UPPER`* |
| enum |***`cusparseIndexBase_t`*** |***`hipsparseIndexBase_t`*** |
| 0 |*`CUSPARSE_INDEX_BASE_ZERO`* |*`HIPSPARSE_INDEX_BASE_ZERO`* |
| 1 |*`CUSPARSE_INDEX_BASE_ONE`* |*`HIPSPARSE_INDEX_BASE_ONE`* |
| enum |***`cusparseMatrixType_t`*** |***`hipsparseMatrixType_t`*** |
| 0 |*`CUSPARSE_MATRIX_TYPE_GENERAL`* |*`HIPSPARSE_MATRIX_TYPE_GENERAL`* |
| 1 |*`CUSPARSE_MATRIX_TYPE_SYMMETRIC`* |*`HIPSPARSE_MATRIX_TYPE_SYMMETRIC`* |
| 2 |*`CUSPARSE_MATRIX_TYPE_HERMITIAN`* |*`HIPSPARSE_MATRIX_TYPE_HERMITIAN`* |
| 3 |*`CUSPARSE_MATRIX_TYPE_TRIANGULAR`* |*`HIPSPARSE_MATRIX_TYPE_TRIANGULAR`* |
| enum |***`cusparseOperation_t`*** |***`hipsparseOperation_t`*** |
| 0 |*`CUSPARSE_OPERATION_NON_TRANSPOSE`* |*`HIPSPARSE_OPERATION_NON_TRANSPOSE`* |
| 1 |*`CUSPARSE_OPERATION_TRANSPOSE`* |*`HIPSPARSE_OPERATION_TRANSPOSE`* |
| 2 |*`CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE`* |*`HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE`* |
| enum |***`cusparsePointerMode_t`*** |***`hipsparsePointerMode_t`*** |
| 0 |*`CUSPARSE_POINTER_MODE_HOST`* |*`HIPSPARSE_POINTER_MODE_HOST`* |
| 1 |*`CUSPARSE_POINTER_MODE_DEVICE`* |*`HIPSPARSE_POINTER_MODE_DEVICE`* |
| enum |***`cusparseAlgMode_t`*** | |
| 0 |*`CUSPARSE_ALG0`* | |
| 1 |*`CUSPARSE_ALG1`* | |
| 0 |*`CUSPARSE_ALG_NAIVE`* | |
| 1 |*`CUSPARSE_ALG_MERGE_PATH`* | |
| enum |***`cusparseSolvePolicy_t`*** |***`hipsparseSolvePolicy_t`*** |
| 0 |*`CUSPARSE_SOLVE_POLICY_NO_LEVEL`* |*`HIPSPARSE_SOLVE_POLICY_NO_LEVEL`* |
| 1 |*`CUSPARSE_SOLVE_POLICY_USE_LEVEL`* |*`HIPSPARSE_SOLVE_POLICY_USE_LEVEL`* |
| enum |***`cusparseStatus_t`*** |***`hipsparseMatrixType_t`*** |
| 0 |*`CUSPARSE_STATUS_SUCCESS`* |*`HIPSPARSE_STATUS_SUCCESS`* |
| 1 |*`CUSPARSE_STATUS_NOT_INITIALIZED`* |*`HIPSPARSE_STATUS_NOT_INITIALIZED`* |
| 2 |*`CUSPARSE_STATUS_ALLOC_FAILED`* |*`HIPSPARSE_STATUS_ALLOC_FAILED`* |
| 3 |*`CUSPARSE_STATUS_INVALID_VALUE`* |*`HIPSPARSE_STATUS_INVALID_VALUE`* |
| 4 |*`CUSPARSE_STATUS_ARCH_MISMATCH`* |*`HIPSPARSE_STATUS_ARCH_MISMATCH`* |
| 5 |*`CUSPARSE_STATUS_MAPPING_ERROR`* |*`HIPSPARSE_STATUS_MAPPING_ERROR`* |
| 6 |*`CUSPARSE_STATUS_EXECUTION_FAILED`* |*`HIPSPARSE_STATUS_EXECUTION_FAILED`* |
| 7 |*`CUSPARSE_STATUS_INTERNAL_ERROR`* |*`HIPSPARSE_STATUS_INTERNAL_ERROR`* |
| 8 |*`CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED`* |*`HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED`* |
| 9 |*`CUSPARSE_STATUS_ZERO_PIVOT`* |*`HIPSPARSE_STATUS_ZERO_PIVOT`* |
| struct |`cusparseContext` | |
| typedef |`cusparseHandle_t` |`hipsparseHandle_t` |
| struct |`cusparseHybMat` | |
| typedef |`cusparseHybMat_t` |`hipsparseHybMat_t` |
| struct |`cusparseMatDescr` | |
| typedef |`cusparseMatDescr_t` |`hipsparseMatDescr_t` |
| struct |`cusparseSolveAnalysisInfo` | |
| typedef |`cusparseSolveAnalysisInfo_t` | |
| struct |`csrsv2Info` | |
| typedef |`csrsv2Info_t` |`csrsv2Info_t` |
| struct |`csrsm2Info` | |
| typedef |`csrsm2Info_t` | |
| struct |`bsrsv2Info` | |
| typedef |`bsrsv2Info_t` | |
| struct |`bsrsm2Info` | |
| typedef |`bsrsm2Info_t` | |
| struct |`bsric02Info` | |
| typedef |`bsric02Info_t` | |
| struct |`csrilu02Info` | |
| typedef |`csrilu02Info_t` |`csrilu02Info_t` |
| struct |`bsrilu02Info` | |
| typedef |`bsrilu02Info_t` | |
| struct |`csru2csrInfo` | |
| typedef |`csru2csrInfo_t` | |
| struct |`cusparseColorInfo` | |
| typedef |`cusparseColorInfo_t` | |
| struct |`pruneInfo` | |
| typedef |`pruneInfo_t` | |
## **2. cuSPARSE Helper Function Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseCreate` |`hipsparseCreate` |
|`cusparseCreateSolveAnalysisInfo` | |
|`cusparseCreateHybMat` |`hipsparseCreateHybMat` |
|`cusparseCreateMatDescr` |`hipsparseCreateMatDescr` |
|`cusparseDestroy` |`hipsparseDestroy` |
|`cusparseDestroySolveAnalysisInfo` | |
|`cusparseDestroyHybMat` |`hipsparseDestroyHybMat` |
|`cusparseDestroyMatDescr` |`hipsparseDestroyMatDescr` |
|`cusparseGetLevelInfo` | |
|`cusparseGetMatDiagType` |`hipsparseGetMatDiagType` |
|`cusparseGetMatFillMode` |`hipsparseGetMatFillMode` |
|`cusparseGetMatIndexBase` |`hipsparseGetMatIndexBase` |
|`cusparseGetMatType` |`hipsparseGetMatType` |
|`cusparseGetPointerMode` |`hipsparseGetPointerMode` |
|`cusparseGetVersion` |`hipsparseGetVersion` |
|`cusparseSetMatDiagType` |`hipsparseSetMatDiagType` |
|`cusparseSetMatFillMode` |`hipsparseSetMatFillMode` |
|`cusparseSetMatType` |`hipsparseSetMatType` |
|`cusparseSetPointerMode` |`hipsparseSetPointerMode` |
|`cusparseSetStream` |`hipsparseSetStream` |
|`cusparseGetStream` |`hipsparseGetStream` |
|`cusparseCreateCsrsv2Info` |`hipsparseCreateCsrsv2Info` |
|`cusparseDestroyCsrsv2Info` |`hipsparseDestroyCsrsv2Info` |
|`cusparseCreateCsrsm2Info` | |
|`cusparseDestroyCsrsm2Info` | |
|`cusparseCreateCsric02Info` | |
|`cusparseDestroyCsric02Info` | |
|`cusparseCreateCsrilu02Info` |`hipsparseCreateCsrilu02Info` |
|`cusparseDestroyCsrilu02Info` |`hipsparseDestroyCsrilu02Info` |
|`cusparseCreateBsrsv2Info` | |
|`cusparseDestroyBsrsv2Info` | |
|`cusparseCreateBsrsm2Info` | |
|`cusparseDestroyBsrsm2Info` | |
|`cusparseCreateBsric02Info` | |
|`cusparseDestroyBsric02Info` | |
|`cusparseCreateBsrilu02Info` | |
|`cusparseDestroyBsrilu02Info` | |
|`cusparseCreateCsrgemm2Info` | |
|`cusparseDestroyCsrgemm2Info` | |
|`cusparseCreatePruneInfo` | |
|`cusparseDestroyPruneInfo` | |
## **3. cuSPARSE Level 1 Function Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseSaxpyi` |`hipsparseSaxpyi` |
|`cusparseDaxpyi` |`hipsparseDaxpyi` |
|`cusparseCaxpyi` | |
|`cusparseZaxpyi` | |
|`cusparseSdoti` |`hipsparseSdoti` |
|`cusparseDdoti` |`hipsparseDdoti` |
|`cusparseCdoti` | |
|`cusparseZdoti` | |
|`cusparseCdotci` | |
|`cusparseZdotci` | |
|`cusparseSgthr` |`hipsparseSgthr` |
|`cusparseDgthr` |`hipsparseDgthr` |
|`cusparseCgthr` | |
|`cusparseZgthr` | |
|`cusparseSgthrz` |`hipsparseSgthrz` |
|`cusparseDgthrz` |`hipsparseDgthrz` |
|`cusparseCgthrz` | |
|`cusparseZgthrz` | |
|`cusparseSroti` |`hipsparseSroti` |
|`cusparseDroti` |`hipsparseDroti` |
|`cusparseSsctr` |`hipsparseSsctr` |
|`cusparseDsctr` |`hipsparseDsctr` |
|`cusparseCsctr` | |
|`cusparseZsctr` | |
## **4. cuSPARSE Level 2 Function Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseSbsrmv` | |
|`cusparseDbsrmv` | |
|`cusparseCbsrmv` | |
|`cusparseZbsrmv` | |
|`cusparseSbsrxmv` | |
|`cusparseDbsrxmv` | |
|`cusparseCbsrxmv` | |
|`cusparseZbsrxmv` | |
|`cusparseScsrmv` |`hipsparseScsrmv` |
|`cusparseDcsrmv` |`hipsparseDcsrmv` |
|`cusparseCcsrmv` | |
|`cusparseZcsrmv` | |
|`cusparseCsrmvEx` | |
|`cusparseCsrmvEx_bufferSize` | |
|`cusparseScsrmv_mp` | |
|`cusparseDcsrmv_mp` | |
|`cusparseCcsrmv_mp` | |
|`cusparseZcsrmv_mp` | |
|`cusparseSgemvi` | |
|`cusparseDgemvi` | |
|`cusparseCgemvi` | |
|`cusparseZgemvi` | |
|`cusparseSgemvi_bufferSize` | |
|`cusparseDgemvi_bufferSize` | |
|`cusparseCgemvi_bufferSize` | |
|`cusparseZgemvi_bufferSize` | |
|`cusparseSbsrsv2_bufferSize` | |
|`cusparseDbsrsv2_bufferSize` | |
|`cusparseCbsrsv2_bufferSize` | |
|`cusparseZbsrsv2_bufferSize` | |
|`cusparseSbsrsv2_analysis` | |
|`cusparseDbsrsv2_analysis` | |
|`cusparseCbsrsv2_analysis` | |
|`cusparseZbsrsv2_analysis` | |
|`cusparseScsrsv_solve` | |
|`cusparseDcsrsv_solve` | |
|`cusparseCcsrsv_solve` | |
|`cusparseZcsrsv_solve` | |
|`cusparseXbsrsv2_zeroPivot` | |
|`cusparseScsrsv_analysis` | |
|`cusparseDcsrsv_analysis` | |
|`cusparseCcsrsv_analysis` | |
|`cusparseZcsrsv_analysis` | |
|`cusparseCsrsv_analysisEx` | |
|`cusparseScsrsv_solve` | |
|`cusparseDcsrsv_solve` | |
|`cusparseCcsrsv_solve` | |
|`cusparseZcsrsv_solve` | |
|`cusparseCsrsv_solveEx` | |
|`cusparseScsrsv2_bufferSize` |`hipsparseScsrsv2_bufferSize` |
|`cusparseDcsrsv2_bufferSize` |`hipsparseDcsrsv2_bufferSize` |
|`cusparseCcsrsv2_bufferSize` | |
|`cusparseZcsrsv2_bufferSize` | |
|`cusparseScsrsv2_analysis` |`hipsparseScsrsv2_analysis` |
|`cusparseDcsrsv2_analysis` |`hipsparseDcsrsv2_analysis` |
|`cusparseCcsrsv2_analysis` | |
|`cusparseZcsrsv2_analysis` | |
|`cusparseScsrsv2_solve` |`hipsparseScsrsv2_solve` |
|`cusparseDcsrsv2_solve` |`hipsparseDcsrsv2_solve` |
|`cusparseCcsrsv2_solve` | |
|`cusparseZcsrsv2_solve` | |
|`cusparseXcsrsv2_zeroPivot` |`hipsparseXcsrsv2_zeroPivot` |
|`cusparseShybmv` |`hipsparseShybmv` |
|`cusparseDhybmv` |`hipsparseDhybmv` |
|`cusparseChybmv` | |
|`cusparseZhybmv` | |
|`cusparseShybsv_analysis` | |
|`cusparseDhybsv_analysis` | |
|`cusparseChybsv_analysis` | |
|`cusparseZhybsv_analysis` | |
|`cusparseShybsv_solve` | |
|`cusparseDhybsv_solve` | |
|`cusparseChybsv_solve` | |
|`cusparseZhybsv_solve` | |
## **5. cuSPARSE Level 3 Function Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseScsrmm` |`hipsparseScsrmm` |
|`cusparseDcsrmm` |`hipsparseDcsrmm` |
|`cusparseCcsrmm` | |
|`cusparseZcsrmm` | |
|`cusparseScsrmm2` |`hipsparseScsrmm2` |
|`cusparseDcsrmm2` |`hipsparseDcsrmm2` |
|`cusparseCcsrmm2` | |
|`cusparseZcsrmm2` | |
|`cusparseScsrsm_analysis` | |
|`cusparseDcsrsm_analysis` | |
|`cusparseCcsrsm_analysis` | |
|`cusparseZcsrsm_analysis` | |
|`cusparseScsrsm_solve` | |
|`cusparseDcsrsm_solve` | |
|`cusparseCcsrsm_solve` | |
|`cusparseZcsrsm_solve` | |
|`cusparseScsrsm2_bufferSizeExt` | |
|`cusparseDcsrsm2_bufferSizeExt` | |
|`cusparseCcsrsm2_bufferSizeExt` | |
|`cusparseZcsrsm2_bufferSizeExt` | |
|`cusparseScsrsm2_analysis` | |
|`cusparseDcsrsm2_analysis` | |
|`cusparseCcsrsm2_analysis` | |
|`cusparseZcsrsm2_analysis` | |
|`cusparseScsrsm2_solve` | |
|`cusparseDcsrsm2_solve` | |
|`cusparseCcsrsm2_solve` | |
|`cusparseZcsrsm2_solve` | |
|`cusparseXcsrsm2_zeroPivot` | |
|`cusparseSbsrmm` | |
|`cusparseDbsrmm` | |
|`cusparseCbsrmm` | |
|`cusparseZbsrmm` | |
|`cusparseSbsrsm2_bufferSize` | |
|`cusparseDbsrsm2_bufferSize` | |
|`cusparseCbsrsm2_bufferSize` | |
|`cusparseZbsrsm2_bufferSize` | |
|`cusparseSbsrsm2_analysis` | |
|`cusparseDbsrsm2_analysis` | |
|`cusparseCbsrsm2_analysis` | |
|`cusparseZbsrsm2_analysis` | |
|`cusparseSbsrsm2_solve` | |
|`cusparseDbsrsm2_solve` | |
|`cusparseCbsrsm2_solve` | |
|`cusparseZbsrsm2_solve` | |
|`cusparseXbsrsm2_zeroPivot` | |
|`cusparseSgemmi` | |
|`cusparseDgemmi` | |
|`cusparseCgemmi` | |
|`cusparseZgemmi` | |
## **6. cuSPARSE Extra Function Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseXcsrgeamNnz` | |
|`cusparseScsrgeam` | |
|`cusparseDcsrgeam` | |
|`cusparseCcsrgeam` | |
|`cusparseZcsrgeam` | |
|`cusparseScsrgeam2_bufferSizeExt` | |
|`cusparseDcsrgeam2_bufferSizeExt` | |
|`cusparseCcsrgeam2_bufferSizeExt` | |
|`cusparseZcsrgeam2_bufferSizeExt` | |
|`cusparseXcsrgemmNnz` | |
|`cusparseScsrgemm` | |
|`cusparseDcsrgemm` | |
|`cusparseCcsrgemm` | |
|`cusparseZcsrgemm` | |
|`cusparseScsrgemm2_bufferSizeExt` | |
|`cusparseDcsrgemm2_bufferSizeExt` | |
|`cusparseCcsrgemm2_bufferSizeExt` | |
|`cusparseZcsrgemm2_bufferSizeExt` | |
## **7. cuSPARSE Preconditioners Reference**
## ***7.1. Incomplete Cholesky Factorization: level 0***
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseScsric0` | |
|`cusparseDcsric0` | |
|`cusparseCcsric0` | |
|`cusparseZcsric0` | |
|`cusparseScsric02_bufferSize` | |
|`cusparseDcsric02_bufferSize` | |
|`cusparseCcsric02_bufferSize` | |
|`cusparseZcsric02_bufferSize` | |
|`cusparseScsric02_analysis` | |
|`cusparseDcsric02_analysis` | |
|`cusparseCcsric02_analysis` | |
|`cusparseZcsric02_analysis` | |
|`cusparseScsric02` | |
|`cusparseDcsric02` | |
|`cusparseCcsric02` | |
|`cusparseZcsric02` | |
|`cusparseXcsric02_zeroPivot` | |
|`cusparseSbsric02_bufferSize` | |
|`cusparseDbsric02_bufferSize` | |
|`cusparseCbsric02_bufferSize` | |
|`cusparseZbsric02_bufferSize` | |
|`cusparseSbsric02_analysis` | |
|`cusparseDbsric02_analysis` | |
|`cusparseCbsric02_analysis` | |
|`cusparseZbsric02_analysis` | |
|`cusparseSbsric02` | |
|`cusparseDbsric02` | |
|`cusparseCbsric02` | |
|`cusparseZbsric02` | |
|`cusparseXbsric02_zeroPivot` | |
## ***7.2. Incomplete LU Factorization: level 0***
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseScsrilu0` | |
|`cusparseDcsrilu0` | |
|`cusparseCcsrilu0` | |
|`cusparseZcsrilu0` | |
|`cusparseCsrilu0Ex` | |
|`cusparseScsrilu02_numericBoost` | |
|`cusparseDcsrilu02_numericBoost` | |
|`cusparseCcsrilu02_numericBoost` | |
|`cusparseZcsrilu02_numericBoost` | |
|`cusparseScsrilu02_bufferSize` |`hipsparseScsrilu02_bufferSize` |
|`cusparseDcsrilu02_bufferSize` |`hipsparseDcsrilu02_bufferSize` |
|`cusparseCcsrilu02_bufferSize` | |
|`cusparseZcsrilu02_bufferSize` | |
|`cusparseScsrilu02_analysis` |`hipsparseScsrilu02_analysis` |
|`cusparseDcsrilu02_analysis` |`hipsparseDcsrilu02_analysis` |
|`cusparseCcsrilu02_analysis` | |
|`cusparseZcsrilu02_analysis` | |
|`cusparseScsrilu02` |`hipsparseScsrilu02` |
|`cusparseDcsrilu02` |`hipsparseDcsrilu02` |
|`cusparseCcsrilu02` | |
|`cusparseZcsrilu02` | |
|`cusparseXbsric02_zeroPivot` |`hipsparseXcsrilu02_zeroPivot` |
|`cusparseSbsrilu02_numericBoost` | |
|`cusparseDbsrilu02_numericBoost` | |
|`cusparseCbsrilu02_numericBoost` | |
|`cusparseZbsrilu02_numericBoost` | |
|`cusparseSbsrilu02_bufferSize` | |
|`cusparseDbsrilu02_bufferSize` | |
|`cusparseCbsrilu02_bufferSize` | |
|`cusparseZbsrilu02_bufferSize` | |
|`cusparseSbsrilu02_analysis` | |
|`cusparseDbsrilu02_analysis` | |
|`cusparseCbsrilu02_analysis` | |
|`cusparseZbsrilu02_analysis` | |
|`cusparseSbsrilu02` | |
|`cusparseDbsrilu02` | |
|`cusparseCbsrilu02` | |
|`cusparseZbsrilu02` | |
|`cusparseXbsrilu02_zeroPivot` | |
## ***7.3. Tridiagonal Solve***
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseSgtsv` | |
|`cusparseDgtsv` | |
|`cusparseCgtsv` | |
|`cusparseZgtsv` | |
|`cusparseSgtsv_nopivot` | |
|`cusparseDgtsv_nopivot` | |
|`cusparseCgtsv_nopivot` | |
|`cusparseZgtsv_nopivot` | |
|`cusparseSgtsv2_bufferSizeExt` | |
|`cusparseDgtsv2_bufferSizeExt` | |
|`cusparseCgtsv2_bufferSizeExt` | |
|`cusparseZgtsv2_bufferSizeExt` | |
|`cusparseSgtsv2` | |
|`cusparseDgtsv2` | |
|`cusparseCgtsv2` | |
|`cusparseZgtsv2` | |
|`cusparseSgtsv2_nopivot_bufferSizeExt` | |
|`cusparseDgtsv2_nopivot_bufferSizeExt` | |
|`cusparseCgtsv2_nopivot_bufferSizeExt` | |
|`cusparseZgtsv2_nopivot_bufferSizeExt` | |
|`cusparseSgtsv2_nopivot` | |
|`cusparseDgtsv2_nopivot` | |
|`cusparseCgtsv2_nopivot` | |
|`cusparseZgtsv2_nopivot` | |
## ***7.4. Batched Tridiagonal Solve***
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseSgtsvStridedBatch` | |
|`cusparseDgtsvStridedBatch` | |
|`cusparseCgtsvStridedBatch` | |
|`cusparseZgtsvStridedBatch` | |
|`cusparseSgtsv2StridedBatch_bufferSizeExt` | |
|`cusparseDgtsv2StridedBatch_bufferSizeExt` | |
|`cusparseCgtsv2StridedBatch_bufferSizeExt` | |
|`cusparseZgtsv2StridedBatch_bufferSizeExt` | |
|`cusparseSgtsv2StridedBatch` | |
|`cusparseDgtsv2StridedBatch` | |
|`cusparseCgtsv2StridedBatch` | |
|`cusparseZgtsv2StridedBatch` | |
|`cusparseSgtsvInterleavedBatch_bufferSizeExt` | |
|`cusparseDgtsvInterleavedBatch_bufferSizeExt` | |
|`cusparseCgtsvInterleavedBatch_bufferSizeExt` | |
|`cusparseZgtsvInterleavedBatch_bufferSizeExt` | |
|`cusparseSgtsvInterleavedBatch` | |
|`cusparseDgtsvInterleavedBatch` | |
|`cusparseCgtsvInterleavedBatch` | |
|`cusparseZgtsvInterleavedBatch` | |
## ***7.5. Batched Pentadiagonal Solve***
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseSgpsvInterleavedBatch_bufferSizeExt` | |
|`cusparseDgpsvInterleavedBatch_bufferSizeExt` | |
|`cusparseCgpsvInterleavedBatch_bufferSizeExt` | |
|`cusparseZgpsvInterleavedBatch_bufferSizeExt` | |
|`cusparseSgpsvInterleavedBatch` | |
|`cusparseDgpsvInterleavedBatch` | |
|`cusparseCgpsvInterleavedBatch` | |
|`cusparseZgpsvInterleavedBatch` | |
## **8. cuSPARSE Matrix Reorderings Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseScsrcolor` | |
|`cusparseDcsrcolor` | |
|`cusparseCcsrcolor` | |
|`cusparseZcsrcolor` | |
## **9. cuSPARSE Format Conversion Reference**
| **CUDA** | **HIP** |
|-----------------------------------------------------------|-------------------------------------------------|
|`cusparseSbsr2csr` | |
|`cusparseDbsr2csr` | |
|`cusparseCbsr2csr` | |
|`cusparseZbsr2csr` | |
|`cusparseSgebsr2gebsc_bufferSize` | |
|`cusparseDgebsr2gebsc_bufferSize` | |
|`cusparseCgebsr2gebsc_bufferSize` | |
|`cusparseZgebsr2gebsc_bufferSize` | |
|`cusparseSgebsr2gebsc` | |
|`cusparseDgebsr2gebsc` | |
|`cusparseCgebsr2gebsc` | |
|`cusparseZgebsr2gebsc` | |
|`cusparseSgebsr2gebsr_bufferSize` | |
|`cusparseDgebsr2gebsr_bufferSize` | |
|`cusparseCgebsr2gebsr_bufferSize` | |
|`cusparseZgebsr2gebsr_bufferSize` | |
|`cusparseXgebsr2gebsrNnz` | |
|`cusparseSgebsr2gebsr` | |
|`cusparseDgebsr2gebsr` | |
|`cusparseCgebsr2gebsr` | |
|`cusparseZgebsr2gebsr` | |
|`cusparseSgebsr2csr` | |
|`cusparseDgebsr2csr` | |
|`cusparseCgebsr2csr` | |
|`cusparseZgebsr2csr` | |
|`cusparseScsr2gebsr_bufferSize` | |
|`cusparseDcsr2gebsr_bufferSize` | |
|`cusparseCcsr2gebsr_bufferSize` | |
|`cusparseZcsr2gebsr_bufferSize` | |
|`cusparseXcsr2gebsrNnz` | |
|`cusparseScsr2gebsr` | |
|`cusparseDcsr2gebsr` | |
|`cusparseCcsr2gebsr` | |
|`cusparseZcsr2gebsr` | |
|`cusparseXcoo2csr` |`hipsparseXcoo2csr` |
|`cusparseScsc2dense` | |
|`cusparseDcsc2dense` | |
|`cusparseCcsc2dense` | |
|`cusparseZcsc2dense` | |
|`cusparseScsc2hyb` | |
|`cusparseDcsc2hyb` | |
|`cusparseCcsc2hyb` | |
|`cusparseZcsc2hyb` | |
|`cusparseXcsr2bsrNnz` | |
|`cusparseScsr2bsr` | |
|`cusparseDcsr2bsr` | |
|`cusparseCcsr2bsr` | |
|`cusparseZcsr2bsr` | |
|`cusparseXcsr2coo` |`hipsparseXcsr2coo` |
|`cusparseScsr2csc` |`hipsparseScsr2csc` |
|`cusparseDcsr2csc` |`hipsparseDcsr2csc` |
|`cusparseCcsr2csc` | |
|`cusparseZcsr2csc` | |
|`cusparseCsr2cscEx` | |
|`cusparseScsr2dense` | |
|`cusparseDcsr2dense` | |
|`cusparseCcsr2dense` | |
|`cusparseZcsr2dense` | |
|`cusparseScsr2csr_compress` | |
|`cusparseDcsr2csr_compress` | |
|`cusparseCcsr2csr_compress` | |
|`cusparseZcsr2csr_compress` | |
|`cusparseScsr2hyb` |`hipsparseScsr2hyb` |
|`cusparseDcsr2hyb` |`hipsparseDcsr2hyb` |
|`cusparseCcsr2hyb` | |
|`cusparseZcsr2hyb` | |
|`cusparseSdense2csc` | |
|`cusparseDdense2csc` | |
|`cusparseCdense2csc` | |
|`cusparseZdense2csc` | |
|`cusparseSdense2csr` | |
|`cusparseDdense2csr` | |
|`cusparseCdense2csr` | |
|`cusparseZdense2csr` | |
|`cusparseSdense2hyb` | |
|`cusparseDdense2hyb` | |
|`cusparseCdense2hyb` | |
|`cusparseZdense2hyb` | |
|`cusparseShyb2csc` | |
|`cusparseDhyb2csc` | |
|`cusparseChyb2csc` | |
|`cusparseZhyb2csc` | |
|`cusparseShyb2csr` | |
|`cusparseDhyb2csr` | |
|`cusparseChyb2csr` | |
|`cusparseZhyb2csr` | |
|`cusparseShyb2dense` | |
|`cusparseDhyb2dense` | |
|`cusparseChyb2dense` | |
|`cusparseZhyb2dense` | |
|`cusparseSnnz` | |
|`cusparseDnnz` | |
|`cusparseCnnz` | |
|`cusparseZnnz` | |
|`cusparseCreateIdentityPermutation` |`hipsparseCreateIdentityPermutation` |
|`cusparseXcoosort_bufferSizeExt` |`hipsparseXcoosort_bufferSizeExt` |
|`cusparseXcoosortByRow` |`hipsparseXcoosortByRow` |
|`cusparseXcoosortByColumn` |`hipsparseXcoosortByColumn` |
|`cusparseXcsrsort_bufferSizeExt` |`hipsparseXcsrsort_bufferSizeExt` |
|`cusparseXcsrsort` |`hipsparseXcsrsort` |
|`cusparseXcscsort_bufferSizeExt` | |
|`cusparseXcscsort` | |
|`cusparseCreateCsru2csrInfo` | |
|`cusparseDestroyCsru2csrInfo` | |
|`cusparseScsru2csr_bufferSizeExt` | |
|`cusparseDcsru2csr_bufferSizeExt` | |
|`cusparseCcsru2csr_bufferSizeExt` | |
|`cusparseZcsru2csr_bufferSizeExt` | |
|`cusparseScsru2csr` | |
|`cusparseDcsru2csr` | |
|`cusparseCcsru2csr` | |
|`cusparseZcsru2csr` | |
|`cusparseHpruneDense2csr_bufferSizeExt` | |
|`cusparseSpruneDense2csr_bufferSizeExt` | |
|`cusparseDpruneDense2csr_bufferSizeExt` | |
|`cusparseHpruneDense2csrNnz` | |
|`cusparseSpruneDense2csrNnz` | |
|`cusparseDpruneDense2csrNnz` | |
|`cusparseHpruneCsr2csr_bufferSizeExt` | |
|`cusparseSpruneCsr2csr_bufferSizeExt` | |
|`cusparseDpruneCsr2csr_bufferSizeExt` | |
|`cusparseHpruneCsr2csrNnz` | |
|`cusparseSpruneCsr2csrNnz` | |
|`cusparseDpruneCsr2csrNnz` | |
|`cusparseHpruneDense2csrByPercentage_bufferSizeExt` | |
|`cusparseSpruneDense2csrByPercentage_bufferSizeExt` | |
|`cusparseDpruneDense2csrByPercentage_bufferSizeExt` | |
|`cusparseHpruneDense2csrNnzByPercentage` | |
|`cusparseSpruneDense2csrNnzByPercentage` | |
|`cusparseDpruneDense2csrNnzByPercentage` | |
|`cusparseHpruneCsr2csrByPercentage_bufferSizeExt` | |
|`cusparseSpruneCsr2csrByPercentage_bufferSizeExt` | |
|`cusparseDpruneCsr2csrByPercentage_bufferSizeExt` | |
|`cusparseHpruneCsr2csrNnzByPercentage` | |
|`cusparseSpruneCsr2csrNnzByPercentage` | |
|`cusparseDpruneCsr2csrNnzByPercentage` | |
|`cusparseSnnz_compress` | |
|`cusparseDnnz_compress` | |
|`cusparseCnnz_compress` | |
|`cusparseZnnz_compress` | |
+1 -1
Просмотреть файл
@@ -159,7 +159,7 @@ void callMyKernel()
## Variable-Type Qualifiers
### `__constant__`
The `__constant__` keyword is supported. The host writes constant memory before launching the kernel; from the GPU, this memory is read-only during kernel execution. The functions for accessing constant memory (hipGetSymbolAddress(), hipGetSymbolSize(), hipMemcpyToSymbol(), hipMemcpyToSymbolAsync, hipMemcpyFromSymbol, hipMemcpyFromSymbolAsync) are under development.
The `__constant__` keyword is supported. The host writes constant memory before launching the kernel; from the GPU, this memory is read-only during kernel execution. The functions for accessing constant memory (hipGetSymbolAddress(), hipGetSymbolSize(), hipMemcpyToSymbol(), hipMemcpyToSymbolAsync(), hipMemcpyFromSymbol(), hipMemcpyFromSymbolAsync()) are available.
### `__shared__`
The `__shared__` keyword is supported.
+2 -1
Просмотреть файл
@@ -27,13 +27,14 @@
- [cuRAND](../docs/markdown/CURAND_API_supported_by_HIP.md)
- [cuDNN](../docs/markdown/CUDNN_API_supported_by_HIP.md)
- [cuFFT](../docs/markdown/CUFFT_API_supported_by_HIP.md)
- [cuSPARSE](../docs/markdown/CUSPARSE_API_supported_by_HIP.md)
## <a name="dependencies"></a> Dependencies
`hipify-clang` requires:
1. LLVM+CLANG of at least version 3.8.0, latest stable and recommended release: 6.0.1 (linux and windows).
2. CUDA at least version 7.5, latest supported release is 9.2.
2. CUDA at least version 7.5, latest supported release is 9.0.
| **LLVM release version** | **CUDA latest supported version** | **Comments** |
|:------------------------:|:---------------------------------:|:------------:|
+9 -2
Просмотреть файл
@@ -12,6 +12,8 @@ const std::map <llvm::StringRef, hipCounter> CUDA_INCLUDE_MAP{
{"cuda_fp16.h", {"hip/hip_fp16.h", CONV_INCLUDE, API_RUNTIME}},
{"cuda_texture_types.h", {"hip/hip_texture_types.h", CONV_INCLUDE, API_RUNTIME}},
{"vector_types.h", {"hip/hip_vector_types.h", CONV_INCLUDE, API_RUNTIME}},
// cuComplex includes
{"cuComplex.h", {"hip/hip_complex.h", CONV_INCLUDE_CUDA_MAIN_H, API_COMPLEX}},
// cuBLAS includes
{"cublas.h", {"hipblas.h", CONV_INCLUDE_CUDA_MAIN_H, API_BLAS}},
{"cublas_v2.h", {"hipblas.h", CONV_INCLUDE_CUDA_MAIN_H, API_BLAS}},
@@ -37,8 +39,9 @@ const std::map <llvm::StringRef, hipCounter> CUDA_INCLUDE_MAP{
{"cudnn.h", {"hipDNN.h", CONV_INCLUDE_CUDA_MAIN_H, API_DNN}},
// cuFFT includes
{"cufft.h", {"hipfft.h", CONV_INCLUDE_CUDA_MAIN_H, API_FFT}},
// cuComplex includes
{"cuComplex.h", {"hip/hip_complex.h", CONV_INCLUDE_CUDA_MAIN_H, API_COMPLEX}},
// cuBLAS includes
{"cusparse.h", {"hipsparse.h", CONV_INCLUDE_CUDA_MAIN_H, API_SPARSE}},
{"cusparse_v2.h", {"hipsparse.h", CONV_INCLUDE_CUDA_MAIN_H, API_SPARSE}},
};
const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP() {
@@ -51,6 +54,8 @@ const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP() {
ret.insert(CUDA_DRIVER_FUNCTION_MAP.begin(), CUDA_DRIVER_FUNCTION_MAP.end());
ret.insert(CUDA_RUNTIME_TYPE_NAME_MAP.begin(), CUDA_RUNTIME_TYPE_NAME_MAP.end());
ret.insert(CUDA_RUNTIME_FUNCTION_MAP.begin(), CUDA_RUNTIME_FUNCTION_MAP.end());
ret.insert(CUDA_COMPLEX_TYPE_NAME_MAP.begin(), CUDA_COMPLEX_TYPE_NAME_MAP.end());
ret.insert(CUDA_COMPLEX_FUNCTION_MAP.begin(), CUDA_COMPLEX_FUNCTION_MAP.end());
ret.insert(CUDA_BLAS_TYPE_NAME_MAP.begin(), CUDA_BLAS_TYPE_NAME_MAP.end());
ret.insert(CUDA_BLAS_FUNCTION_MAP.begin(), CUDA_BLAS_FUNCTION_MAP.end());
ret.insert(CUDA_RAND_TYPE_NAME_MAP.begin(), CUDA_RAND_TYPE_NAME_MAP.end());
@@ -59,5 +64,7 @@ const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP() {
ret.insert(CUDA_DNN_FUNCTION_MAP.begin(), CUDA_DNN_FUNCTION_MAP.end());
ret.insert(CUDA_FFT_TYPE_NAME_MAP.begin(), CUDA_FFT_TYPE_NAME_MAP.end());
ret.insert(CUDA_FFT_FUNCTION_MAP.begin(), CUDA_FFT_FUNCTION_MAP.end());
ret.insert(CUDA_SPARSE_TYPE_NAME_MAP.begin(), CUDA_SPARSE_TYPE_NAME_MAP.end());
ret.insert(CUDA_SPARSE_FUNCTION_MAP.begin(), CUDA_SPARSE_FUNCTION_MAP.end());
return ret;
};
+8
Просмотреть файл
@@ -15,6 +15,10 @@ extern const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP;
extern const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_FUNCTION_MAP;
// Maps the names of CUDA RUNTIME API types to the corresponding HIP types
extern const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_TYPE_NAME_MAP;
// Maps the names of CUDA Complex API types to the corresponding HIP types
extern const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_TYPE_NAME_MAP;
// Maps the names of CUDA Complex API functions to the corresponding HIP functions
extern const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_FUNCTION_MAP;
// Maps the names of CUDA RUNTIME API functions to the corresponding HIP functions
extern const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP;
// Maps the names of CUDA BLAS API types to the corresponding HIP types
@@ -33,6 +37,10 @@ extern const std::map<llvm::StringRef, hipCounter> CUDA_DNN_FUNCTION_MAP;
extern const std::map<llvm::StringRef, hipCounter> CUDA_FFT_TYPE_NAME_MAP;
// Maps the names of CUDA FFT API functions to the corresponding HIP functions
extern const std::map<llvm::StringRef, hipCounter> CUDA_FFT_FUNCTION_MAP;
// Maps the names of CUDA SPARSE API types to the corresponding HIP types
extern const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_TYPE_NAME_MAP;
// Maps the names of CUDA SPARSE API functions to the corresponding HIP functions
extern const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP;
/**
* The union of all the above maps, except includes.
+28
Просмотреть файл
@@ -0,0 +1,28 @@
#include "CUDA2HIP.h"
// Maps the names of CUDA Complex API types to the corresponding HIP types
const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_FUNCTION_MAP{
{"cuCrealf", {"hipCrealf", CONV_COMPLEX, API_COMPLEX}},
{"cuCimagf", {"hipCimagf", CONV_COMPLEX, API_COMPLEX}},
{"make_cuFloatComplex", {"make_hipFloatComplex", CONV_COMPLEX, API_COMPLEX}},
{"cuConjf", {"hipConjf", CONV_COMPLEX, API_COMPLEX}},
{"cuCaddf", {"hipCaddf", CONV_COMPLEX, API_COMPLEX}},
{"cuCsubf", {"hipCsubf", CONV_COMPLEX, API_COMPLEX}},
{"cuCmulf", {"hipCmulf", CONV_COMPLEX, API_COMPLEX}},
{"cuCdivf", {"hipCdivf", CONV_COMPLEX, API_COMPLEX}},
{"cuCabsf", {"hipCabsf", CONV_COMPLEX, API_COMPLEX}},
{"cuCreal", {"hipCreal", CONV_COMPLEX, API_COMPLEX}},
{"cuCimag", {"hipCimag", CONV_COMPLEX, API_COMPLEX}},
{"make_cuDoubleComplex", {"make_hipDoubleComplex", CONV_COMPLEX, API_COMPLEX}},
{"cuConj", {"hipConj", CONV_COMPLEX, API_COMPLEX}},
{"cuCadd", {"hipCadd", CONV_COMPLEX, API_COMPLEX}},
{"cuCsub", {"hipCsub", CONV_COMPLEX, API_COMPLEX}},
{"cuCmul", {"hipCmul", CONV_COMPLEX, API_COMPLEX}},
{"cuCdiv", {"hipCdiv", CONV_COMPLEX, API_COMPLEX}},
{"cuCabs", {"hipCabs", CONV_COMPLEX, API_COMPLEX}},
{"make_cuComplex", {"make_hipComplex", CONV_COMPLEX, API_COMPLEX}},
{"cuComplexFloatToDouble", {"hipComplexFloatToDouble", CONV_COMPLEX, API_COMPLEX}},
{"cuComplexDoubleToFloat", {"hipComplexDoubleToFloat", CONV_COMPLEX, API_COMPLEX}},
{"cuCfmaf", {"hipCfmaf", CONV_COMPLEX, API_COMPLEX}},
{"cuCfma", {"hipCfma", CONV_COMPLEX, API_COMPLEX}},
};
+8
Просмотреть файл
@@ -0,0 +1,8 @@
#include "CUDA2HIP.h"
// Maps the names of CUDA Complex API types to the corresponding HIP types
const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_TYPE_NAME_MAP{
{"cuFloatComplex", {"hipFloatComplex", CONV_TYPE, API_COMPLEX}},
{"cuDoubleComplex", {"hipDoubleComplex", CONV_TYPE, API_COMPLEX}},
{"cuComplex", {"hipComplex", CONV_TYPE, API_COMPLEX}},
};
Разница между файлами не показана из-за своего большого размера Загрузить разницу
+4 -2
Просмотреть файл
@@ -80,8 +80,10 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP{
{"CUDA_TEXTURE_DESC_st", {"HIP_TEXTURE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
{"CUDA_TEXTURE_DESC", {"HIP_TEXTURE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
{"CUdevprop_st", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}},
{"CUdevprop", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}},
// no analogue
// NOTE: cudaDeviceProp differs
{"CUdevprop_st", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
{"CUdevprop", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
// cudaIpcEventHandle_st
{"CUipcEventHandle_st", {"ihipIpcEventHandle_t", CONV_TYPE, API_DRIVER}},
+105 -23
Просмотреть файл
@@ -1,6 +1,6 @@
#include "CUDA2HIP.h"
// Map of all functions
// Map of all CUDA Runtime API functions
const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
// Error API
{"cudaGetLastError", {"hipGetLastError", CONV_ERROR, API_RUNTIME}},
@@ -9,29 +9,49 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaGetErrorString", {"hipGetErrorString", CONV_ERROR, API_RUNTIME}},
// memcpy functions
// no analogue
// NOTE: Not equal to cuMemcpy due to different signatures
{"cudaMemcpy", {"hipMemcpy", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyToArray", {"hipMemcpyToArray", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyToSymbol", {"hipMemcpyToSymbol", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyToSymbolAsync", {"hipMemcpyToSymbolAsync", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyAsync", {"hipMemcpyAsync", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuMemcpy2D due to different signatures
{"cudaMemcpy2D", {"hipMemcpy2D", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuMemcpy2DAsync due to different signatures
{"cudaMemcpy2DAsync", {"hipMemcpy2DAsync", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpy2DToArray", {"hipMemcpy2DToArray", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpy2DArrayToArray", {"hipMemcpy2DArrayToArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpy2DFromArray", {"hipMemcpy2DFromArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpy2DFromArrayAsync", {"hipMemcpy2DFromArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpy2DToArrayAsync", {"hipMemcpy2DToArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpy3D due to different signatures
{"cudaMemcpy3D", {"hipMemcpy3D", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuMemcpy3DAsync due to different signatures
{"cudaMemcpy3DAsync", {"hipMemcpy3DAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpy3DPeer due to different signatures
{"cudaMemcpy3DPeer", {"hipMemcpy3DPeer", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpy3DPeerAsync due to different signatures
{"cudaMemcpy3DPeerAsync", {"hipMemcpy3DPeerAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpyAtoA due to different signatures
{"cudaMemcpyArrayToArray", {"hipMemcpyArrayToArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpyFromArrayAsync", {"hipMemcpyFromArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpyFromSymbol", {"hipMemcpyFromSymbol", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyFromSymbolAsync", {"hipMemcpyFromSymbolAsync", CONV_MEMORY, API_RUNTIME}},
{"cudaMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, //
{"cudaMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, //
{"cudaMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, //
// cuMemAdvise
{"cudaMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// cuMemRangeGetAttribute
{"cudaMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// cuMemRangeGetAttributes
{"cudaMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// memset
{"cudaMemset", {"hipMemset", CONV_MEMORY, API_RUNTIME}},
@@ -42,13 +62,17 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaMemset3DAsync", {"hipMemset3DAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// Memory management
// cuMemGetInfo
{"cudaMemGetInfo", {"hipMemGetInfo", CONV_MEMORY, API_RUNTIME}},
{"cudaArrayGetInfo", {"hipArrayGetInfo", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMipmappedArrayDestroy due to different signatures
{"cudaFreeMipmappedArray", {"hipFreeMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaGetMipmappedArrayLevel", {"hipGetMipmappedArrayLevel", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaGetSymbolAddress", {"hipGetSymbolAddress", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaGetSymbolSize", {"hipGetSymbolSize", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // // API_Driver ANALOGUE (cuMemPrefetchAsync)
{"cudaGetSymbolAddress", {"hipGetSymbolAddress", CONV_MEMORY, API_RUNTIME}},
{"cudaGetSymbolSize", {"hipGetSymbolSize", CONV_MEMORY, API_RUNTIME}},
// TODO: double check cuMemPrefetchAsync
{"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// malloc
{"cudaMalloc", {"hipMalloc", CONV_MEMORY, API_RUNTIME}},
@@ -57,15 +81,22 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaMalloc3D", {"hipMalloc3D", CONV_MEMORY, API_RUNTIME}},
{"cudaMalloc3DArray", {"hipMalloc3DArray", CONV_MEMORY, API_RUNTIME}},
{"cudaMallocManaged", {"hipMallocManaged", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMipmappedArrayCreate due to different signatures
{"cudaMallocMipmappedArray", {"hipMallocMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMallocPitch", {"hipMallocPitch", CONV_MEMORY, API_RUNTIME}},
// cuMemFree
{"cudaFree", {"hipFree", CONV_MEMORY, API_RUNTIME}},
// cuMemFreeHost
{"cudaFreeHost", {"hipHostFree", CONV_MEMORY, API_RUNTIME}},
{"cudaFreeArray", {"hipFreeArray", CONV_MEMORY, API_RUNTIME}},
// cuMemHostRegister
{"cudaHostRegister", {"hipHostRegister", CONV_MEMORY, API_RUNTIME}},
// cuMemHostUnregister
{"cudaHostUnregister", {"hipHostUnregister", CONV_MEMORY, API_RUNTIME}},
// hipHostAlloc deprecated - use hipHostMalloc instead
// cuMemHostAlloc
// NOTE: hipHostAlloc deprecated - use hipHostMalloc instead
{"cudaHostAlloc", {"hipHostMalloc", CONV_MEMORY, API_RUNTIME}},
// make memory functions
@@ -74,35 +105,81 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"make_cudaPos", {"make_hipPos", CONV_MEMORY, API_RUNTIME}},
// Host Register Flags
// cuMemHostGetFlags
{"cudaHostGetFlags", {"hipHostGetFlags", CONV_MEMORY, API_RUNTIME}},
// Events
{"cudaEventCreate", {"hipEventCreate", CONV_EVENT, API_RUNTIME}},
{"cudaEventCreateWithFlags", {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}},
{"cudaEventDestroy", {"hipEventDestroy", CONV_EVENT, API_RUNTIME}},
{"cudaEventRecord", {"hipEventRecord", CONV_EVENT, API_RUNTIME}},
{"cudaEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}},
{"cudaEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}},
{"cudaEventQuery", {"hipEventQuery", CONV_EVENT, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuEventCreate due to different signatures
{"cudaEventCreate", {"hipEventCreate", CONV_EVENT, API_RUNTIME}},
// cuEventCreate
{"cudaEventCreateWithFlags", {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}},
// cuEventDestroy
{"cudaEventDestroy", {"hipEventDestroy", CONV_EVENT, API_RUNTIME}},
// cuEventRecord
{"cudaEventRecord", {"hipEventRecord", CONV_EVENT, API_RUNTIME}},
// cuEventElapsedTime
{"cudaEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}},
// cuEventSynchronize
{"cudaEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}},
// cuEventQuery
{"cudaEventQuery", {"hipEventQuery", CONV_EVENT, API_RUNTIME}},
// 5.6. External Resource Interoperability
// cuDestroyExternalMemory
{"cudaDestroyExternalMemory", {"hipDestroyExternalMemory", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuDestroyExternalSemaphore
{"cudaDestroyExternalSemaphore", {"hipDestroyExternalSemaphore", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuExternalMemoryGetMappedBuffer
{"cudaExternalMemoryGetMappedBuffer", {"hipExternalMemoryGetMappedBuffer", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuExternalMemoryGetMappedMipmappedArray
{"cudaExternalMemoryGetMappedMipmappedArray", {"hipExternalMemoryGetMappedMipmappedArray", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuImportExternalMemory
{"cudaImportExternalMemory", {"hipImportExternalMemory", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuImportExternalSemaphore
{"cudaImportExternalSemaphore", {"hipImportExternalSemaphore", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuSignalExternalSemaphoresAsync
{"cudaSignalExternalSemaphoresAsync", {"hipSignalExternalSemaphoresAsync", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuWaitExternalSemaphoresAsync
{"cudaWaitExternalSemaphoresAsync", {"hipWaitExternalSemaphoresAsync", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// Streams
// no analogue
// NOTE: Not equal to cuStreamCreate due to different signatures
{"cudaStreamCreate", {"hipStreamCreate", CONV_STREAM, API_RUNTIME}},
// cuStreamCreate
{"cudaStreamCreateWithFlags", {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}},
{"cudaStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamCreateWithPriority
{"cudaStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME}},
// cuStreamDestroy
{"cudaStreamDestroy", {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}},
// cuStreamWaitEvent
{"cudaStreamWaitEvent", {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}},
// cuStreamSynchronize
{"cudaStreamSynchronize", {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}},
// cuStreamGetFlags
{"cudaStreamGetFlags", {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}},
// cuStreamQuery
{"cudaStreamQuery", {"hipStreamQuery", CONV_STREAM, API_RUNTIME}},
// cuStreamAddCallback
{"cudaStreamAddCallback", {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}},
// cuStreamAttachMemAsync
{"cudaStreamAttachMemAsync", {"hipStreamAttachMemAsync", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamBeginCapture
{"cudaStreamBeginCapture", {"hipStreamBeginCapture", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamEndCapture
{"cudaStreamEndCapture", {"hipStreamEndCapture", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamIsCapturing
{"cudaStreamIsCapturing", {"hipStreamIsCapturing", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamGetPriority
{"cudaStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME}},
// Other synchronization
{"cudaDeviceSynchronize", {"hipDeviceSynchronize", CONV_DEVICE, API_RUNTIME}},
{"cudaDeviceReset", {"hipDeviceReset", CONV_DEVICE, API_RUNTIME}},
{"cudaSetDevice", {"hipSetDevice", CONV_DEVICE, API_RUNTIME}},
{"cudaGetDevice", {"hipGetDevice", CONV_DEVICE, API_RUNTIME}},
// cuDeviceGetCount
{"cudaGetDeviceCount", {"hipGetDeviceCount", CONV_DEVICE, API_RUNTIME}},
{"cudaChooseDevice", {"hipChooseDevice", CONV_DEVICE, API_RUNTIME}},
@@ -118,20 +195,25 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaDeviceGetAttribute", {"hipDeviceGetAttribute", CONV_DEVICE, API_RUNTIME}},
// Pointer Attributes
// struct cudaPointerAttributes
{"cudaPointerGetAttributes", {"hipPointerGetAttributes", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuPointerGetAttributes due to different signatures
{"cudaPointerGetAttributes", {"hipPointerGetAttributes", CONV_ADDRESSING, API_RUNTIME}},
// cuMemHostGetDevicePointer
{"cudaHostGetDevicePointer", {"hipHostGetDevicePointer", CONV_MEMORY, API_RUNTIME}},
// Device
{"cudaGetDeviceProperties", {"hipGetDeviceProperties", CONV_DEVICE, API_RUNTIME}},
// cuDeviceGetPCIBusId
{"cudaDeviceGetPCIBusId", {"hipDeviceGetPCIBusId", CONV_DEVICE, API_RUNTIME}},
// cuDeviceGetByPCIBusId
{"cudaDeviceGetByPCIBusId", {"hipDeviceGetByPCIBusId", CONV_DEVICE, API_RUNTIME}},
{"cudaDeviceGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}},
// cuCtxGetStreamPriorityRange
{"cudaDeviceGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_DEVICE, API_RUNTIME}},
{"cudaSetValidDevices", {"hipSetValidDevices", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}},
// Device Flags
{"cudaGetDeviceFlags", {"hipGetDeviceFlags", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}},
// cuCtxGetFlags
{"cudaGetDeviceFlags", {"hipCtxGetFlags", CONV_DEVICE, API_RUNTIME}},
{"cudaSetDeviceFlags", {"hipSetDeviceFlags", CONV_DEVICE, API_RUNTIME}},
// Cache config
@@ -179,7 +261,7 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
// {"cudaThreadGetSharedMemConfig", {"hipDeviceGetSharedMemConfig", CONV_DEVICE, API_RUNTIME}},
// {"cudaThreadSetSharedMemConfig", {"hipDeviceSetSharedMemConfig", CONV_DEVICE, API_RUNTIME}},
// cuCtxGetLimit
{"cudaDeviceGetLimit", {"hipDeviceGetLimit", CONV_DEVICE, API_RUNTIME}},
// Profiler
+609
Просмотреть файл
@@ -0,0 +1,609 @@
#include "CUDA2HIP.h"
// Maps the names of CUDA SPARSE API types to the corresponding HIP types
const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_FUNCTION_MAP{
// 5. cuSPARSE Helper Function Reference
{"cusparseCreate", {"hipsparseCreate", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCreateSolveAnalysisInfo", {"hipsparseCreateSolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateHybMat", {"hipsparseCreateHybMat", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCreateMatDescr", {"hipsparseCreateMatDescr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDestroy", {"hipsparseDestroy", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDestroySolveAnalysisInfo", {"hipsparseDestroySolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyHybMat", {"hipsparseDestroyHybMat", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDestroyMatDescr", {"hipsparseDestroyMatDescr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetLevelInfo", {"hipsparseGetLevelInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseGetMatDiagType", {"hipsparseGetMatDiagType", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetMatFillMode", {"hipsparseGetMatFillMode", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetMatIndexBase", {"hipsparseGetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetMatType", {"hipsparseGetMatType", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetPointerMode", {"hipsparseGetPointerMode", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetVersion", {"hipsparseGetVersion", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSetMatDiagType", {"hipsparseSetMatDiagType", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSetMatFillMode", {"hipsparseSetMatFillMode", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSetMatIndexBase", {"hipsparseSetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSetMatType", {"hipsparseSetMatType", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSetPointerMode", {"hipsparseSetPointerMode", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSetStream", {"hipsparseSetStream", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseGetStream", {"hipsparseGetStream", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCreateCsrsv2Info", {"hipsparseCreateCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDestroyCsrsv2Info", {"hipsparseDestroyCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCreateCsrsm2Info", {"hipsparseCreateCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyCsrsm2Info", {"hipsparseDestroyCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateCsric02Info", {"hipsparseCreateCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyCsric02Info", {"hipsparseDestroyCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateCsrilu02Info", {"hipsparseCreateCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDestroyCsrilu02Info", {"hipsparseDestroyCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCreateBsrsv2Info", {"hipsparseCreateBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyBsrsv2Info", {"hipsparseDestroyBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateBsrsm2Info", {"hipsparseCreateBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyBsrsm2Info", {"hipsparseDestroyBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateBsric02Inf", {"hipsparseCreateBsric02Inf", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyBsric02Info", {"hipsparseDestroyBsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateBsrilu02Info", {"hipsparseCreateBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyBsrilu02Info", {"hipsparseDestroyBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateCsrgemm2Info", {"hipsparseCreateCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyCsrgemm2Info", {"hipsparseDestroyCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreatePruneInfo", {"hipsparseCreatePruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyPruneInfo", {"hipsparseDestroyPruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 6. cuSPARSE Level 1 Function Reference
{"cusparseSaxpyi", {"hipsparseSaxpyi", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDaxpyi", {"hipsparseDaxpyi", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCaxpyi", {"hipsparseCaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZaxpyi", {"hipsparseZaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSdoti", {"hipsparseSdoti", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDdoti", {"hipsparseDdoti", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCdoti", {"hipsparseCdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZdoti", {"hipsparseZdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCdotci", {"hipsparseCdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZdotci", {"hipsparseZdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgthr", {"hipsparseSgthr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDgthr", {"hipsparseDgthr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCgthr", {"hipsparseCgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgthr", {"hipsparseZgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgthrz", {"hipsparseSgthrz", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDgthrz", {"hipsparseDgthrz", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCgthrz", {"hipsparseCgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgthrz", {"hipsparseZgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSroti", {"hipsparseSroti", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDroti", {"hipsparseDroti", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSsctr", {"hipsparseSsctr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDsctr", {"hipsparseDsctr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCsctr", {"hipsparseCsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZsctr", {"hipsparseZsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 7. cuSPARSE Level 2 Function Reference
{"cusparseSbsrmv", {"hipsparseSbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrmv", {"hipsparseDbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrmv", {"hipsparseCbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrmv", {"hipsparseZbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrxmv", {"hipsparseSbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrxmv", {"hipsparseDbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrxmv", {"hipsparseCbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrxmv", {"hipsparseZbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrmv", {"hipsparseScsrmv", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrmv", {"hipsparseDcsrmv", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrmv", {"hipsparseCcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrmv", {"hipsparseZcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCsrmvEx", {"hipsparseCsrmvEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCsrmvEx_bufferSize", {"hipsparseCsrmvEx_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrmv_mp", {"hipsparseScsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrmv_mp", {"hipsparseDcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrmv_mp", {"hipsparseCcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrmv_mp", {"hipsparseZcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgemvi", {"hipsparseSgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgemvi", {"hipsparseDgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgemvi", {"hipsparseCgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgemvi", {"hipsparseZgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgemvi_bufferSize", {"hipsparseSgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgemvi_bufferSize", {"hipsparseDgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgemvi_bufferSize", {"hipsparseCgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgemvi_bufferSize", {"hipsparseZgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrsv2_bufferSize", {"hipsparseSbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrsv2_bufferSize", {"hipsparseDbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrsv2_bufferSize", {"hipsparseCbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrsv2_bufferSize", {"hipsparseZbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrsv2_analysis", {"hipsparseSbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrsv2_analysis", {"hipsparseDbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrsv2_analysis", {"hipsparseCbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrsv2_analysis", {"hipsparseZbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXbsrsv2_zeroPivot", {"hipsparseXbsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsv_analysis", {"hipsparseScsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsv_analysis", {"hipsparseDcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsv_analysis", {"hipsparseCcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsv_analysis", {"hipsparseZcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCsrsv_analysisEx", {"hipsparseCsrsv_analysisEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCsrsv_solveEx", {"hipsparseCsrsv_solveEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsv2_bufferSize", {"hipsparseScsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrsv2_bufferSize", {"hipsparseDcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrsv2_bufferSize", {"hipsparseCcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsv2_bufferSize", {"hipsparseZcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsv2_analysis", {"hipsparseScsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrsv2_analysis", {"hipsparseDcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrsv2_analysis", {"hipsparseCcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsv2_analysis", {"hipsparseZcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsv2_solve", {"hipsparseScsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrsv2_solve", {"hipsparseDcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrsv2_solve", {"hipsparseCcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsv2_solve", {"hipsparseZcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsrsv2_zeroPivot", {"hipsparseXcsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseShybmv", {"hipsparseShybmv", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDhybmv", {"hipsparseDhybmv", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseChybmv", {"hipsparseChybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZhybmv", {"hipsparseZhybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseShybsv_analysis", {"hipsparseShybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDhybsv_analysis", {"hipsparseDhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseChybsv_analysis", {"hipsparseChybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZhybsv_analysis", {"hipsparseZhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseShybsv_solve", {"hipsparseShybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDhybsv_solve", {"hipsparseDhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseChybsv_solve", {"hipsparseChybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZhybsv_solve", {"hipsparseZhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 8. cuSPARSE Level 3 Function Reference
{"cusparseScsrmm", {"hipsparseScsrmm", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrmm", {"hipsparseDcsrmm", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrmm", {"hipsparseCcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrmm", {"hipsparseZcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrmm2", {"hipsparseScsrmm2", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrmm2", {"hipsparseDcsrmm2", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrmm2", {"hipsparseCcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrmm2", {"hipsparseZcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsm_analysis", {"hipsparseScsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsm_analysis", {"hipsparseDcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsm_analysis", {"hipsparseCcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsm_analysis", {"hipsparseZcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsm_solve", {"hipsparseScsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsm_solve", {"hipsparseDcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsm_solve", {"hipsparseCcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsm_solve", {"hipsparseZcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsm2_bufferSizeExt", {"hipsparseScsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsm2_bufferSizeExt", {"hipsparseDcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsm2_bufferSizeExt", {"hipsparseCcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsm2_bufferSizeExt", {"hipsparseZcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsm2_analysis", {"hipsparseScsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsm2_analysis", {"hipsparseDcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsm2_analysis", {"hipsparseCcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsm2_analysis", {"hipsparseZcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrsm2_solve", {"hipsparseScsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrsm2_solve", {"hipsparseDcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrsm2_solve", {"hipsparseCcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrsm2_solve", {"hipsparseZcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsrsm2_zeroPivot", {"hipsparseXcsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrmm", {"hipsparseSbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrmm", {"hipsparseDbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrmm", {"hipsparseCbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrmm", {"hipsparseZbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrsm2_bufferSize", {"hipsparseDbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrsm2_bufferSize", {"hipsparseZbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrsm2_analysis", {"hipsparseSbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrsm2_analysis", {"hipsparseDbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrsm2_analysis", {"hipsparseCbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrsm2_analysis", {"hipsparseZbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrsm2_solve", {"hipsparseSbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrsm2_solve", {"hipsparseDbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrsm2_solve", {"hipsparseCbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrsm2_solve", {"hipsparseZbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXbsrsm2_zeroPivot", {"hipsparseXbsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgemmi", {"hipsparseSgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgemmi", {"hipsparseDgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgemmi", {"hipsparseCgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgemmi", {"hipsparseZgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 9. cuSPARSE Extra Function Reference
{"cusparseXcsrgeamNnz", {"hipsparseXcsrgeamNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrgeam", {"hipsparseScsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrgeam", {"hipsparseDcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrgeam", {"hipsparseCcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrgeam", {"hipsparseZcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrgeam2_bufferSizeExt", {"hipsparseScsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrgeam2_bufferSizeExt", {"hipsparseDcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrgeam2_bufferSizeExt", {"hipsparseCcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrgeam2_bufferSizeExt", {"hipsparseZcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsrgemmNnz", {"hipsparseXcsrgemmNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrgemm", {"hipsparseScsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrgemm", {"hipsparseDcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrgemm", {"hipsparseCcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrgemm", {"hipsparseZcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrgemm2_bufferSizeExt", {"hipsparseScsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrgemm2_bufferSizeExt", {"hipsparseDcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrgemm2_bufferSizeExt", {"hipsparseCcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrgemm2_bufferSizeExt", {"hipsparseZcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 10. cuSPARSE Preconditioners Reference
// 10.1. Incomplete Cholesky Factorization : level 0
{"cusparseScsric0", {"hipsparseScsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsric0", {"hipsparseDcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsric0", {"hipsparseCcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsric0", {"hipsparseZcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsric02_bufferSize", {"hipsparseScsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsric02_bufferSize", {"hipsparseDcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsric02_bufferSize", {"hipsparseCcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsric02_bufferSize", {"hipsparseZcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsric02_analysis", {"hipsparseScsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsric02_analysis", {"hipsparseDcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsric02_analysis", {"hipsparseCcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsric02_analysis", {"hipsparseZcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsric02", {"hipsparseScsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsric02", {"hipsparseDcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsric02", {"hipsparseCcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsric02", {"hipsparseZcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsric02_zeroPivot", {"hipsparseXcsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsric02_analysis", {"hipsparseSbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsric02_analysis", {"hipsparseDbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsric02_analysis", {"hipsparseCbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsric02_analysis", {"hipsparseZbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsric02", {"hipsparseSbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsric02", {"hipsparseDbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsric02", {"hipsparseCbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsric02", {"hipsparseZbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXbsric02_zeroPivot", {"hipsparseXbsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 10.2. Incomplete LU Factorization: level 0
{"cusparseScsrilu0", {"hipsparseScsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrilu0", {"hipsparseDcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrilu0", {"hipsparseCcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrilu0", {"hipsparseZcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCsrilu0Ex", {"hipsparseCsrilu0Ex", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrilu02_numericBoost", {"hipsparseScsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrilu02_numericBoost", {"hipsparseDcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrilu02_numericBoost", {"hipsparseCcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrilu02_numericBoost", {"hipsparseZcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrilu02_bufferSize", {"hipsparseScsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrilu02_bufferSize", {"hipsparseDcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrilu02_bufferSize", {"hipsparseCcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrilu02_bufferSize", {"hipsparseZcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrilu02_analysis", {"hipsparseScsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrilu02_analysis", {"hipsparseDcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrilu02_analysis", {"hipsparseCcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrilu02_analysis", {"hipsparseZcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsrilu02", {"hipsparseScsrilu02", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsrilu02", {"hipsparseDcsrilu02", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsrilu02", {"hipsparseCcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrilu02", {"hipsparseZcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXbsric02_zeroPivot", {"hipsparseXcsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseSbsrilu02_numericBoost", {"hipsparseSbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrilu02_numericBoost", {"hipsparseDbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrilu02_numericBoost", {"hipsparseCbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrilu02_numericBoost", {"hipsparseZbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrilu02_bufferSize", {"hipsparseSbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrilu02_bufferSize", {"hipsparseDbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrilu02_bufferSize", {"hipsparseCbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrilu02_bufferSize", {"hipsparseZbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrilu02_analysis", {"hipsparseSbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrilu02_analysis", {"hipsparseDbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrilu02_analysis", {"hipsparseCbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrilu02_analysis", {"hipsparseZbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSbsrilu02", {"hipsparseSbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsrilu02", {"hipsparseDbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsrilu02", {"hipsparseCbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsrilu02", {"hipsparseZbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXbsrilu02_zeroPivot", {"hipsparseXbsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}},
// 10.3. Tridiagonal Solve
{"cusparseSgtsv", {"hipsparseSgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv", {"hipsparseDgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv", {"hipsparseCgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv", {"hipsparseZgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv_nopivot", {"hipsparseSgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv_nopivot", {"hipsparseDgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv_nopivot", {"hipsparseCgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv_nopivot", {"hipsparseZgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv2_bufferSizeExt", {"hipsparseSgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv2_bufferSizeExt", {"hipsparseDgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv2_bufferSizeExt", {"hipsparseCgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv2_bufferSizeExt", {"hipsparseZgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv2", {"hipsparseSgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv2", {"hipsparseDgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv2", {"hipsparseCgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv2", {"hipsparseZgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv2_nopivot_bufferSizeExt", {"hipsparseSgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv2_nopivot_bufferSizeExt", {"hipsparseDgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv2_nopivot_bufferSizeExt", {"hipsparseCgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv2_nopivot_bufferSizeExt", {"hipsparseZgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv2_nopivot", {"hipsparseSgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv2_nopivot", {"hipsparseDgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv2_nopivot", {"hipsparseCgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv2_nopivot", {"hipsparseZgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 10.4. Batched Tridiagonal Solve
{"cusparseSgtsvStridedBatch", {"hipsparseSgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsvStridedBatch", {"hipsparseDgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsvStridedBatch", {"hipsparseCgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsvStridedBatch", {"hipsparseZgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv2StridedBatch_bufferSizeExt", {"hipsparseSgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv2StridedBatch_bufferSizeExt", {"hipsparseDgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv2StridedBatch_bufferSizeExt", {"hipsparseCgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv2StridedBatch_bufferSizeExt", {"hipsparseZgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsv2StridedBatch", {"hipsparseSgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsv2StridedBatch", {"hipsparseDgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsv2StridedBatch", {"hipsparseCgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsv2StridedBatch", {"hipsparseZgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsvInterleavedBatch_bufferSizeExt", {"hipsparseSgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsvInterleavedBatch_bufferSizeExt", {"hipsparseDgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsvInterleavedBatch_bufferSizeExt", {"hipsparseCgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsvInterleavedBatch_bufferSizeExt", {"hipsparseZgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgtsvInterleavedBatch", {"hipsparseSgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgtsvInterleavedBatch", {"hipsparseDgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgtsvInterleavedBatch", {"hipsparseCgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgtsvInterleavedBatch", {"hipsparseZgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 10.5. Batched Pentadiagonal Solve
{"cusparseSgpsvInterleavedBatch_bufferSizeExt", {"hipsparseSgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgpsvInterleavedBatch_bufferSizeExt", {"hipsparseDgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgpsvInterleavedBatch_bufferSizeExt", {"hipsparseCgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgpsvInterleavedBatch_bufferSizeExt", {"hipsparseZgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgpsvInterleavedBatch", {"hipsparseSgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgpsvInterleavedBatch", {"hipsparseDgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgpsvInterleavedBatch", {"hipsparseCgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgpsvInterleavedBatch", {"hipsparseZgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 11. cuSPARSE Matrix Reorderings Reference
{"cusparseScsrcolor", {"hipsparseScsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsrcolor", {"hipsparseDcsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsrcolor", {"hipsparseCcsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsrcolor", {"hipsparseZcsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
// 12. cuSPARSE Format Conversion Reference
{"cusparseSbsr2csr", {"hipsparseSbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDbsr2csr", {"hipsparseDbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCbsr2csr", {"hipsparseCbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZbsr2csr", {"hipsparseZbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgebsr2gebsc_bufferSize", {"hipsparseSgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgebsr2gebsc_bufferSize", {"hipsparseDgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgebsr2gebsc_bufferSize", {"hipsparseCgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgebsr2gebsc_bufferSize", {"hipsparseZgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgebsr2gebsc", {"hipsparseSgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgebsr2gebsc", {"hipsparseDgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgebsr2gebsc", {"hipsparseCgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgebsr2gebsc", {"hipsparseZgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgebsr2gebsr_bufferSize", {"hipsparseSgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgebsr2gebsr_bufferSize", {"hipsparseDgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgebsr2gebsr_bufferSize", {"hipsparseCgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgebsr2gebsr_bufferSize", {"hipsparseZgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgebsr2csr", {"hipsparseSgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgebsr2csr", {"hipsparseDgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgebsr2csr", {"hipsparseCgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgebsr2csr", {"hipsparseZgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXgebsr2gebsrNnz", {"hipsparseXgebsr2gebsrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSgebsr2gebsr", {"hipsparseSgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDgebsr2gebsr", {"hipsparseDgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCgebsr2gebsr", {"hipsparseCgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZgebsr2gebsr", {"hipsparseZgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsr2gebsr_bufferSize", {"hipsparseScsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsr2gebsr_bufferSize", {"hipsparseDcsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsr2gebsr_bufferSize", {"hipsparseCcsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2gebsr_bufferSize", {"hipsparseZcsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsr2gebsrNnz", {"hipsparseXcsr2gebsrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsr2gebsr", {"hipsparseScsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsr2gebsr", {"hipsparseDcsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsr2gebsr", {"hipsparseCcsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2gebsr", {"hipsparseZcsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcoo2csr", {"hipsparseXcoo2csr", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseScsc2dense", {"hipsparseScsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsc2dense", {"hipsparseDcsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsc2dense", {"hipsparseCcsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsc2dense", {"hipsparseZcsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsc2hyb", {"hipsparseScsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsc2hyb", {"hipsparseDcsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsc2hyb", {"hipsparseCcsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsc2hyb", {"hipsparseZcsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsr2bsrNnz", {"hipsparseXcsr2bsrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsr2bsr", {"hipsparseScsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsr2bsr", {"hipsparseDcsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsr2bsr", {"hipsparseCcsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2bsr", {"hipsparseZcsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcsr2coo", {"hipsparseXcsr2coo", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseScsr2csc", {"hipsparseScsr2csc", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsr2csc", {"hipsparseDcsr2csc", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsr2csc", {"hipsparseCcsr2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2csc", {"hipsparseZcsr2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCsr2cscEx", {"hipsparseCsr2cscEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsr2dense", {"hipsparseScsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsr2dense", {"hipsparseDcsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsr2dense", {"hipsparseCcsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2dense", {"hipsparseZcsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsr2csr_compress", {"hipsparseScsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsr2csr_compress", {"hipsparseDcsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsr2csr_compress", {"hipsparseDcsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2csr_compress", {"hipsparseZcsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsr2hyb", {"hipsparseScsr2hyb", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseDcsr2hyb", {"hipsparseDcsr2hyb", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseCcsr2hyb", {"hipsparseCcsr2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsr2hyb", {"hipsparseZcsr2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSdense2csc", {"hipsparseSdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDdense2csc", {"hipsparseDdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCdense2csc", {"hipsparseCdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZdense2csc", {"hipsparseZdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSdense2csr", {"hipsparseSdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDdense2csr", {"hipsparseDdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCdense2csr", {"hipsparseCdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZdense2csr", {"hipsparseZdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSdense2hyb", {"hipsparseSdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDdense2hyb", {"hipsparseDdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCdense2hyb", {"hipsparseCdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZdense2hyb", {"hipsparseZdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseShyb2csc", {"hipsparseShyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDhyb2csc", {"hipsparseDhyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseChyb2csc", {"hipsparseChyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZhyb2csc", {"hipsparseZhyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseShyb2csr", {"hipsparseShyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDhyb2csr", {"hipsparseDhyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseChyb2csr", {"hipsparseChyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZhyb2csr", {"hipsparseZhyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseShyb2dense", {"hipsparseShyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDhyb2dense", {"hipsparseDhyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseChyb2dense", {"hipsparseChyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZhyb2dense", {"hipsparseZhyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSnnz", {"hipsparseSnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDnnz", {"hipsparseDnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCnnz", {"hipsparseCnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZnnz", {"hipsparseZnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateIdentityPermutation", {"hipsparseCreateIdentityPermutation", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseXcoosort_bufferSizeExt", {"hipsparseXcoosort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseXcoosortByRow", {"hipsparseXcoosortByRow", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseXcoosortByColumn", {"hipsparseXcoosortByColumn", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseXcsrsort_bufferSizeExt", {"hipsparseXcsrsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseXcsrsort", {"hipsparseXcsrsort", CONV_LIB_FUNC, API_SPARSE}},
{"cusparseXcscsort_bufferSizeExt", {"hipsparseXcscsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseXcscsort", {"hipsparseXcscsort", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCreateCsru2csrInfo", {"hipsparseCreateCsru2csrInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDestroyCsru2csrInfo", {"hipsparseDestroyCsru2csrInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsru2csr_bufferSizeExt", {"hipsparseScsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsru2csr_bufferSizeExt", {"hipsparseDcsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsru2csr_bufferSizeExt", {"hipsparseCcsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsru2csr_bufferSizeExt", {"hipsparseZcsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseScsru2csr", {"hipsparseScsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDcsru2csr", {"hipsparseDcsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCcsru2csr", {"hipsparseCcsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZcsru2csr", {"hipsparseZcsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneDense2csr_bufferSizeExt", {"hipsparseHpruneDense2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneDense2csr_bufferSizeExt", {"hipsparseSpruneDense2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneDense2csr_bufferSizeExt", {"hipsparseDpruneDense2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneDense2csrNnz", {"hipsparseHpruneDense2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneDense2csrNnz", {"hipsparseSpruneDense2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneDense2csrNnz", {"hipsparseDpruneDense2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneCsr2csr_bufferSizeExt", {"hipsparseHpruneCsr2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneCsr2csr_bufferSizeExt", {"hipsparseSpruneCsr2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneCsr2csr_bufferSizeExt", {"hipsparseDpruneCsr2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneCsr2csrNnz", {"hipsparseHpruneCsr2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneCsr2csrNnz", {"hipsparseSpruneCsr2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneCsr2csrNnz", {"hipsparseDpruneCsr2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneDense2csrByPercentage_bufferSizeExt", {"hipsparseHpruneDense2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneDense2csrByPercentage_bufferSizeExt", {"hipsparseSpruneDense2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneDense2csrByPercentage_bufferSizeExt", {"hipsparseDpruneDense2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneDense2csrNnzByPercentage", {"hipsparseHpruneDense2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneDense2csrNnzByPercentage", {"hipsparseSpruneDense2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneDense2csrNnzByPercentage", {"hipsparseDpruneDense2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneCsr2csrByPercentage_bufferSizeExt", {"hipsparseHpruneCsr2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneCsr2csrByPercentage_bufferSizeExt", {"hipsparseSpruneCsr2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneCsr2csrByPercentage_bufferSizeExt", {"hipsparseDpruneCsr2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHpruneCsr2csrNnzByPercentage", {"hipsparseHpruneCsr2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSpruneCsr2csrNnzByPercentage", {"hipsparseSpruneCsr2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDpruneCsr2csrNnzByPercentage", {"hipsparseDpruneCsr2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSnnz_compress", {"hipsparseSnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseDnnz_compress", {"hipsparseDnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseCnnz_compress", {"hipsparseCnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseZnnz_compress", {"hipsparseZnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}},
};
+111
Просмотреть файл
@@ -0,0 +1,111 @@
#include "CUDA2HIP.h"
// Maps the names of CUDA SPARSE API types to the corresponding HIP types
const std::map<llvm::StringRef, hipCounter> CUDA_SPARSE_TYPE_NAME_MAP{
// 1. Structs
{"cusparseContext", {"hipsparseContext", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHandle_t", {"hipsparseHandle_t", CONV_TYPE, API_SPARSE}},
{"cusparseHybMat", {"hipsparseHybMat", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHybMat_t", {"hipsparseHybMat_t", CONV_TYPE, API_SPARSE}},
{"cusparseMatDescr", {"hipsparseMatDescr", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseMatDescr_t", {"hipsparseMatDescr_t", CONV_TYPE, API_SPARSE}},
{"cusparseSolveAnalysisInfo", {"hipsparseSolveAnalysisInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSolveAnalysisInfo_t", {"hipsparseSolveAnalysisInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csrsv2Info", {"csrsv2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csrsv2Info_t", {"csrsv2Info_t", CONV_TYPE, API_SPARSE}},
{"csrsm2Info", {"csrsm2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csrsm2Info_t", {"csrsm2Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsrsv2Info", {"bsrsv2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsrsv2Info_t", {"bsrsv2Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsrsm2Info", {"bsrsm2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsrsm2Info_t", {"bsrsm2Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsric02Info", {"bsric02Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsric02Info_t", {"bsric02Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csrilu02Info", {"csrilu02Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csrilu02Info_t", {"csrilu02Info_t", CONV_TYPE, API_SPARSE}},
{"bsrilu02Info", {"bsrilu02Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"bsrilu02Info_t", {"bsrilu02Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csru2csrInfo", {"csru2csrInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"csru2csrInfo_t", {"csru2csrInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseColorInfo", {"hipsparseColorInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseColorInfo_t", {"hipsparseColorInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"pruneInfo", {"pruneInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"pruneInfo_t", {"pruneInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
// 2. Enums
{"cusparseAction_t", {"hipsparseAction_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_ACTION_SYMBOLIC", {"HIPSPARSE_ACTION_SYMBOLIC", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_ACTION_NUMERIC", {"HIPSPARSE_ACTION_NUMERIC", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseDirection_t", {"hipsparseDirection_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"CUSPARSE_DIRECTION_ROW", {"HIPSPARSE_DIRECTION_ROW", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}},
{"CUSPARSE_DIRECTION_COLUMN", {"HIPSPARSE_DIRECTION_COLUMN", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseHybPartition_t", {"hipsparseHybPartition_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_HYB_PARTITION_AUTO", {"HIPSPARSE_HYB_PARTITION_AUTO", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_HYB_PARTITION_USER", {"HIPSPARSE_HYB_PARTITION_USER", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_HYB_PARTITION_MAX", {"HIPSPARSE_HYB_PARTITION_MAX", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseDiagType_t", {"hipsparseDiagType_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_DIAG_TYPE_NON_UNIT", {"HIPSPARSE_DIAG_TYPE_NON_UNIT", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_DIAG_TYPE_UNIT", {"HIPSPARSE_DIAG_TYPE_UNIT", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseFillMode_t", {"hipsparseFillMode_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_FILL_MODE_LOWER", {"HIPSPARSE_FILL_MODE_LOWER", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_FILL_MODE_UPPER", {"HIPSPARSE_FILL_MODE_UPPER", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseIndexBase_t", {"hipsparseIndexBase_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_INDEX_BASE_ZERO", {"HIPSPARSE_INDEX_BASE_ZERO", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_INDEX_BASE_ONE", {"HIPSPARSE_INDEX_BASE_ONE", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseMatrixType_t", {"hipsparseMatrixType_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_MATRIX_TYPE_GENERAL", {"HIPSPARSE_MATRIX_TYPE_GENERAL", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_MATRIX_TYPE_SYMMETRIC", {"HIPSPARSE_MATRIX_TYPE_SYMMETRIC", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_MATRIX_TYPE_HERMITIAN", {"HIPSPARSE_MATRIX_TYPE_HERMITIAN", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_MATRIX_TYPE_TRIANGULAR", {"HIPSPARSE_MATRIX_TYPE_TRIANGULAR", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseOperation_t", {"hipsparseOperation_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_OPERATION_NON_TRANSPOSE", {"HIPSPARSE_OPERATION_NON_TRANSPOSE", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_OPERATION_TRANSPOSE", {"HIPSPARSE_OPERATION_TRANSPOSE", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE", {"HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparsePointerMode_t", {"hipsparsePointerMode_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_POINTER_MODE_HOST", {"HIPSPARSE_POINTER_MODE_HOST", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_POINTER_MODE_DEVICE", {"HIPSPARSE_POINTER_MODE_DEVICE", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseAlgMode_t", {"hipsparseAlgMode_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}},
{"CUSPARSE_ALG0", {"CUSPARSE_ALG0", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}},
{"CUSPARSE_ALG1", {"CUSPARSE_ALG1", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}},
{"CUSPARSE_ALG_NAIVE", {"CUSPARSE_ALG_NAIVE", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}},
{"CUSPARSE_ALG_MERGE_PATH", {"CUSPARSE_ALG_MERGE_PATH", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}},
{"cusparseSolvePolicy_t", {"hipsparseSolvePolicy_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_SOLVE_POLICY_NO_LEVEL", {"HIPSPARSE_SOLVE_POLICY_NO_LEVEL", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_SOLVE_POLICY_USE_LEVEL", {"HIPSPARSE_SOLVE_POLICY_USE_LEVEL", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"cusparseStatus_t", {"hipsparseStatus_t", CONV_TYPE, API_SPARSE}},
{"CUSPARSE_STATUS_SUCCESS", {"HIPSPARSE_STATUS_SUCCESS", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_NOT_INITIALIZED", {"HIPSPARSE_STATUS_NOT_INITIALIZED", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_ALLOC_FAILED", {"HIPSPARSE_STATUS_ALLOC_FAILED", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_INVALID_VALUE", {"HIPSPARSE_STATUS_INVALID_VALUE", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_ARCH_MISMATCH", {"HIPSPARSE_STATUS_ARCH_MISMATCH", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_MAPPING_ERROR", {"HIPSPARSE_STATUS_MAPPING_ERROR", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_EXECUTION_FAILED", {"HIPSPARSE_STATUS_EXECUTION_FAILED", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_INTERNAL_ERROR", {"HIPSPARSE_STATUS_INTERNAL_ERROR", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED", {"HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED", CONV_NUMERIC_LITERAL, API_SPARSE}},
{"CUSPARSE_STATUS_ZERO_PIVOT", {"HIPSPARSE_STATUS_ZERO_PIVOT", CONV_NUMERIC_LITERAL, API_SPARSE}},
};
+9 -5
Просмотреть файл
@@ -155,6 +155,10 @@ bool HipifyAction::Exclude(const hipCounter & hipToken) {
if (insertedComplexHeader) { return true; }
insertedComplexHeader = true;
return false;
case API_SPARSE:
if (insertedSPARSEHeader) { return true; }
insertedSPARSEHeader = true;
return false;
default:
return false;
}
@@ -270,14 +274,14 @@ bool HipifyAction::cudaLaunchKernel(const clang::ast_matchers::MatchFinder::Matc
if (numArgs > 0) {
OS << ", ";
// Start of the first argument.
clang::SourceLocation argStart = launchKernel->getArg(0)->getLocStart();
clang::SourceLocation argStart = llcompat::getBeginLoc(launchKernel->getArg(0));
// End of the last argument.
clang::SourceLocation argEnd = launchKernel->getArg(numArgs - 1)->getLocEnd();
clang::SourceLocation argEnd = llcompat::getEndLoc(launchKernel->getArg(numArgs - 1));
OS << readSourceText(*SM, {argStart, argEnd});
}
OS << ")";
clang::SourceRange replacementRange = getWriteRange(*SM, {launchKernel->getLocStart(), launchKernel->getLocEnd()});
clang::SourceRange replacementRange = getWriteRange(*SM, {llcompat::getBeginLoc(launchKernel), llcompat::getEndLoc(launchKernel)});
clang::SourceLocation launchStart = replacementRange.getBegin();
clang::SourceLocation launchEnd = replacementRange.getEnd();
size_t length = SM->getCharacterData(clang::Lexer::getLocForEndOfToken(launchEnd, 0, *SM, DefaultLangOptions)) - SM->getCharacterData(launchStart);
@@ -320,8 +324,8 @@ bool HipifyAction::cudaSharedIncompleteArrayVar(const clang::ast_matchers::Match
}
if (!typeName.empty()) {
clang::SourceLocation slStart = sharedVar->getLocStart();
clang::SourceLocation slEnd = sharedVar->getLocEnd();
clang::SourceLocation slStart = llcompat::getBeginLoc(sharedVar->getTypeSourceInfo()->getTypeLoc());
clang::SourceLocation slEnd = llcompat::getEndLoc(sharedVar->getTypeSourceInfo()->getTypeLoc());
clang::SourceManager* SM = Result.SourceManager;
size_t repLength = SM->getCharacterData(slEnd) - SM->getCharacterData(slStart) + 1;
std::string varName = sharedVar->getNameAsString();
+2
Просмотреть файл
@@ -9,6 +9,7 @@
#include "Statistics.h"
namespace ct = clang::tooling;
using namespace llvm;
/**
* A FrontendAction that hipifies CUDA programs.
@@ -28,6 +29,7 @@ private:
bool insertedRAND_kernelHeader = false;
bool insertedDNNHeader = false;
bool insertedFFTHeader = false;
bool insertedSPARSEHeader = false;
bool insertedComplexHeader = false;
bool firstHeader = false;
bool pragmaOnce = false;
+34 -2
Просмотреть файл
@@ -8,11 +8,11 @@ void PrintStackTraceOnErrorSignal() {
#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 8)
llvm::sys::PrintStackTraceOnErrorSignal();
#else
llvm::sys::PrintStackTraceOnErrorSignal(clang::StringRef());
llvm::sys::PrintStackTraceOnErrorSignal(StringRef());
#endif
}
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, clang::StringRef file) {
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, StringRef file) {
#if LLVM_VERSION_MAJOR > 3
// getReplacements() now returns a map from filename to Replacements - so create an entry
// for this source file and return a reference to it.
@@ -40,4 +40,36 @@ void EnterPreprocessorTokenStream(clang::Preprocessor& _pp, const clang::Token *
#endif
}
clang::SourceLocation getBeginLoc(const clang::Stmt* stmt) {
#if LLVM_VERSION_MAJOR < 8
return stmt->getLocStart();
#else
return stmt->getBeginLoc();
#endif
}
clang::SourceLocation getBeginLoc(const clang::TypeLoc& typeLoc) {
#if LLVM_VERSION_MAJOR < 8
return typeLoc.getLocStart();
#else
return typeLoc.getBeginLoc();
#endif
}
clang::SourceLocation getEndLoc(const clang::Stmt* stmt) {
#if LLVM_VERSION_MAJOR < 8
return stmt->getLocEnd();
#else
return stmt->getEndLoc();
#endif
}
clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc) {
#if LLVM_VERSION_MAJOR < 8
return typeLoc.getLocEnd();
#else
return typeLoc.getEndLoc();
#endif
}
} // namespace llcompat
+9 -1
Просмотреть файл
@@ -25,15 +25,23 @@ namespace llcompat {
#define LLVM_DEBUG(X) DEBUG(X)
#endif
clang::SourceLocation getBeginLoc(const clang::Stmt* stmt);
clang::SourceLocation getBeginLoc(const clang::TypeLoc& typeLoc);
clang::SourceLocation getEndLoc(const clang::Stmt* stmt);
clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc);
void PrintStackTraceOnErrorSignal();
using namespace llvm;
/**
* Get the replacement map for a given filename in a RefactoringTool.
*
* Older LLVM versions don't actually support multiple filenames, so everything all gets
* smushed together. It is the caller's responsibility to cope with this.
*/
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, clang::StringRef file);
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, StringRef file);
/**
* Add a Replacement to a Replacements.
+8 -1
Просмотреть файл
@@ -43,7 +43,14 @@ const char *counterNames[NUM_CONV_TYPES] = {
};
const char *apiNames[NUM_API_TYPES] = {
"CUDA Driver API", "CUDA RT API", "CUBLAS API", "CURAND API", "CUDNN API", "CUFFT API", "cuComplex API"
"CUDA Driver API",
"CUDA RT API",
"cuComplex API",
"cuBLAS API",
"cuRAND API",
"cuDNN API",
"cuFFT API",
"cuSPARSE"
};
namespace {
+2 -1
Просмотреть файл
@@ -103,11 +103,12 @@ constexpr int NUM_CONV_TYPES = (int) ConvTypes::CONV_LAST;
enum ApiTypes {
API_DRIVER = 0,
API_RUNTIME,
API_COMPLEX,
API_BLAS,
API_RAND,
API_DNN,
API_FFT,
API_COMPLEX,
API_SPARSE,
API_LAST
};
constexpr int NUM_API_TYPES = (int) ApiTypes::API_LAST;
+6
Просмотреть файл
@@ -41,8 +41,14 @@ THE SOFTWARE.
#define __HIP_SIZE_OF_HEAP (__HIP_NUM_PAGES * __HIP_SIZE_OF_PAGE)
#if __HIP__ && __HIP_DEVICE_COMPILE__
__attribute__((weak)) __device__ char __hip_device_heap[__HIP_SIZE_OF_HEAP];
__attribute__((weak)) __device__
uint32_t __hip_device_page_flag[__HIP_NUM_PAGES];
#else
extern __device__ char __hip_device_heap[];
extern __device__ uint32_t __hip_device_page_flag[];
#endif
extern "C" inline __device__ void* __hip_malloc(size_t size) {
char* heap = (char*)__hip_device_heap;
+204
Просмотреть файл
@@ -0,0 +1,204 @@
// automatically generated sources
#ifndef _HIP_PROF_API_H
#define _HIP_PROF_API_H
#include <atomic>
#include <iostream>
#include <mutex>
#include "hip/hcc_detail/hip_prof_str.h"
template <typename Record, typename Fun, typename Act>
class api_callbacks_table_templ {
public:
typedef std::recursive_mutex mutex_t;
typedef Record record_t;
typedef Fun fun_t;
typedef Act act_t;
// HIP API callbacks table
struct hip_cb_table_entry_t {
volatile std::atomic<bool> sync;
volatile std::atomic<uint32_t> sem;
act_t act;
void* a_arg;
fun_t fun;
void* arg;
};
struct hip_cb_table_t {
hip_cb_table_entry_t arr[HIP_API_ID_NUMBER];
};
api_callbacks_table_templ() {
memset(&callbacks_table_, 0, sizeof(callbacks_table_));
}
bool set_activity(uint32_t id, act_t fun, void* arg) {
std::lock_guard<mutex_t> lock(mutex_);
bool ret = true;
if (id == HIP_API_ID_ANY) {
for (unsigned i = 0; i < HIP_API_ID_NUMBER; ++i) set_activity(i, fun, arg);
} else if (id < HIP_API_ID_NUMBER) {
cb_sync(id);
callbacks_table_.arr[id].act = fun;
callbacks_table_.arr[id].a_arg = arg;
cb_release(id);
} else {
ret = false;
}
return ret;
}
bool set_callback(uint32_t id, fun_t fun, void* arg) {
std::lock_guard<mutex_t> lock(mutex_);
bool ret = true;
if (id == HIP_API_ID_ANY) {
for (unsigned i = 0; i < HIP_API_ID_NUMBER; ++i) set_callback(i, fun, arg);
} else if (id < HIP_API_ID_NUMBER) {
cb_sync(id);
callbacks_table_.arr[id].fun = fun;
callbacks_table_.arr[id].arg = arg;
cb_release(id);
} else {
ret = false;
}
return ret;
}
inline hip_cb_table_entry_t& entry(const uint32_t& id) {
return callbacks_table_.arr[id];
}
inline void sem_sync(const uint32_t& id) {
sem_increment(id);
if (entry(id).sync.load() == true) sync_wait(id);
}
inline void sem_release(const uint32_t& id) {
sem_decrement(id);
}
private:
inline void cb_sync(const uint32_t& id) {
entry(id).sync.store(true);
while (entry(id).sem.load() != 0) {}
}
inline void cb_release(const uint32_t& id) {
entry(id).sync.store(false);
}
inline void sem_increment(const uint32_t& id) {
const uint32_t prev = entry(id).sem.fetch_add(1);
if (prev == UINT32_MAX) {
std::cerr << "sem overflow id = " << id << std::endl << std::flush;
abort();
}
}
inline void sem_decrement(const uint32_t& id) {
const uint32_t prev = entry(id).sem.fetch_sub(1);
if (prev == 0) {
std::cerr << "sem corrupted id = " << id << std::endl << std::flush;
abort();
}
}
void sync_wait(const uint32_t& id) {
sem_decrement(id);
while (entry(id).sync.load() == true) {}
sem_increment(id);
}
mutex_t mutex_;
hip_cb_table_t callbacks_table_;
};
#if USE_PROF_API
#include <prof_protocol.h>
static const uint32_t HIP_DOMAIN_ID = ACTIVITY_DOMAIN_HIP_API;
typedef activity_record_t hip_api_record_t;
typedef activity_rtapi_callback_t hip_api_callback_t;
typedef activity_sync_callback_t hip_act_callback_t;
// HIP API callbacks spawner object macro
#define HIP_CB_SPAWNER_OBJECT(CB_ID) \
hip_api_data_t api_data{}; \
INIT_CB_ARGS_DATA(CB_ID, api_data); \
api_callbacks_spawner_t<HIP_API_ID_##CB_ID> __api_tracer(HIP_API_ID_##CB_ID, api_data);
typedef api_callbacks_table_templ<hip_api_record_t,
hip_api_callback_t,
hip_act_callback_t> api_callbacks_table_t;
extern api_callbacks_table_t callbacks_table;
template <int cid_>
class api_callbacks_spawner_t {
public:
api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) :
api_data_(api_data),
record_({})
{
if (cid_ >= HIP_API_ID_NUMBER) {
fprintf(stderr, "HIP %s bad id %d\n", __FUNCTION__, cid_);
abort();
}
callbacks_table.sem_sync(cid_);
act = entry(cid_).act;
a_arg = entry(cid_).a_arg;
fun = entry(cid_).fun;
arg = entry(cid_).arg;
api_data_.phase = 0;
if (act != NULL) act(cid_, &record_, &api_data_, a_arg);
if (fun != NULL) fun(HIP_DOMAIN_ID, cid_, &api_data_, arg);
}
~api_callbacks_spawner_t() {
api_data_.phase = 1;
if (act != NULL) act(cid_, &record_, &api_data_, a_arg);
if (fun != NULL) fun(HIP_DOMAIN_ID, cid_, &api_data_, arg);
callbacks_table.sem_release(cid_);
}
private:
inline api_callbacks_table_t::hip_cb_table_entry_t& entry(const uint32_t& id) {
return callbacks_table.entry(id);
}
hip_api_data_t& api_data_;
hip_api_record_t record_;
hip_act_callback_t act;
void* a_arg;
hip_api_callback_t fun;
void* arg;
};
template <>
class api_callbacks_spawner_t<HIP_API_ID_NUMBER> {
public:
api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) {}
};
#else
#define HIP_CB_SPAWNER_OBJECT(x) do {} while(0)
class api_callbacks_table_t {
public:
typedef void* act_t;
typedef void* fun_t;
bool set_activity(uint32_t id, act_t fun, void* arg) { return true; }
bool set_callback(uint32_t id, fun_t fun, void* arg) { return true; }
};
#endif
#endif // _HIP_PROF_API_H
Разница между файлами не показана из-за своего большого размера Загрузить разницу
+47
Просмотреть файл
@@ -1385,6 +1385,32 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t siz
size_t offset __dparm(0), hipMemcpyKind kind __dparm(hipMemcpyHostToDevice));
/**
* @brief Copies the memory address of symbol @p symbolName to @p devPtr
*
* @param[in] symbolName - Symbol on device
* @param[out] devPtr - Pointer to a pointer to the memory referred to by the symbol
* @return #hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound
*
* @see hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync,
* hipMemcpyFromSymbolAsync
*/
hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName);
/**
* @brief Copies the size of symbol @p symbolName to @p size
*
* @param[in] symbolName - Symbol on device
* @param[out] size - Pointer to the size of the symbol
* @return #hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound
*
* @see hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync,
* hipMemcpyFromSymbolAsync
*/
hipError_t hipGetSymbolSize(size_t* size, const void* symbolName);
/**
* @brief Copies @p sizeBytes bytes from the memory area pointed to by @p src to the memory area
* pointed to by @p offset bytes from the start of symbol @p symbol
@@ -2334,6 +2360,9 @@ hipError_t hipFuncGetAttributes(hipFuncAttributes* attr, const void* func);
hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name);
hipError_t ihipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name);
hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name);
/**
* @brief builds module from code object which resides in host memory. Image is pointer to that
@@ -2581,6 +2610,24 @@ hipError_t hipLaunchByPtr(const void* func);
} /* extern "c" */
#endif
#include <hip/hcc_detail/hip_prof_api.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Callback/Activity API
*/
hipError_t hipRegisterApiCallback(uint32_t id, void* fun, void* arg);
hipError_t hipRemoveApiCallback(uint32_t id);
hipError_t hipRegisterActivityCallback(uint32_t id, void* fun, void* arg);
hipError_t hipRemoveActivityCallback(uint32_t id);
static inline const char* hipApiName(const uint32_t& id) { return hip_api_name(id); }
const char* hipKernelNameRef(hipFunction_t f);
#ifdef __cplusplus
} /* extern "C" */
#endif
#ifdef __cplusplus
hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr,
+8
Просмотреть файл
@@ -551,6 +551,14 @@ inline static hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolN
dst, symbolName, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(kind), stream));
}
inline static hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) {
return hipCUDAErrorTohipError(cudaGetSymbolAddress(devPtr, symbolName));
}
inline static hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) {
return hipCUDAErrorTohipError(cudaGetSymbolSize(size, symbolName));
}
inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch,
size_t width, size_t height, hipMemcpyKind kind) {
return hipCUDAErrorTohipError(
+1 -5
Просмотреть файл
@@ -23,10 +23,6 @@ THE SOFTWARE.
#include <stdio.h>
#include <iostream>
#include "hip/hip_runtime.h"
#ifdef __HIP_PLATFORM_HCC__
#include <hc.hpp>
#endif
#define CHECK(cmd) \
{ \
@@ -44,7 +40,7 @@ __global__ void bit_extract_kernel(uint32_t* C_d, const uint32_t* A_d, size_t N)
for (size_t i = offset; i < N; i += stride) {
#ifdef __HIP_PLATFORM_HCC__
C_d[i] = hc::__bitextract_u32(A_d[i], 8, 4);
C_d[i] = __bitextract_u32(A_d[i], 8, 4);
#else /* defined __HIP_PLATFORM_NVCC__ or other path */
C_d[i] = ((A_d[i] & 0xf00) >> 8);
#endif
+14 -43
Просмотреть файл
@@ -26,34 +26,9 @@ THE SOFTWARE.
#include "hip/hip_runtime.h"
#include "hip_hcc_internal.h"
#include "hip_fatbin.h"
#include "trace_helper.h"
constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF"
#define CLANG_OFFLOAD_BUNDLER_MAGIC "__CLANG_OFFLOAD_BUNDLE__"
#define AMDGCN_AMDHSA_TRIPLE "hip-amdgcn-amd-amdhsa"
struct __ClangOffloadBundleDesc {
uint64_t offset;
uint64_t size;
uint64_t tripleSize;
const char triple[1];
};
struct __ClangOffloadBundleHeader {
const char magic[sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC) - 1];
uint64_t numBundles;
__ClangOffloadBundleDesc desc[1];
};
struct __CudaFatBinaryWrapper {
unsigned int magic;
unsigned int version;
__ClangOffloadBundleHeader* binary;
void* unused;
};
extern "C" std::vector<hipModule_t>*
__hipRegisterFatBinary(const void* data)
{
@@ -108,21 +83,13 @@ __hipRegisterFatBinary(const void* data)
std::string image{reinterpret_cast<const char*>(
reinterpret_cast<uintptr_t>(header) + desc->offset), desc->size};
if (HIP_DUMP_CODE_OBJECT)
__hipDumpCodeObject(image);
module->executable = hip_impl::load_executable(image, module->executable, agent);
if (module->executable.handle) {
modules->at(deviceId) = module;
tprintf(DB_FB, "Loaded code object for %s\n", name);
if (HIP_DUMP_CODE_OBJECT) {
char fname[30];
static std::atomic<int> index;
sprintf(fname, "__hip_dump_code_object%04d.o", index++);
tprintf(DB_FB, "Dump code object %s\n", fname);
std::ofstream ofs;
ofs.open(fname, std::ios::binary);
ofs << image;
ofs.close();
}
} else {
fprintf(stderr, "Failed to load code object for %s\n", name);
abort();
@@ -159,17 +126,19 @@ extern "C" void __hipRegisterFunction(
dim3* gridDim,
int* wSize)
{
HIP_INIT_API(modules, hostFunction, deviceFunction, deviceName);
HIP_INIT_API(NONE, modules, hostFunction, deviceFunction, deviceName);
std::vector<hipFunction_t> functions{g_deviceCnt};
assert(modules && modules->size() >= g_deviceCnt);
for (int deviceId = 0; deviceId < g_deviceCnt; ++deviceId) {
hipFunction_t function;
if (hipSuccess == hipModuleGetFunction(&function, modules->at(deviceId), deviceName)) {
if (hipSuccess == hipModuleGetFunction(&function, modules->at(deviceId), deviceName) &&
function != nullptr) {
functions[deviceId] = function;
}
else {
tprintf(DB_FB, "missing kernel %s for device %d\n", deviceName, deviceId);
tprintf(DB_FB, "__hipRegisterFunction cannot find kernel %s for"
" device %d\n", deviceName, deviceId);
}
}
@@ -212,7 +181,7 @@ hipError_t hipSetupArgument(
size_t size,
size_t offset)
{
HIP_INIT_API(arg, size, offset);
HIP_INIT_API(hipSetupArgument, arg, size, offset);
auto ctx = ihipGetTlsDefaultCtx();
LockedAccessor_CtxCrit_t crit(ctx->criticalData());
auto& arguments = crit->_execStack.top()._arguments;
@@ -227,7 +196,7 @@ hipError_t hipSetupArgument(
hipError_t hipLaunchByPtr(const void *hostFunction)
{
HIP_INIT_API(hostFunction);
HIP_INIT_API(hipLaunchByPtr, hostFunction);
ihipExec_t exec;
{
auto ctx = ihipGetTlsDefaultCtx();
@@ -249,9 +218,11 @@ hipError_t hipLaunchByPtr(const void *hostFunction)
hipError_t e = hipSuccess;
decltype(g_functions)::iterator it;
if ((it = g_functions.find(hostFunction)) == g_functions.end()) {
if ((it = g_functions.find(hostFunction)) == g_functions.end() ||
!it->second[deviceId]) {
e = hipErrorUnknown;
fprintf(stderr, "kernel %p not found!\n", hostFunction);
fprintf(stderr, "hipLaunchByPtr cannot find kernel with stub address %p"
" for device %d!\n", hostFunction, deviceId);
abort();
} else {
size_t size = exec._arguments.size();
+23 -23
Просмотреть файл
@@ -40,7 +40,7 @@ void ihipCtxStackUpdate() {
}
hipError_t hipInit(unsigned int flags) {
HIP_INIT_API(flags);
HIP_INIT_API(hipInit, flags);
hipError_t e = hipSuccess;
@@ -53,7 +53,7 @@ hipError_t hipInit(unsigned int flags) {
}
hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) {
HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init
HIP_INIT_API(hipCtxCreate, ctx, flags, device); // FIXME - review if we want to init
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(device);
{
@@ -71,7 +71,7 @@ hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) {
}
hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) {
HIP_INIT_API(device, deviceId); // FIXME - review if we want to init
HIP_INIT_API(hipDeviceGet, device, deviceId); // FIXME - review if we want to init
auto deviceHandle = ihipGetDevice(deviceId);
@@ -86,7 +86,7 @@ hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) {
};
hipError_t hipDriverGetVersion(int* driverVersion) {
HIP_INIT_API(driverVersion);
HIP_INIT_API(hipDriverGetVersion, driverVersion);
hipError_t e = hipSuccess;
if (driverVersion) {
*driverVersion = 4;
@@ -98,7 +98,7 @@ hipError_t hipDriverGetVersion(int* driverVersion) {
}
hipError_t hipRuntimeGetVersion(int* runtimeVersion) {
HIP_INIT_API(runtimeVersion);
HIP_INIT_API(hipRuntimeGetVersion, runtimeVersion);
hipError_t e = hipSuccess;
if (runtimeVersion) {
*runtimeVersion = HIP_VERSION_PATCH;
@@ -110,7 +110,7 @@ hipError_t hipRuntimeGetVersion(int* runtimeVersion) {
}
hipError_t hipCtxDestroy(hipCtx_t ctx) {
HIP_INIT_API(ctx);
HIP_INIT_API(hipCtxDestroy, ctx);
hipError_t e = hipSuccess;
ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx();
ihipCtx_t* primaryCtx = ((ihipDevice_t*)ctx->getDevice())->_primaryCtx;
@@ -134,7 +134,7 @@ hipError_t hipCtxDestroy(hipCtx_t ctx) {
}
hipError_t hipCtxPopCurrent(hipCtx_t* ctx) {
HIP_INIT_API(ctx);
HIP_INIT_API(hipCtxPopCurrent, ctx);
hipError_t e = hipSuccess;
ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx();
auto deviceHandle = currentCtx->getDevice();
@@ -155,7 +155,7 @@ hipError_t hipCtxPopCurrent(hipCtx_t* ctx) {
}
hipError_t hipCtxPushCurrent(hipCtx_t ctx) {
HIP_INIT_API(ctx);
HIP_INIT_API(hipCtxPushCurrent, ctx);
hipError_t e = hipSuccess;
if (ctx != NULL) { // TODO- is this check needed?
ihipSetTlsDefaultCtx(ctx);
@@ -168,7 +168,7 @@ hipError_t hipCtxPushCurrent(hipCtx_t ctx) {
}
hipError_t hipCtxGetCurrent(hipCtx_t* ctx) {
HIP_INIT_API(ctx);
HIP_INIT_API(hipCtxGetCurrent, ctx);
hipError_t e = hipSuccess;
if ((tls_getPrimaryCtx) || tls_ctxStack.empty()) {
*ctx = ihipGetTlsDefaultCtx();
@@ -179,7 +179,7 @@ hipError_t hipCtxGetCurrent(hipCtx_t* ctx) {
}
hipError_t hipCtxSetCurrent(hipCtx_t ctx) {
HIP_INIT_API(ctx);
HIP_INIT_API(hipCtxSetCurrent, ctx);
hipError_t e = hipSuccess;
if (ctx == NULL) {
tls_ctxStack.pop();
@@ -192,7 +192,7 @@ hipError_t hipCtxSetCurrent(hipCtx_t ctx) {
}
hipError_t hipCtxGetDevice(hipDevice_t* device) {
HIP_INIT_API(device);
HIP_INIT_API(hipCtxGetDevice, device);
hipError_t e = hipSuccess;
ihipCtx_t* ctx = ihipGetTlsDefaultCtx();
@@ -208,7 +208,7 @@ hipError_t hipCtxGetDevice(hipDevice_t* device) {
}
hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) {
HIP_INIT_API(apiVersion);
HIP_INIT_API(hipCtxGetApiVersion, apiVersion);
if (apiVersion) {
*apiVersion = 4;
@@ -218,7 +218,7 @@ hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) {
}
hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) {
HIP_INIT_API(cacheConfig);
HIP_INIT_API(hipCtxGetCacheConfig, cacheConfig);
*cacheConfig = hipFuncCachePreferNone;
@@ -226,7 +226,7 @@ hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) {
}
hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) {
HIP_INIT_API(cacheConfig);
HIP_INIT_API(hipCtxSetCacheConfig, cacheConfig);
// Nop, AMD does not support variable cache configs.
@@ -234,7 +234,7 @@ hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) {
}
hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) {
HIP_INIT_API(config);
HIP_INIT_API(hipCtxSetSharedMemConfig, config);
// Nop, AMD does not support variable shared mem configs.
@@ -242,7 +242,7 @@ hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) {
}
hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) {
HIP_INIT_API(pConfig);
HIP_INIT_API(hipCtxGetSharedMemConfig, pConfig);
*pConfig = hipSharedMemBankSizeFourByte;
@@ -250,12 +250,12 @@ hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) {
}
hipError_t hipCtxSynchronize(void) {
HIP_INIT_API(1);
HIP_INIT_API(hipCtxSynchronize, 1);
return ihipLogStatus(ihipSynchronize()); // TODP Shall check validity of ctx?
}
hipError_t hipCtxGetFlags(unsigned int* flags) {
HIP_INIT_API(flags);
HIP_INIT_API(hipCtxGetFlags, flags);
hipError_t e = hipSuccess;
ihipCtx_t* tempCtx;
tempCtx = ihipGetTlsDefaultCtx();
@@ -264,7 +264,7 @@ hipError_t hipCtxGetFlags(unsigned int* flags) {
}
hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active) {
HIP_INIT_API(dev, flags, active);
HIP_INIT_API(hipDevicePrimaryCtxGetState, dev, flags, active);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
@@ -286,7 +286,7 @@ hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int
}
hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) {
HIP_INIT_API(dev);
HIP_INIT_API(hipDevicePrimaryCtxRelease, dev);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
@@ -297,7 +297,7 @@ hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) {
}
hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) {
HIP_INIT_API(pctx, dev);
HIP_INIT_API(hipDevicePrimaryCtxRetain, pctx, dev);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
@@ -309,7 +309,7 @@ hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) {
}
hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) {
HIP_INIT_API(dev);
HIP_INIT_API(hipDevicePrimaryCtxReset, dev);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
@@ -322,7 +322,7 @@ hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) {
}
hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags) {
HIP_INIT_API(dev, flags);
HIP_INIT_API(hipDevicePrimaryCtxSetFlags, dev, flags);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
+20 -20
Просмотреть файл
@@ -30,7 +30,7 @@ THE SOFTWARE.
//-------------------------------------------------------------------------------------------------
// TODO - does this initialize HIP runtime?
hipError_t hipGetDevice(int* deviceId) {
HIP_INIT_API(deviceId);
HIP_INIT_API(hipGetDevice, deviceId);
hipError_t e = hipSuccess;
@@ -69,12 +69,12 @@ hipError_t ihipGetDeviceCount(int* count) {
}
hipError_t hipGetDeviceCount(int* count) {
HIP_INIT_API(count);
HIP_INIT_API(hipGetDeviceCount, count);
return ihipLogStatus(ihipGetDeviceCount(count));
}
hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) {
HIP_INIT_API(cacheConfig);
HIP_INIT_API(hipDeviceSetCacheConfig, cacheConfig);
// Nop, AMD does not support variable cache configs.
@@ -82,7 +82,7 @@ hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) {
}
hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) {
HIP_INIT_API(cacheConfig);
HIP_INIT_API(hipDeviceGetCacheConfig, cacheConfig);
if (cacheConfig == nullptr) {
return ihipLogStatus(hipErrorInvalidValue);
@@ -94,7 +94,7 @@ hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) {
}
hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) {
HIP_INIT_API(pValue, limit);
HIP_INIT_API(hipDeviceGetLimit, pValue, limit);
if (pValue == nullptr) {
return ihipLogStatus(hipErrorInvalidValue);
}
@@ -107,7 +107,7 @@ hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) {
}
hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t cacheConfig) {
HIP_INIT_API(cacheConfig);
HIP_INIT_API(hipFuncSetCacheConfig, cacheConfig);
// Nop, AMD does not support variable cache configs.
@@ -115,7 +115,7 @@ hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t cacheConfig) {
}
hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) {
HIP_INIT_API(config);
HIP_INIT_API(hipDeviceSetSharedMemConfig, config);
// Nop, AMD does not support variable shared mem configs.
@@ -123,7 +123,7 @@ hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) {
}
hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) {
HIP_INIT_API(pConfig);
HIP_INIT_API(hipDeviceGetSharedMemConfig, pConfig);
*pConfig = hipSharedMemBankSizeFourByte;
@@ -131,7 +131,7 @@ hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) {
}
hipError_t hipSetDevice(int deviceId) {
HIP_INIT_API(deviceId);
HIP_INIT_API(hipSetDevice, deviceId);
if ((deviceId < 0) || (deviceId >= g_deviceCnt)) {
return ihipLogStatus(hipErrorInvalidDevice);
} else {
@@ -142,12 +142,12 @@ hipError_t hipSetDevice(int deviceId) {
}
hipError_t hipDeviceSynchronize(void) {
HIP_INIT_SPECIAL_API(TRACE_SYNC);
HIP_INIT_SPECIAL_API(hipDeviceSynchronize, TRACE_SYNC);
return ihipLogStatus(ihipSynchronize());
}
hipError_t hipDeviceReset(void) {
HIP_INIT_API();
HIP_INIT_API(hipDeviceReset, );
auto* ctx = ihipGetTlsDefaultCtx();
@@ -287,7 +287,7 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device
}
hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) {
HIP_INIT_API(pi, attr, device);
HIP_INIT_API(hipDeviceGetAttribute, pi, attr, device);
if ((device < 0) || (device >= g_deviceCnt)) {
return ihipLogStatus(hipErrorInvalidDevice);
}
@@ -314,7 +314,7 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) {
}
hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) {
HIP_INIT_API(props, device);
HIP_INIT_API(hipGetDeviceProperties, props, device);
if ((device < 0) || (device >= g_deviceCnt)) {
return ihipLogStatus(hipErrorInvalidDevice);
}
@@ -322,7 +322,7 @@ hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) {
}
hipError_t hipSetDeviceFlags(unsigned int flags) {
HIP_INIT_API(flags);
HIP_INIT_API(hipSetDeviceFlags, flags);
hipError_t e = hipSuccess;
@@ -367,7 +367,7 @@ hipError_t hipSetDeviceFlags(unsigned int flags) {
};
hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device) {
HIP_INIT_API(major, minor, device);
HIP_INIT_API(hipDeviceComputeCapability, major, minor, device);
hipError_t e = hipSuccess;
if ((device < 0) || (device >= g_deviceCnt)) {
e = hipErrorInvalidDevice;
@@ -380,7 +380,7 @@ hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device
hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device) {
// Cast to void* here to avoid printing garbage in debug modes.
HIP_INIT_API((void*)name, len, device);
HIP_INIT_API(hipDeviceGetName, (void*)name, len, device);
hipError_t e = hipSuccess;
if ((device < 0) || (device >= g_deviceCnt)) {
e = hipErrorInvalidDevice;
@@ -394,7 +394,7 @@ hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device) {
hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) {
// Cast to void* here to avoid printing garbage in debug modes.
HIP_INIT_API((void*)pciBusId, len, device);
HIP_INIT_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device);
hipError_t e = hipErrorInvalidValue;
if ((device < 0) || (device >= g_deviceCnt)) {
e = hipErrorInvalidDevice;
@@ -413,7 +413,7 @@ hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) {
}
hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device) {
HIP_INIT_API(bytes, device);
HIP_INIT_API(hipDeviceTotalMem, bytes, device);
hipError_t e = hipSuccess;
if ((device < 0) || (device >= g_deviceCnt)) {
e = hipErrorInvalidDevice;
@@ -425,7 +425,7 @@ hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device) {
}
hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId) {
HIP_INIT_API(device, pciBusId);
HIP_INIT_API(hipDeviceGetByPCIBusId, device, pciBusId);
hipDeviceProp_t tempProp;
int deviceCount = 0;
hipError_t e = hipErrorInvalidValue;
@@ -451,7 +451,7 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId) {
}
hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* prop) {
HIP_INIT_API(device, prop);
HIP_INIT_API(hipChooseDevice, device, prop);
hipDeviceProp_t tempProp;
hipError_t e = hipSuccess;
if ((device == NULL) || (prop == NULL)) {
+4 -4
Просмотреть файл
@@ -30,7 +30,7 @@ THE SOFTWARE.
//---
hipError_t hipGetLastError() {
HIP_INIT_API();
HIP_INIT_API(hipGetLastError);
// Return last error, but then reset the state:
hipError_t e = ihipLogStatus(tls_lastHipError);
@@ -39,20 +39,20 @@ hipError_t hipGetLastError() {
}
hipError_t hipPeekAtLastError() {
HIP_INIT_API();
HIP_INIT_API(hipPeekAtLastError);
// peek at last error, but don't reset it.
return ihipLogStatus(tls_lastHipError);
}
const char* hipGetErrorName(hipError_t hip_error) {
HIP_INIT_API(hip_error);
HIP_INIT_API(hipGetErrorName, hip_error);
return ihipErrorString(hip_error);
}
const char* hipGetErrorString(hipError_t hip_error) {
HIP_INIT_API(hip_error);
HIP_INIT_API(hipGetErrorString, hip_error);
// TODO - return a message explaining the error.
// TODO - This should be set up to return the same string reported in the the doxygen comments,
+7 -7
Просмотреть файл
@@ -95,20 +95,20 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) {
}
hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) {
HIP_INIT_API(event, flags);
HIP_INIT_API(hipEventCreateWithFlags, event, flags);
return ihipLogStatus(ihipEventCreate(event, flags));
}
hipError_t hipEventCreate(hipEvent_t* event) {
HIP_INIT_API(event);
HIP_INIT_API(hipEventCreate, event);
return ihipLogStatus(ihipEventCreate(event, 0));
}
hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
HIP_INIT_SPECIAL_API(TRACE_SYNC, event, stream);
HIP_INIT_SPECIAL_API(hipEventRecord, TRACE_SYNC, event, stream);
auto ecd = event->locked_copyCrit();
@@ -153,7 +153,7 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
hipError_t hipEventDestroy(hipEvent_t event) {
HIP_INIT_API(event);
HIP_INIT_API(hipEventDestroy, event);
if (event) {
delete event;
@@ -165,7 +165,7 @@ hipError_t hipEventDestroy(hipEvent_t event) {
}
hipError_t hipEventSynchronize(hipEvent_t event) {
HIP_INIT_SPECIAL_API(TRACE_SYNC, event);
HIP_INIT_SPECIAL_API(hipEventSynchronize, TRACE_SYNC, event);
if (!(event->_flags & hipEventReleaseToSystem)) {
tprintf(DB_WARN,
@@ -198,7 +198,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) {
}
hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) {
HIP_INIT_API(ms, start, stop);
HIP_INIT_API(hipEventElapsedTime, ms, start, stop);
hipError_t status = hipSuccess;
@@ -255,7 +255,7 @@ hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) {
}
hipError_t hipEventQuery(hipEvent_t event) {
HIP_INIT_SPECIAL_API(TRACE_QUERY, event);
HIP_INIT_SPECIAL_API(hipEventQuery, TRACE_QUERY, event);
if (!(event->_flags & hipEventReleaseToSystem)) {
tprintf(DB_WARN,
+91
Просмотреть файл
@@ -0,0 +1,91 @@
/*
Copyright (c) 2018 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <string>
#include <fstream>
#include "hip_fatbin.h"
#include "hip/hip_runtime.h"
#include "hip_hcc_internal.h"
#include "trace_helper.h"
void __hipDumpCodeObject(const std::string& image) {
char fname[30];
static std::atomic<int> index;
sprintf(fname, "__hip_dump_code_object%04d.o", index++);
tprintf(DB_FB, "Dump code object %s\n", fname);
std::ofstream ofs;
ofs.open(fname, std::ios::binary);
ofs << image;
ofs.close();
}
// Returns a pointer to the code object in the fatbin. The pointer should not
// be freed.
const void* __hipExtractCodeObjectFromFatBinary(const void* data,
const char* agent_name)
{
HIP_INIT();
tprintf(DB_FB, "Enter __hipExtractCodeObjectFromFatBinary(%p, \"%s\")\n",
data, agent_name);
const __ClangOffloadBundleHeader* header
= reinterpret_cast<const __ClangOffloadBundleHeader*>(data);
std::string magic(reinterpret_cast<const char*>(header),
sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC) - 1);
if (magic.compare(CLANG_OFFLOAD_BUNDLER_MAGIC)) {
return nullptr;
}
const __ClangOffloadBundleDesc* desc = &header->desc[0];
for (uint64_t i = 0; i < header->numBundles; ++i,
desc = reinterpret_cast<const __ClangOffloadBundleDesc*>(
reinterpret_cast<uintptr_t>(&desc->triple[0]) + desc->tripleSize)) {
std::string triple{&desc->triple[0], sizeof(AMDGCN_AMDHSA_TRIPLE) - 1};
if (triple.compare(AMDGCN_AMDHSA_TRIPLE))
continue;
std::string target{&desc->triple[sizeof(AMDGCN_AMDHSA_TRIPLE)],
desc->tripleSize - sizeof(AMDGCN_AMDHSA_TRIPLE)};
tprintf(DB_FB, "Found hip-clang bundle for %s\n", target.c_str());
if (target.compare(agent_name)) {
continue;
}
auto *codeobj = reinterpret_cast<const char*>(
reinterpret_cast<uintptr_t>(header) + desc->offset);
if (HIP_DUMP_CODE_OBJECT)
__hipDumpCodeObject(std::string{codeobj, desc->size});
tprintf(DB_FB, "__hipExtractCodeObjectFromFatBinary succeeds and returns %p\n",
codeobj);
return codeobj;
}
// hipcc --genco for HCC generates fat binaries with different triple strings.
// It will reach here and return a null pointer. The fat binary itself will
// be handled in a different place.
tprintf(DB_FB, "No hip-clang device code bundle for %s\n", agent_name);
return nullptr;
}
+58
Просмотреть файл
@@ -0,0 +1,58 @@
/*
Copyright (c) 2018 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef HIP_SRC_HIP_FATBIN_H
#define HIP_SRC_HIP_FATBIN_H
#include "hip/hip_runtime.h"
#include "hip_hcc_internal.h"
// hip-clang fatbin format
constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF"
#define CLANG_OFFLOAD_BUNDLER_MAGIC "__CLANG_OFFLOAD_BUNDLE__"
#define AMDGCN_AMDHSA_TRIPLE "hip-amdgcn-amd-amdhsa"
struct __ClangOffloadBundleDesc {
uint64_t offset;
uint64_t size;
uint64_t tripleSize;
const char triple[1];
};
struct __ClangOffloadBundleHeader {
const char magic[sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC) - 1];
uint64_t numBundles;
__ClangOffloadBundleDesc desc[1];
};
struct __CudaFatBinaryWrapper {
unsigned int magic;
unsigned int version;
__ClangOffloadBundleHeader* binary;
void* unused;
};
const void* __hipExtractCodeObjectFromFatBinary(const void* data,
const char* agent_name);
void __hipDumpCodeObject(const std::string& image);
#endif // HIP_SRC_HIP_FATBIN_H
+7 -6
Просмотреть файл
@@ -179,7 +179,7 @@ uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr) {
if (COMPILE_HIP_DB && HIP_TRACE_API) {
fprintf(stderr, "%s<<hip-api tid:%s @%lu%s\n", API_COLOR, fullStr->c_str(), apiStartTick,
fprintf(stderr, "%s<<hip-api pid:%d tid:%s @%lu%s\n", API_COLOR, tls_tidInfo.pid(), fullStr->c_str(), apiStartTick,
API_COLOR_END);
}
@@ -237,6 +237,7 @@ hipError_t ihipSynchronize(void) {
//=================================================================================================
TidInfo::TidInfo() : _apiSeqNum(0) {
_shortTid = g_lastShortTid.fetch_add(1);
_pid = getpid();
if (COMPILE_HIP_DB && HIP_TRACE_API) {
std::stringstream tid_ss;
@@ -1535,7 +1536,7 @@ void ihipPrintKernelLaunch(const char* kernelName, const grid_launch_parm* lp,
if ((HIP_TRACE_API & (1 << TRACE_KCMD)) || HIP_PROFILE_API ||
(COMPILE_HIP_DB & HIP_TRACE_API)) {
std::stringstream os;
os << tls_tidInfo.tid() << "." << tls_tidInfo.apiSeqNum() << " hipLaunchKernel '"
os << tls_tidInfo.pid() << " " << tls_tidInfo.tid() << "." << tls_tidInfo.apiSeqNum() << " hipLaunchKernel '"
<< kernelName << "'"
<< " gridDim:" << lp->grid_dim << " groupDim:" << lp->group_dim << " sharedMem:+"
<< lp->dynamic_group_mem_bytes << " " << *stream;
@@ -2288,7 +2289,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes
//-------------------------------------------------------------------------------------------------
// Profiler, really these should live elsewhere:
hipError_t hipProfilerStart() {
HIP_INIT_API();
HIP_INIT_API(hipProfilerStart);
#if COMPILE_HIP_ATP_MARKER
amdtResumeProfiling(AMDT_ALL_PROFILING);
#endif
@@ -2298,7 +2299,7 @@ hipError_t hipProfilerStart() {
hipError_t hipProfilerStop() {
HIP_INIT_API();
HIP_INIT_API(hipProfilerStop);
#if COMPILE_HIP_ATP_MARKER
amdtStopProfiling(AMDT_ALL_PROFILING);
#endif
@@ -2313,7 +2314,7 @@ hipError_t hipProfilerStop() {
//---
hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator* acc) {
HIP_INIT_API(deviceId, acc);
HIP_INIT_API(hipHccGetAccelerator, deviceId, acc);
const ihipDevice_t* device = ihipGetDevice(deviceId);
hipError_t err;
@@ -2329,7 +2330,7 @@ hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator* acc) {
//---
hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view** av) {
HIP_INIT_API(stream, av);
HIP_INIT_API(hipHccGetAcceleratorView, stream, av);
if (stream == hipStreamNull) {
ihipCtx_t* device = ihipGetTlsDefaultCtx();
+32 -28
Просмотреть файл
@@ -94,11 +94,13 @@ class TidInfo {
TidInfo();
int tid() const { return _shortTid; };
pid_t pid() const { return _pid; };
uint64_t incApiSeqNum() { return ++_apiSeqNum; };
uint64_t apiSeqNum() const { return _apiSeqNum; };
private:
int _shortTid;
pid_t _pid;
// monotonically increasing API sequence number for this threa.
uint64_t _apiSeqNum;
@@ -243,14 +245,14 @@ static const DbName dbName[] = {
#if COMPILE_HIP_DB
#define tprintf(trace_level, ...) \
{ \
if (HIP_DB & (1 << (trace_level))) { \
char msgStr[1000]; \
snprintf(msgStr, sizeof(msgStr), __VA_ARGS__); \
fprintf(stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, \
dbName[trace_level]._shortName, tls_tidInfo.tid(), msgStr, KNRM); \
} \
#define tprintf(trace_level, ...) \
{ \
if (HIP_DB & (1 << (trace_level))) { \
char msgStr[1000]; \
snprintf(msgStr, sizeof(msgStr), __VA_ARGS__); \
fprintf(stderr, " %ship-%s pid:%d tid:%d:%s%s", dbName[trace_level]._color, \
dbName[trace_level]._shortName, tls_tidInfo.pid(), tls_tidInfo.tid(), msgStr, KNRM); \
} \
}
#else
/* Compile to empty code */
@@ -297,38 +299,40 @@ extern uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr);
// This macro should be called at the beginning of every HIP API.
// It initializes the hip runtime (exactly once), and
// generates a trace string that can be output to stderr or to ATP file.
#define HIP_INIT_API(...) \
#define HIP_INIT_API(cid, ...) \
HIP_INIT() \
API_TRACE(0, __VA_ARGS__);
API_TRACE(0, __VA_ARGS__); \
HIP_CB_SPAWNER_OBJECT(cid);
// Like above, but will trace with a specified "special" bit.
// Replace HIP_INIT_API with this call inside HIP APIs that launch work on the GPU:
// kernel launches, copy commands, memory sets, etc.
#define HIP_INIT_SPECIAL_API(tbit, ...) \
#define HIP_INIT_SPECIAL_API(cid, tbit, ...) \
HIP_INIT() \
API_TRACE((HIP_TRACE_API & (1 << tbit)), __VA_ARGS__);
API_TRACE((HIP_TRACE_API & (1 << tbit)), __VA_ARGS__); \
HIP_CB_SPAWNER_OBJECT(cid);
// This macro should be called at the end of every HIP API, and only at the end of top-level hip
// APIS (not internal hip) It has dual function: logs the last error returned for use by
// hipGetLastError, and also prints the closing message when the debug trace is enabled.
#define ihipLogStatus(hipStatus) \
({ \
hipError_t localHipStatus = hipStatus; /*local copy so hipStatus only evaluated once*/ \
tls_lastHipError = localHipStatus; \
\
if ((COMPILE_HIP_TRACE_API & 0x2) && HIP_TRACE_API & (1 << TRACE_ALL)) { \
auto ticks = getTicks() - hipApiStartTick; \
fprintf(stderr, " %ship-api tid:%d.%lu %-30s ret=%2d (%s)>> +%lu ns%s\n", \
(localHipStatus == 0) ? API_COLOR : KRED, tls_tidInfo.tid(), \
tls_tidInfo.apiSeqNum(), __func__, localHipStatus, \
ihipErrorString(localHipStatus), ticks, API_COLOR_END); \
} \
if (HIP_PROFILE_API) { \
MARKER_END(); \
} \
localHipStatus; \
#define ihipLogStatus(hipStatus) \
({ \
hipError_t localHipStatus = hipStatus; /*local copy so hipStatus only evaluated once*/ \
tls_lastHipError = localHipStatus; \
\
if ((COMPILE_HIP_TRACE_API & 0x2) && HIP_TRACE_API & (1 << TRACE_ALL)) { \
auto ticks = getTicks() - hipApiStartTick; \
fprintf(stderr, " %ship-api pid:%d tid:%d.%lu %-30s ret=%2d (%s)>> +%lu ns%s\n", \
(localHipStatus == 0) ? API_COLOR : KRED, tls_tidInfo.pid(), tls_tidInfo.tid(), \
tls_tidInfo.apiSeqNum(), __func__, localHipStatus, \
ihipErrorString(localHipStatus), ticks, API_COLOR_END); \
} \
if (HIP_PROFILE_API) { \
MARKER_END(); \
} \
localHipStatus; \
})
+49
Просмотреть файл
@@ -0,0 +1,49 @@
/*
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "hip/hip_runtime.h"
#include "hip/hcc_detail/hip_prof_api.h"
// HIP API callback/activity
api_callbacks_table_t callbacks_table;
extern std::string& FunctionSymbol(hipFunction_t f);
const char* hipKernelNameRef(const hipFunction_t f) { return FunctionSymbol(f).c_str(); }
hipError_t hipRegisterApiCallback(uint32_t id, void* fun, void* arg) {
return callbacks_table.set_callback(id, reinterpret_cast<api_callbacks_table_t::fun_t>(fun), arg) ?
hipSuccess : hipErrorInvalidValue;
}
hipError_t hipRemoveApiCallback(uint32_t id) {
return callbacks_table.set_callback(id, NULL, NULL) ? hipSuccess : hipErrorInvalidValue;
}
hipError_t hipRegisterActivityCallback(uint32_t id, void* fun, void* arg) {
return callbacks_table.set_activity(id, reinterpret_cast<api_callbacks_table_t::act_t>(fun), arg) ?
hipSuccess : hipErrorInvalidValue;
}
hipError_t hipRemoveActivityCallback(uint32_t id) {
return callbacks_table.set_activity(id, NULL, NULL) ? hipSuccess : hipErrorInvalidValue;
}
+90 -66
Просмотреть файл
@@ -159,7 +159,7 @@ void* allocAndSharePtr(const char* msg, size_t sizeBytes, ihipCtx_t* ctx, bool s
// TODO - add more info here when available.
//
hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) {
HIP_INIT_API(attributes, ptr);
HIP_INIT_API(hipPointerGetAttributes, attributes, ptr);
hipError_t e = hipSuccess;
if ((attributes == nullptr) || (ptr == nullptr)) {
@@ -206,7 +206,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void
hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsigned flags) {
HIP_INIT_API(devicePointer, hostPointer, flags);
HIP_INIT_API(hipHostGetDevicePointer, devicePointer, hostPointer, flags);
hipError_t e = hipSuccess;
@@ -237,7 +237,7 @@ hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsi
hipError_t hipMalloc(void** ptr, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MEM), ptr, sizeBytes);
HIP_INIT_SPECIAL_API(hipMalloc, (TRACE_MEM), ptr, sizeBytes);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
@@ -266,7 +266,7 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) {
hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) {
HIP_INIT_SPECIAL_API((TRACE_MEM), ptr, sizeBytes, flags);
HIP_INIT_SPECIAL_API(hipHostMalloc, (TRACE_MEM), ptr, sizeBytes, flags);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
@@ -398,7 +398,7 @@ hipError_t ihipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t heigh
// width in bytes
hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) {
HIP_INIT_SPECIAL_API((TRACE_MEM), ptr, pitch, width, height);
HIP_INIT_SPECIAL_API(hipMallocPitch, (TRACE_MEM), ptr, pitch, width, height);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
@@ -409,7 +409,7 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height
}
hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent) {
HIP_INIT_API(pitchedDevPtr, &extent);
HIP_INIT_API(hipMalloc3D, pitchedDevPtr, &extent);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
@@ -444,7 +444,7 @@ extern void getChannelOrderAndType(const hipChannelFormatDesc& desc,
hsa_ext_image_channel_type_t* channelType);
hipError_t hipArrayCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) {
HIP_INIT_SPECIAL_API((TRACE_MEM), array, pAllocateArray);
HIP_INIT_SPECIAL_API(hipArrayCreate, (TRACE_MEM), array, pAllocateArray);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
if (pAllocateArray->width > 0) {
@@ -554,7 +554,7 @@ hipError_t hipArrayCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocat
hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width,
size_t height, unsigned int flags) {
HIP_INIT_SPECIAL_API((TRACE_MEM), array, desc, width, height, flags);
HIP_INIT_SPECIAL_API(hipMallocArray, (TRACE_MEM), array, desc, width, height, flags);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
if (width > 0) {
@@ -635,7 +635,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, si
}
hipError_t hipArray3DCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) {
HIP_INIT_SPECIAL_API((TRACE_MEM), array, pAllocateArray);
HIP_INIT_SPECIAL_API(hipArray3DCreate, (TRACE_MEM), array, pAllocateArray);
hipError_t hip_status = hipSuccess;
auto ctx = ihipGetTlsDefaultCtx();
@@ -762,7 +762,7 @@ hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc*
HIP_INIT_API(array, desc, &extent, flags);
HIP_INIT_API(hipMalloc3DArray, array, desc, &extent, flags);
HIP_SET_DEVICE();
hipError_t hip_status = hipSuccess;
@@ -846,7 +846,7 @@ hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc*
}
hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) {
HIP_INIT_API(flagsPtr, hostPtr);
HIP_INIT_API(hipHostGetFlags, flagsPtr, hostPtr);
hipError_t hip_status = hipSuccess;
@@ -874,7 +874,7 @@ hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) {
// TODO - need to fix several issues here related to P2P access, host memory fallback.
hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) {
HIP_INIT_API(hostPtr, sizeBytes, flags);
HIP_INIT_API(hipHostRegister, hostPtr, sizeBytes, flags);
hipError_t hip_status = hipSuccess;
@@ -909,14 +909,22 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags)
}
am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0],
vecAcc.size());
#if USE_APP_PTR_FOR_CTX
hc::am_memtracker_update(hostPtr, device->_deviceId, flags, ctx);
#else
hc::am_memtracker_update(hostPtr, device->_deviceId, flags);
#endif
if ( am_status == AM_SUCCESS ) {
am_status = hc::am_memtracker_getinfo(&amPointerInfo, hostPtr);
tprintf(DB_MEM, " %s registered ptr=%p and allowed access to %zu peers\n", __func__,
hostPtr, vecAcc.size());
if ( am_status == AM_SUCCESS ) {
void *devPtr = amPointerInfo._devicePointer;
#if USE_APP_PTR_FOR_CTX
hc::am_memtracker_update(hostPtr, device->_deviceId, flags, ctx);
hc::am_memtracker_update(devPtr, device->_deviceId, flags, ctx);
#else
hc::am_memtracker_update(hostPtr, device->_deviceId, flags);
hc::am_memtracker_update(devPtr, device->_deviceId, flags);
#endif
tprintf(DB_MEM, " %s registered ptr=%p and allowed access to %zu peers\n", __func__,
hostPtr, vecAcc.size());
};
};
if (am_status == AM_SUCCESS) {
hip_status = hipSuccess;
} else {
@@ -931,7 +939,7 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags)
}
hipError_t hipHostUnregister(void* hostPtr) {
HIP_INIT_API(hostPtr);
HIP_INIT_API(hipHostUnregister, hostPtr);
auto ctx = ihipGetTlsDefaultCtx();
hipError_t hip_status = hipSuccess;
if (hostPtr == NULL) {
@@ -953,7 +961,7 @@ inline hipDeviceptr_t agent_address_for_symbol(const char* symbolName) {
#if __hcc_workweek__ >= 17481
size_t byte_cnt = 0u;
hipModuleGetGlobal(&r, &byte_cnt, 0, symbolName);
ihipModuleGetGlobal(&r, &byte_cnt, 0, symbolName);
#else
auto ctx = ihipGetTlsDefaultCtx();
auto acc = ctx->getDevice()->_acc;
@@ -966,7 +974,7 @@ inline hipDeviceptr_t agent_address_for_symbol(const char* symbolName) {
hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t count, size_t offset,
hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, src, count, offset, kind);
HIP_INIT_SPECIAL_API(hipMemcpyToSymbol, (TRACE_MCMD), symbolName, src, count, offset, kind);
if (symbolName == nullptr) {
return ihipLogStatus(hipErrorInvalidSymbol);
@@ -985,10 +993,9 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t cou
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
if (kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost ||
if (kind == hipMemcpyHostToDevice || kind == hipMemcpyDefault ||
kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) {
stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind);
// acc.memcpy_symbol(dst, (void*)src, count+offset);
stream->locked_copySync((char*)dst+offset, (void*)src, count, kind, false);
} else {
return ihipLogStatus(hipErrorInvalidValue);
}
@@ -999,7 +1006,7 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t cou
hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, size_t offset,
hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, dst, count, offset, kind);
HIP_INIT_SPECIAL_API(hipMemcpyFromSymbol, (TRACE_MCMD), symbolName, dst, count, offset, kind);
if (symbolName == nullptr) {
return ihipLogStatus(hipErrorInvalidSymbol);
@@ -1018,9 +1025,9 @@ hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count,
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
if (kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost ||
if (kind == hipMemcpyDefault || kind == hipMemcpyDeviceToHost ||
kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) {
stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind);
stream->locked_copySync((void*)dst, (char*)src+offset, count, kind, false);
} else {
return ihipLogStatus(hipErrorInvalidValue);
}
@@ -1031,7 +1038,7 @@ hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count,
hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_t count,
size_t offset, hipMemcpyKind kind, hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, src, count, offset, kind, stream);
HIP_INIT_SPECIAL_API(hipMemcpyToSymbolAsync, (TRACE_MCMD), symbolName, src, count, offset, kind, stream);
if (symbolName == nullptr) {
return ihipLogStatus(hipErrorInvalidSymbol);
@@ -1052,7 +1059,7 @@ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_
if (stream) {
try {
stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count, offset, kind);
hip_internal::memcpyAsync((char*)dst+offset, src, count, kind, stream);
} catch (ihipException& ex) {
e = ex._code;
}
@@ -1066,7 +1073,7 @@ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_
hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t count, size_t offset,
hipMemcpyKind kind, hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, dst, count, offset, kind, stream);
HIP_INIT_SPECIAL_API(hipMemcpyFromSymbolAsync, (TRACE_MCMD), symbolName, dst, count, offset, kind, stream);
if (symbolName == nullptr) {
return ihipLogStatus(hipErrorInvalidSymbol);
@@ -1088,7 +1095,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co
stream = ihipSyncAndResolveStream(stream);
if (stream) {
try {
stream->lockedSymbolCopyAsync(acc, dst, src, count, offset, kind);
hip_internal::memcpyAsync(dst, (char*)src+offset, count, kind, stream);
} catch (ihipException& ex) {
e = ex._code;
}
@@ -1099,9 +1106,26 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co
return ihipLogStatus(e);
}
hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) {
HIP_INIT_API(devPtr, symbolName);
size_t size = 0;
return ihipModuleGetGlobal(devPtr, &size, 0, static_cast<const char*>(symbolName));
}
hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) {
HIP_INIT_API(size, symbolName);
void* devPtr = nullptr;
return ihipModuleGetGlobal(&devPtr, size, 0, static_cast<const char*>(symbolName));
}
//---
hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, kind);
HIP_INIT_SPECIAL_API(hipMemcpy, (TRACE_MCMD), dst, src, sizeBytes, kind);
hipError_t e = hipSuccess;
@@ -1128,7 +1152,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind
hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes);
HIP_INIT_SPECIAL_API(hipMemcpyHtoD, (TRACE_MCMD), dst, src, sizeBytes);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1147,7 +1171,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) {
hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes);
HIP_INIT_SPECIAL_API(hipMemcpyDtoH, (TRACE_MCMD), dst, src, sizeBytes);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1166,7 +1190,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) {
hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes);
HIP_INIT_SPECIAL_API(hipMemcpyDtoD, (TRACE_MCMD), dst, src, sizeBytes);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1184,7 +1208,7 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte
}
hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes);
HIP_INIT_SPECIAL_API(hipMemcpyHtoH, (TRACE_MCMD), dst, src, sizeBytes);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1203,13 +1227,13 @@ hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) {
hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind,
hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, kind, stream);
HIP_INIT_SPECIAL_API(hipMemcpyAsync, (TRACE_MCMD), dst, src, sizeBytes, kind, stream);
return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, kind, stream));
}
hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, stream);
HIP_INIT_SPECIAL_API(hipMemcpyHtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream);
return ihipLogStatus(
hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyHostToDevice, stream));
@@ -1217,14 +1241,14 @@ hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, h
hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes,
hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, stream);
HIP_INIT_SPECIAL_API(hipMemcpyDtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream);
return ihipLogStatus(
hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToDevice, stream));
}
hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, stream);
HIP_INIT_SPECIAL_API(hipMemcpyDtoHAsync, (TRACE_MCMD), dst, src, sizeBytes, stream);
return ihipLogStatus(
hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToHost, stream));
@@ -1232,7 +1256,7 @@ hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, h
hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src,
size_t spitch, size_t width, size_t height, hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, wOffset, hOffset, src, spitch, width, height, kind);
HIP_INIT_SPECIAL_API(hipMemcpy2DToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, spitch, width, height, kind);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1284,7 +1308,7 @@ hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, con
hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src,
size_t count, hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, wOffset, hOffset, src, count, kind);
HIP_INIT_SPECIAL_API(hipMemcpyToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, count, kind);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1303,7 +1327,7 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const
hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset,
size_t count, hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, srcArray, wOffset, hOffset, count, kind);
HIP_INIT_SPECIAL_API(hipMemcpyFromArray, (TRACE_MCMD), dst, srcArray, wOffset, hOffset, count, kind);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1321,7 +1345,7 @@ hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffs
}
hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHost, size_t count) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dstArray, dstOffset, srcHost, count);
HIP_INIT_SPECIAL_API(hipMemcpyHtoA, (TRACE_MCMD), dstArray, dstOffset, srcHost, count);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1339,7 +1363,7 @@ hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHo
}
hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t count) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, srcArray, srcOffset, count);
HIP_INIT_SPECIAL_API(hipMemcpyAtoH, (TRACE_MCMD), dst, srcArray, srcOffset, count);
hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull);
@@ -1358,7 +1382,7 @@ hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t
}
hipError_t hipMemcpy3D(const struct hipMemcpy3DParms* p) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), p);
HIP_INIT_SPECIAL_API(hipMemcpy3D, (TRACE_MCMD), p);
hipError_t e = hipSuccess;
if (p) {
size_t byteSize;
@@ -1626,7 +1650,7 @@ hipError_t ihipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch
hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width,
size_t height, hipMemcpyKind kind) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind);
HIP_INIT_SPECIAL_API(hipMemcpy2D, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind);
hipError_t e = hipSuccess;
e = ihipMemcpy2D(dst, dpitch, src, spitch, width, height, kind);
return ihipLogStatus(e);
@@ -1634,7 +1658,7 @@ hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch,
hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width,
size_t height, hipMemcpyKind kind, hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind, stream);
HIP_INIT_SPECIAL_API(hipMemcpy2DAsync, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind, stream);
if (dst == nullptr || src == nullptr || width > dpitch || width > spitch) return ihipLogStatus(hipErrorInvalidValue);
hipError_t e = hipSuccess;
int isLocked = 0;
@@ -1673,7 +1697,7 @@ hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t sp
}
hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), pCopy);
HIP_INIT_SPECIAL_API(hipMemcpyParam2D, (TRACE_MCMD), pCopy);
hipError_t e = hipSuccess;
if (pCopy == nullptr) {
e = hipErrorInvalidValue;
@@ -1685,7 +1709,7 @@ hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) {
// TODO-sync: function is async unless target is pinned host memory - then these are fully sync.
hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, value, sizeBytes, stream);
HIP_INIT_SPECIAL_API(hipMemsetAsync, (TRACE_MCMD), dst, value, sizeBytes, stream);
hipError_t e = hipSuccess;
@@ -1697,7 +1721,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st
};
hipError_t hipMemset(void* dst, int value, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, value, sizeBytes);
HIP_INIT_SPECIAL_API(hipMemset, (TRACE_MCMD), dst, value, sizeBytes);
hipError_t e = hipSuccess;
@@ -1713,7 +1737,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes) {
}
hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, pitch, value, width, height);
HIP_INIT_SPECIAL_API(hipMemset2D, (TRACE_MCMD), dst, pitch, value, width, height);
hipError_t e = hipSuccess;
@@ -1732,7 +1756,7 @@ hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t
hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream )
{
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, pitch, value, width, height, stream);
HIP_INIT_SPECIAL_API(hipMemset2DAsync, (TRACE_MCMD), dst, pitch, value, width, height, stream);
hipError_t e = hipSuccess;
@@ -1749,7 +1773,7 @@ hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, si
};
hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes) {
HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, value, sizeBytes);
HIP_INIT_SPECIAL_API(hipMemsetD8, (TRACE_MCMD), dst, value, sizeBytes);
hipError_t e = hipSuccess;
@@ -1766,7 +1790,7 @@ hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes
hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent )
{
HIP_INIT_SPECIAL_API((TRACE_MCMD), &pitchedDevPtr, value, &extent);
HIP_INIT_SPECIAL_API(hipMemset3D, (TRACE_MCMD), &pitchedDevPtr, value, &extent);
hipError_t e = hipSuccess;
hipStream_t stream = hipStreamNull;
@@ -1785,7 +1809,7 @@ hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent
hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent ,hipStream_t stream )
{
HIP_INIT_SPECIAL_API((TRACE_MCMD), &pitchedDevPtr, value, &extent);
HIP_INIT_SPECIAL_API(hipMemset3DAsync, (TRACE_MCMD), &pitchedDevPtr, value, &extent);
hipError_t e = hipSuccess;
// TODO - call an ihip memset so HIP_TRACE is correct.
@@ -1801,7 +1825,7 @@ hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent e
}
hipError_t hipMemGetInfo(size_t* free, size_t* total) {
HIP_INIT_API(free, total);
HIP_INIT_API(hipMemGetInfo, free, total);
hipError_t e = hipSuccess;
@@ -1835,7 +1859,7 @@ hipError_t hipMemGetInfo(size_t* free, size_t* total) {
}
hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) {
HIP_INIT_API(ptr, size);
HIP_INIT_API(hipMemPtrGetInfo, ptr, size);
hipError_t e = hipSuccess;
@@ -1860,7 +1884,7 @@ hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) {
hipError_t hipFree(void* ptr) {
HIP_INIT_SPECIAL_API((TRACE_MEM), ptr);
HIP_INIT_SPECIAL_API(hipFree, (TRACE_MEM), ptr);
hipError_t hipStatus = hipErrorInvalidDevicePointer;
@@ -1892,7 +1916,7 @@ hipError_t hipFree(void* ptr) {
hipError_t hipHostFree(void* ptr) {
HIP_INIT_SPECIAL_API((TRACE_MEM), ptr);
HIP_INIT_SPECIAL_API(hipHostFree, (TRACE_MEM), ptr);
// Synchronize to ensure all work has finished.
ihipGetTlsDefaultCtx()->locked_waitAllStreams(); // ignores non-blocking streams, this waits
@@ -1927,7 +1951,7 @@ hipError_t hipHostFree(void* ptr) {
hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); }
hipError_t hipFreeArray(hipArray* array) {
HIP_INIT_SPECIAL_API((TRACE_MEM), array);
HIP_INIT_SPECIAL_API(hipFreeArray, (TRACE_MEM), array);
hipError_t hipStatus = hipErrorInvalidDevicePointer;
@@ -1955,7 +1979,7 @@ hipError_t hipFreeArray(hipArray* array) {
}
hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr) {
HIP_INIT_API(pbase, psize, dptr);
HIP_INIT_API(hipMemGetAddressRange, pbase, psize, dptr);
hipError_t hipStatus = hipSuccess;
hc::accelerator acc;
#if (__hcc_workweek__ >= 17332)
@@ -1976,7 +2000,7 @@ hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDevice
// TODO: IPC implementaiton:
hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) {
HIP_INIT_API(handle, devPtr);
HIP_INIT_API(hipIpcGetMemHandle, handle, devPtr);
hipError_t hipStatus = hipSuccess;
// Get the size of allocated pointer
size_t psize = 0u;
@@ -2012,7 +2036,7 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) {
}
hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags) {
HIP_INIT_API(devPtr, &handle, flags);
HIP_INIT_API(hipIpcOpenMemHandle, devPtr, &handle, flags);
hipError_t hipStatus = hipSuccess;
if (devPtr == NULL) {
hipStatus = hipErrorInvalidValue;
@@ -2042,7 +2066,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned
}
hipError_t hipIpcCloseMemHandle(void* devPtr) {
HIP_INIT_API(devPtr);
HIP_INIT_API(hipIpcCloseMemHandle, devPtr);
hipError_t hipStatus = hipSuccess;
if (devPtr == NULL) {
hipStatus = hipErrorInvalidValue;
+34 -17
Просмотреть файл
@@ -48,6 +48,7 @@ THE SOFTWARE.
#include <utility>
#include <vector>
#include "../include/hip/hcc_detail/code_object_bundle.hpp"
#include "hip_fatbin.h"
// TODO Use Pool APIs from HCC to get memory regions.
using namespace ELFIO;
@@ -84,6 +85,7 @@ string ToString(hipFunction_t v) {
return ss.str();
};
std::string& FunctionSymbol(hipFunction_t f) { return f->_name; };
#define CHECK_HSA(hsaStatus, hipStatus) \
if (hsaStatus != HSA_STATUS_SUCCESS) { \
@@ -96,7 +98,7 @@ string ToString(hipFunction_t v) {
}
hipError_t hipModuleUnload(hipModule_t hmod) {
HIP_INIT_API(hmod);
HIP_INIT_API(hipModuleUnload, hmod);
// TODO - improve this synchronization so it is thread-safe.
// Currently we want for all inflight activity to complete, but don't prevent another
@@ -230,7 +232,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, uint32_t gridDimX, uint32_t gr
uint32_t gridDimZ, uint32_t blockDimX, uint32_t blockDimY,
uint32_t blockDimZ, uint32_t sharedMemBytes, hipStream_t hStream,
void** kernelParams, void** extra) {
HIP_INIT_API(f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes,
HIP_INIT_API(hipModuleLaunchKernel, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes,
hStream, kernelParams, extra);
return ihipLogStatus(ihipModuleLaunchKernel(
f, blockDimX * gridDimX, blockDimY * gridDimY, gridDimZ * blockDimZ, blockDimX, blockDimY,
@@ -244,7 +246,7 @@ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,
uint32_t localWorkSizeZ, size_t sharedMemBytes,
hipStream_t hStream, void** kernelParams, void** extra,
hipEvent_t startEvent, hipEvent_t stopEvent) {
HIP_INIT_API(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX,
HIP_INIT_API(hipHccModuleLaunchKernel, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX,
localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra);
return ihipLogStatus(ihipModuleLaunchKernel(
f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY,
@@ -258,12 +260,16 @@ struct Agent_global {
uint32_t byte_cnt;
};
inline void track(const Agent_global& x) {
inline void track(const Agent_global& x, hsa_agent_t agent) {
tprintf(DB_MEM, " add variable '%s' with ptr=%p size=%u to tracker\n", x.name.c_str(),
x.address, x.byte_cnt);
auto device = ihipGetTlsDefaultCtx()->getWriteableDevice();
int deviceIndex =0;
for ( deviceIndex = 0; deviceIndex < g_deviceCnt; deviceIndex++) {
if(g_allAgents[deviceIndex] == agent)
break;
}
auto device = ihipGetDevice(deviceIndex - 1);
hc::AmPointerInfo ptr_info(nullptr, x.address, x.address, x.byte_cnt, device->_acc, true,
false);
hc::am_memtracker_add(x.address, ptr_info);
@@ -276,7 +282,7 @@ inline void track(const Agent_global& x) {
}
template <typename Container = vector<Agent_global>>
inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t,
inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t agent,
hsa_executable_symbol_t x, void* out) {
assert(out);
@@ -286,7 +292,7 @@ inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t,
if (t == HSA_SYMBOL_KIND_VARIABLE) {
static_cast<Container*>(out)->push_back(Agent_global{name(x), address(x), size(x)});
track(static_cast<Container*>(out)->back());
track(static_cast<Container*>(out)->back(),agent);
}
return HSA_STATUS_SUCCESS;
@@ -460,22 +466,27 @@ hipError_t ihipModuleGetFunction(hipFunction_t* func, hipModule_t hmod, const ch
}
hipError_t hipModuleGetFunction(hipFunction_t* hfunc, hipModule_t hmod, const char* name) {
HIP_INIT_API(hfunc, hmod, name);
HIP_INIT_API(hipModuleGetFunction, hfunc, hmod, name);
return ihipLogStatus(ihipModuleGetFunction(hfunc, hmod, name));
}
hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name) {
HIP_INIT_API(dptr, bytes, hmod, name);
HIP_INIT_API(hipModuleGetGlobal, dptr, bytes, hmod, name);
if (!dptr || !bytes) return ihipLogStatus(hipErrorInvalidValue);
return ihipLogStatus(ihipModuleGetGlobal(dptr, bytes, hmod, name));
}
if (!name) return ihipLogStatus(hipErrorNotInitialized);
hipError_t ihipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name) {
if (!dptr || !bytes) return hipErrorInvalidValue;
if (!name) return hipErrorNotInitialized;
const auto r = hmod ? read_agent_global_from_module(dptr, bytes, hmod, name)
: read_agent_global_from_process(dptr, bytes, name);
return ihipLogStatus(r);
return r;
}
namespace
@@ -546,6 +557,12 @@ hipError_t ihipModuleLoadData(hipModule_t* module, const void* image) {
auto ctx = ihipGetTlsDefaultCtx();
if (!ctx) return hipErrorInvalidContext;
// try extracting code object from image as fatbin.
char name[64] = {};
hsa_agent_get_info(this_agent(), HSA_AGENT_INFO_NAME, name);
if (auto *code_obj = __hipExtractCodeObjectFromFatBinary(image, name))
image = code_obj;
hsa_executable_create_alt(HSA_PROFILE_FULL, HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT, nullptr,
&(*module)->executable);
@@ -558,12 +575,12 @@ hipError_t ihipModuleLoadData(hipModule_t* module, const void* image) {
}
hipError_t hipModuleLoadData(hipModule_t* module, const void* image) {
HIP_INIT_API(module, image);
HIP_INIT_API(hipModuleLoadData, module, image);
return ihipLogStatus(ihipModuleLoadData(module,image));
}
hipError_t hipModuleLoad(hipModule_t* module, const char* fname) {
HIP_INIT_API(module, fname);
HIP_INIT_API(hipModuleLoad, module, fname);
if (!fname) return ihipLogStatus(hipErrorInvalidValue);
@@ -578,12 +595,12 @@ hipError_t hipModuleLoad(hipModule_t* module, const char* fname) {
hipError_t hipModuleLoadDataEx(hipModule_t* module, const void* image, unsigned int numOptions,
hipJitOption* options, void** optionValues) {
HIP_INIT_API(module, image, numOptions, options, optionValues);
HIP_INIT_API(hipModuleLoadDataEx, module, image, numOptions, options, optionValues);
return ihipLogStatus(ihipModuleLoadData(module, image));
}
hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name) {
HIP_INIT_API(texRef, hmod, name);
HIP_INIT_API(hipModuleGetTexRef, texRef, hmod, name);
hipError_t ret = hipErrorNotFound;
if (!texRef) return ihipLogStatus(hipErrorInvalidValue);
+10 -10
Просмотреть файл
@@ -73,7 +73,7 @@ hipError_t ihipDeviceCanAccessPeer(int* canAccessPeer, hipCtx_t thisCtx, hipCtx_
*/
//---
hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, hipCtx_t thisCtx, hipCtx_t peerCtx) {
HIP_INIT_API(canAccessPeer, thisCtx, peerCtx);
HIP_INIT_API(hipDeviceCanAccessPeer2, canAccessPeer, thisCtx, peerCtx);
return ihipLogStatus(ihipDeviceCanAccessPeer(canAccessPeer, thisCtx, peerCtx));
}
@@ -150,7 +150,7 @@ hipError_t ihipEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) {
//---
hipError_t hipMemcpyPeer(void* dst, hipCtx_t dstCtx, const void* src, hipCtx_t srcCtx,
size_t sizeBytes) {
HIP_INIT_API(dst, dstCtx, src, srcCtx, sizeBytes);
HIP_INIT_API(hipMemcpyPeer2, dst, dstCtx, src, srcCtx, sizeBytes);
// TODO - move to ihip memory copy implementaion.
// HCC has a unified memory architecture so device specifiers are not required.
@@ -161,7 +161,7 @@ hipError_t hipMemcpyPeer(void* dst, hipCtx_t dstCtx, const void* src, hipCtx_t s
//---
hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hipCtx_t srcDevice,
size_t sizeBytes, hipStream_t stream) {
HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream);
HIP_INIT_API(hipMemcpyPeerAsync2, dst, dstDevice, src, srcDevice, sizeBytes, stream);
// TODO - move to ihip memory copy implementaion.
// HCC has a unified memory architecture so device specifiers are not required.
@@ -175,21 +175,21 @@ hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hi
//=============================================================================
hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId) {
HIP_INIT_API(canAccessPeer, deviceId, peerDeviceId);
HIP_INIT_API(hipDeviceCanAccessPeer, canAccessPeer, deviceId, peerDeviceId);
return ihipLogStatus(ihipDeviceCanAccessPeer(canAccessPeer, ihipGetPrimaryCtx(deviceId),
ihipGetPrimaryCtx(peerDeviceId)));
}
hipError_t hipDeviceDisablePeerAccess(int peerDeviceId) {
HIP_INIT_API(peerDeviceId);
HIP_INIT_API(hipDeviceDisablePeerAccess, peerDeviceId);
return ihipLogStatus(ihipDisablePeerAccess(ihipGetPrimaryCtx(peerDeviceId)));
}
hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) {
HIP_INIT_API(peerDeviceId, flags);
HIP_INIT_API(hipDeviceEnablePeerAccess, peerDeviceId, flags);
return ihipLogStatus(ihipEnablePeerAccess(ihipGetPrimaryCtx(peerDeviceId), flags));
}
@@ -197,7 +197,7 @@ hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) {
hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevice,
size_t sizeBytes) {
HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes);
HIP_INIT_API(hipMemcpyPeer, dst, dstDevice, src, srcDevice, sizeBytes);
return ihipLogStatus(hipMemcpyPeer(dst, ihipGetPrimaryCtx(dstDevice), src,
ihipGetPrimaryCtx(srcDevice), sizeBytes));
}
@@ -205,18 +205,18 @@ hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevic
hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice,
size_t sizeBytes, hipStream_t stream) {
HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream);
HIP_INIT_API(hipMemcpyPeerAsync, dst, dstDevice, src, srcDevice, sizeBytes, stream);
return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDefault, stream));
}
hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) {
HIP_INIT_API(peerCtx, flags);
HIP_INIT_API(hipCtxEnablePeerAccess, peerCtx, flags);
return ihipLogStatus(ihipEnablePeerAccess(peerCtx, flags));
}
hipError_t hipCtxDisablePeerAccess(hipCtx_t peerCtx) {
HIP_INIT_API(peerCtx);
HIP_INIT_API(hipCtxDisablePeerAccess, peerCtx);
return ihipLogStatus(ihipDisablePeerAccess(peerCtx));
}
+11 -11
Просмотреть файл
@@ -90,21 +90,21 @@ hipError_t ihipStreamCreate(hipStream_t* stream, unsigned int flags, int priorit
//---
hipError_t hipStreamCreateWithFlags(hipStream_t* stream, unsigned int flags) {
HIP_INIT_API(stream, flags);
HIP_INIT_API(hipStreamCreateWithFlags, stream, flags);
return ihipLogStatus(ihipStreamCreate(stream, flags, priority_normal));
}
//---
hipError_t hipStreamCreate(hipStream_t* stream) {
HIP_INIT_API(stream);
HIP_INIT_API(hipStreamCreate, stream);
return ihipLogStatus(ihipStreamCreate(stream, hipStreamDefault, priority_normal));
}
//---
hipError_t hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags, int priority) {
HIP_INIT_API(stream, flags, priority);
HIP_INIT_API(hipStreamCreateWithPriority, stream, flags, priority);
// clamp priority to range [priority_high:priority_low]
priority = (priority < priority_high ? priority_high : (priority > priority_low ? priority_low : priority));
@@ -113,7 +113,7 @@ hipError_t hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags,
//---
hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPriority) {
HIP_INIT_API(leastPriority, greatestPriority);
HIP_INIT_API(hipDeviceGetStreamPriorityRange, leastPriority, greatestPriority);
if (leastPriority != NULL) *leastPriority = priority_low;
if (greatestPriority != NULL) *greatestPriority = priority_high;
@@ -121,7 +121,7 @@ hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPrio
}
hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags) {
HIP_INIT_SPECIAL_API(TRACE_SYNC, stream, event, flags);
HIP_INIT_SPECIAL_API(hipStreamWaitEvent, TRACE_SYNC, stream, event, flags);
hipError_t e = hipSuccess;
@@ -152,7 +152,7 @@ hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int
//---
hipError_t hipStreamQuery(hipStream_t stream) {
HIP_INIT_SPECIAL_API(TRACE_QUERY, stream);
HIP_INIT_SPECIAL_API(hipStreamQuery, TRACE_QUERY, stream);
// Use default stream if 0 specified:
if (stream == hipStreamNull) {
@@ -175,7 +175,7 @@ hipError_t hipStreamQuery(hipStream_t stream) {
//---
hipError_t hipStreamSynchronize(hipStream_t stream) {
HIP_INIT_SPECIAL_API(TRACE_SYNC, stream);
HIP_INIT_SPECIAL_API(hipStreamSynchronize, TRACE_SYNC, stream);
return ihipLogStatus(ihipStreamSynchronize(stream));
}
@@ -186,7 +186,7 @@ hipError_t hipStreamSynchronize(hipStream_t stream) {
* @return #hipSuccess, #hipErrorInvalidResourceHandle
*/
hipError_t hipStreamDestroy(hipStream_t stream) {
HIP_INIT_API(stream);
HIP_INIT_API(hipStreamDestroy, stream);
hipError_t e = hipSuccess;
@@ -214,7 +214,7 @@ hipError_t hipStreamDestroy(hipStream_t stream) {
//---
hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags) {
HIP_INIT_API(stream, flags);
HIP_INIT_API(hipStreamGetFlags, stream, flags);
if (flags == NULL) {
return ihipLogStatus(hipErrorInvalidValue);
@@ -229,7 +229,7 @@ hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags) {
//--
hipError_t hipStreamGetPriority(hipStream_t stream, int* priority) {
HIP_INIT_API(stream, priority);
HIP_INIT_API(hipStreamGetPriority, stream, priority);
if (priority == NULL) {
return ihipLogStatus(hipErrorInvalidValue);
@@ -250,7 +250,7 @@ hipError_t hipStreamGetPriority(hipStream_t stream, int* priority) {
//---
hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData,
unsigned int flags) {
HIP_INIT_API(stream, callback, userData, flags);
HIP_INIT_API(hipStreamAddCallback, stream, callback, userData, flags);
hipError_t e = hipSuccess;
// Create a thread in detached mode to handle callback
+2 -2
Просмотреть файл
@@ -41,7 +41,7 @@ void saveSurfaceInfo(const hipSurface* pSurface, const hipResourceDesc* pResDesc
// Surface Object APIs
hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject,
const hipResourceDesc* pResDesc) {
HIP_INIT_API(pSurfObject, pResDesc);
HIP_INIT_API(hipCreateSurfaceObject, pSurfObject, pResDesc);
hipError_t hip_status = hipSuccess;
auto ctx = ihipGetTlsDefaultCtx();
@@ -71,7 +71,7 @@ hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject,
}
hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) {
HIP_INIT_API(surfaceObject);
HIP_INIT_API(hipDestroySurfaceObject, surfaceObject);
hipError_t hip_status = hipSuccess;
+20 -20
Просмотреть файл
@@ -202,7 +202,7 @@ bool getHipTextureObject(hipTextureObject_t* pTexObject, hsa_ext_image_t& image,
hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResourceDesc* pResDesc,
const hipTextureDesc* pTexDesc,
const hipResourceViewDesc* pResViewDesc) {
HIP_INIT_API(pTexObject, pResDesc, pTexDesc, pResViewDesc);
HIP_INIT_API(hipCreateTextureObject, pTexObject, pResDesc, pTexDesc, pResViewDesc);
hipError_t hip_status = hipSuccess;
auto ctx = ihipGetTlsDefaultCtx();
@@ -311,7 +311,7 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResou
}
hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject) {
HIP_INIT_API(textureObject);
HIP_INIT_API(hipDestroyTextureObject, textureObject);
hipError_t hip_status = hipSuccess;
@@ -335,7 +335,7 @@ hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject) {
hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc,
hipTextureObject_t textureObject) {
HIP_INIT_API(pResDesc, textureObject);
HIP_INIT_API(hipGetTextureObjectResourceDesc, pResDesc, textureObject);
hipError_t hip_status = hipSuccess;
auto ctx = ihipGetTlsDefaultCtx();
@@ -350,7 +350,7 @@ hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc,
hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc,
hipTextureObject_t textureObject) {
HIP_INIT_API(pResViewDesc, textureObject);
HIP_INIT_API(hipGetTextureObjectResourceViewDesc, pResViewDesc, textureObject);
hipError_t hip_status = hipSuccess;
auto ctx = ihipGetTlsDefaultCtx();
@@ -366,7 +366,7 @@ hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc
hipError_t hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc,
hipTextureObject_t textureObject) {
HIP_INIT_API(pTexDesc, textureObject);
HIP_INIT_API(hipGetTextureObjectTextureDesc, pTexDesc, textureObject);
hipError_t hip_status = hipSuccess;
@@ -444,7 +444,7 @@ hipError_t ihipBindTextureImpl(int dim, enum hipTextureReadMode readMode, size_t
hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr,
const hipChannelFormatDesc* desc, size_t size) {
HIP_INIT_API(offset, tex, devPtr, desc, size);
HIP_INIT_API(hipBindTexture, offset, tex, devPtr, desc, size);
hipError_t hip_status = hipSuccess;
// TODO: hipReadModeElementType is default.
hip_status = ihipBindTextureImpl(hipTextureType1D, hipReadModeElementType, offset, devPtr, desc,
@@ -517,7 +517,7 @@ hipError_t ihipBindTexture2DImpl(int dim, enum hipTextureReadMode readMode, size
hipError_t hipBindTexture2D(size_t* offset, textureReference* tex, const void* devPtr,
const hipChannelFormatDesc* desc, size_t width, size_t height,
size_t pitch) {
HIP_INIT_API(offset, tex, devPtr, desc, width, height, pitch);
HIP_INIT_API(hipBindTexture2D, offset, tex, devPtr, desc, width, height, pitch);
hipError_t hip_status = hipSuccess;
hip_status = ihipBindTexture2DImpl(hipTextureType2D, hipReadModeElementType, offset, devPtr,
desc, width, height, tex);
@@ -613,7 +613,7 @@ hipError_t ihipBindTextureToArrayImpl(int dim, enum hipTextureReadMode readMode,
hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array,
const hipChannelFormatDesc* desc) {
HIP_INIT_API(tex, array, desc);
HIP_INIT_API(hipBindTextureToArray, tex, array, desc);
hipError_t hip_status = hipSuccess;
// TODO: hipReadModeElementType is default.
hip_status =
@@ -624,7 +624,7 @@ hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array,
hipError_t hipBindTextureToMipmappedArray(textureReference* tex,
hipMipmappedArray_const_t mipmappedArray,
const hipChannelFormatDesc* desc) {
HIP_INIT_API(tex, mipmappedArray, desc);
HIP_INIT_API(hipBindTextureToMipmappedArray, tex, mipmappedArray, desc);
hipError_t hip_status = hipSuccess;
return ihipLogStatus(hip_status);
}
@@ -652,14 +652,14 @@ hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject) {
}
hipError_t hipUnbindTexture(const textureReference* tex) {
HIP_INIT_API(tex);
HIP_INIT_API(hipUnbindTexture, tex);
hipError_t hip_status = hipSuccess;
hip_status = ihipUnbindTextureImpl(tex->textureObject);
return ihipLogStatus(hip_status);
}
hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array) {
HIP_INIT_API(desc, array);
HIP_INIT_API(hipGetChannelDesc, desc, array);
hipError_t hip_status = hipSuccess;
auto ctx = ihipGetTlsDefaultCtx();
@@ -670,7 +670,7 @@ hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array)
}
hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* tex) {
HIP_INIT_API(offset, tex);
HIP_INIT_API(hipGetTextureAlignmentOffset, offset, tex);
hipError_t hip_status = hipSuccess;
@@ -683,7 +683,7 @@ hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference*
}
hipError_t hipGetTextureReference(const textureReference** tex, const void* symbol) {
HIP_INIT_API(tex, symbol);
HIP_INIT_API(hipGetTextureReference, tex, symbol);
hipError_t hip_status = hipSuccess;
@@ -694,7 +694,7 @@ hipError_t hipGetTextureReference(const textureReference** tex, const void* symb
}
hipError_t hipTexRefSetFormat(textureReference* tex, hipArray_Format fmt, int NumPackedComponents) {
HIP_INIT_API(tex, fmt, NumPackedComponents);
HIP_INIT_API(hipTexRefSetFormat, tex, fmt, NumPackedComponents);
hipError_t hip_status = hipSuccess;
tex->format = fmt;
tex->numChannels = NumPackedComponents;
@@ -702,28 +702,28 @@ hipError_t hipTexRefSetFormat(textureReference* tex, hipArray_Format fmt, int Nu
}
hipError_t hipTexRefSetFlags(textureReference* tex, unsigned int flags) {
HIP_INIT_API(tex, flags);
HIP_INIT_API(hipTexRefSetFlags, tex, flags);
hipError_t hip_status = hipSuccess;
tex->normalized = flags;
return ihipLogStatus(hip_status);
}
hipError_t hipTexRefSetFilterMode(textureReference* tex, hipTextureFilterMode fm) {
HIP_INIT_API(tex, fm);
HIP_INIT_API(hipTexRefSetFilterMode, tex, fm);
hipError_t hip_status = hipSuccess;
tex->filterMode = fm;
return ihipLogStatus(hip_status);
}
hipError_t hipTexRefSetAddressMode(textureReference* tex, int dim, hipTextureAddressMode am) {
HIP_INIT_API(tex, dim, am);
HIP_INIT_API(hipTexRefSetAddressMode, tex, dim, am);
hipError_t hip_status = hipSuccess;
tex->addressMode[dim] = am;
return ihipLogStatus(hip_status);
}
hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsigned int flags) {
HIP_INIT_API(tex, array, flags);
HIP_INIT_API(hipTexRefSetArray, tex, array, flags);
hipError_t hip_status = hipSuccess;
hip_status = ihipBindTextureToArrayImpl(array->textureType, hipReadModeElementType, array,
@@ -734,7 +734,7 @@ hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsi
hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDeviceptr_t devPtr,
size_t size) {
HIP_INIT_API(offset, tex, devPtr, size);
HIP_INIT_API(hipTexRefSetAddress, offset, tex, devPtr, size);
hipError_t hip_status = hipSuccess;
// TODO: hipReadModeElementType is default.
hip_status = ihipBindTextureImpl(hipTextureType1D, hipReadModeElementType, offset, devPtr, NULL,
@@ -744,7 +744,7 @@ hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDevicep
hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPTOR* desc,
hipDeviceptr_t devPtr, size_t pitch) {
HIP_INIT_API(tex, desc, devPtr, pitch);
HIP_INIT_API(hipTexRefSetAddress2D, tex, desc, devPtr, pitch);
size_t offset;
hipError_t hip_status = hipSuccess;
// TODO: hipReadModeElementType is default.
+7
Просмотреть файл
@@ -23,6 +23,13 @@ config.test_source_root = os.path.dirname(__file__)
config.excludes = ['cmdparser.hpp']
config.cuda_version = "@CUDA_VERSION@"
if config.cuda_version not in ['10.0']:
config.excludes.append('cuSPARSE_08.cu')
config.excludes.append('cuSPARSE_09.cu')
config.excludes.append('cuSPARSE_10.cu')
config.excludes.append('cuSPARSE_11.cu')
# test_exec_root: The path where tests are located (default is the test suite root).
#config.test_exec_root = config.test_source_root
@@ -48,6 +48,7 @@
// CHECK: #include <string>
// CHECK: #include "hipfft.h"
// CHECK: #include "hipsparse.h"
#include <cuda.h>
@@ -95,3 +96,5 @@
#include <string>
#include "cufft.h"
#include "cusparse.h"
+367
Просмотреть файл
@@ -0,0 +1,367 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include "hipsparse.h"
#include "cusparse.h"
// CHECK: if (y) hipFree(y);
// CHECK: if (z) hipFree(z);
// CHECK: if (xInd) hipFree(xInd);
// CHECK: if (xVal) hipFree(xVal);
// CHECK: if (csrRowPtr) hipFree(csrRowPtr);
// CHECK: if (cooRowIndex) hipFree(cooRowIndex);
// CHECK: if (cooColIndex) hipFree(cooColIndex);
// CHECK: if (cooVal) hipFree(cooVal);
// CHECK: if (descr) hipsparseDestroyMatDescr(descr);
// CHECK: if (handle) hipsparseDestroy(handle);
// CHECK: hipDeviceReset();
#define CLEANUP(s) \
do { \
printf ("%s\n", s); \
if (yHostPtr) free(yHostPtr); \
if (zHostPtr) free(zHostPtr); \
if (xIndHostPtr) free(xIndHostPtr); \
if (xValHostPtr) free(xValHostPtr); \
if (cooRowIndexHostPtr) free(cooRowIndexHostPtr);\
if (cooColIndexHostPtr) free(cooColIndexHostPtr);\
if (cooValHostPtr) free(cooValHostPtr); \
if (y) cudaFree(y); \
if (z) cudaFree(z); \
if (xInd) cudaFree(xInd); \
if (xVal) cudaFree(xVal); \
if (csrRowPtr) cudaFree(csrRowPtr); \
if (cooRowIndex) cudaFree(cooRowIndex); \
if (cooColIndex) cudaFree(cooColIndex); \
if (cooVal) cudaFree(cooVal); \
if (descr) cusparseDestroyMatDescr(descr);\
if (handle) cusparseDestroy(handle); \
cudaDeviceReset(); \
fflush (stdout); \
} while (0)
int main(){
// CHECK: hipError_t cudaStat1,cudaStat2,cudaStat3,cudaStat4,cudaStat5,cudaStat6;
cudaError_t cudaStat1,cudaStat2,cudaStat3,cudaStat4,cudaStat5,cudaStat6;
// CHECK: hipsparseStatus_t status;
cusparseStatus_t status;
// CHECK: hipsparseHandle_t handle=0;
cusparseHandle_t handle=0;
// CHECK: hipsparseMatDescr_t descr=0;
cusparseMatDescr_t descr=0;
int * cooRowIndexHostPtr=0;
int * cooColIndexHostPtr=0;
double * cooValHostPtr=0;
int * cooRowIndex=0;
int * cooColIndex=0;
double * cooVal=0;
int * xIndHostPtr=0;
double * xValHostPtr=0;
double * yHostPtr=0;
int * xInd=0;
double * xVal=0;
double * y=0;
int * csrRowPtr=0;
double * zHostPtr=0;
double * z=0;
int n, nnz, nnz_vector;
double dzero =0.0;
double dtwo =2.0;
double dthree=3.0;
double dfive =5.0;
printf("testing example\n");
/* create the following sparse test matrix in COO format */
/* |1.0 2.0 3.0|
| 4.0 |
|5.0 6.0 7.0|
| 8.0 9.0| */
n=4; nnz=9;
cooRowIndexHostPtr = (int *) malloc(nnz*sizeof(cooRowIndexHostPtr[0]));
cooColIndexHostPtr = (int *) malloc(nnz*sizeof(cooColIndexHostPtr[0]));
cooValHostPtr = (double *)malloc(nnz*sizeof(cooValHostPtr[0]));
if ((!cooRowIndexHostPtr) || (!cooColIndexHostPtr) || (!cooValHostPtr)){
CLEANUP("Host malloc failed (matrix)");
return 1;
}
cooRowIndexHostPtr[0]=0; cooColIndexHostPtr[0]=0; cooValHostPtr[0]=1.0;
cooRowIndexHostPtr[1]=0; cooColIndexHostPtr[1]=2; cooValHostPtr[1]=2.0;
cooRowIndexHostPtr[2]=0; cooColIndexHostPtr[2]=3; cooValHostPtr[2]=3.0;
cooRowIndexHostPtr[3]=1; cooColIndexHostPtr[3]=1; cooValHostPtr[3]=4.0;
cooRowIndexHostPtr[4]=2; cooColIndexHostPtr[4]=0; cooValHostPtr[4]=5.0;
cooRowIndexHostPtr[5]=2; cooColIndexHostPtr[5]=2; cooValHostPtr[5]=6.0;
cooRowIndexHostPtr[6]=2; cooColIndexHostPtr[6]=3; cooValHostPtr[6]=7.0;
cooRowIndexHostPtr[7]=3; cooColIndexHostPtr[7]=1; cooValHostPtr[7]=8.0;
cooRowIndexHostPtr[8]=3; cooColIndexHostPtr[8]=3; cooValHostPtr[8]=9.0;
nnz_vector = 3;
xIndHostPtr = (int *) malloc(nnz_vector*sizeof(xIndHostPtr[0]));
xValHostPtr = (double *)malloc(nnz_vector*sizeof(xValHostPtr[0]));
yHostPtr = (double *)malloc(2*n *sizeof(yHostPtr[0]));
zHostPtr = (double *)malloc(2*(n+1) *sizeof(zHostPtr[0]));
if((!xIndHostPtr) || (!xValHostPtr) || (!yHostPtr) || (!zHostPtr)) {
CLEANUP("Host malloc failed (vectors)");
return 1;
}
yHostPtr[0] = 10.0;
xIndHostPtr[0]=0;
xValHostPtr[0]=100.0;
yHostPtr[1] = 20.0;
xIndHostPtr[1]=1;
xValHostPtr[1]=200.0;
yHostPtr[2] = 30.0;
yHostPtr[3] = 40.0;
xIndHostPtr[2]=3;
xValHostPtr[2]=400.0;
yHostPtr[4] = 50.0;
yHostPtr[5] = 60.0;
yHostPtr[6] = 70.0;
yHostPtr[7] = 80.0;
/* allocate GPU memory and copy the matrix and vectors into it */
// CHECK: cudaStat1 = hipMalloc((void**)&cooRowIndex,nnz*sizeof(cooRowIndex[0]));
cudaStat1 = cudaMalloc((void**)&cooRowIndex,nnz*sizeof(cooRowIndex[0]));
// CHECK: cudaStat2 = hipMalloc((void**)&cooColIndex,nnz*sizeof(cooColIndex[0]));
cudaStat2 = cudaMalloc((void**)&cooColIndex,nnz*sizeof(cooColIndex[0]));
// CHECK: cudaStat3 = hipMalloc((void**)&cooVal, nnz*sizeof(cooVal[0]));
cudaStat3 = cudaMalloc((void**)&cooVal, nnz*sizeof(cooVal[0]));
// CHECK: cudaStat4 = hipMalloc((void**)&y, 2*n*sizeof(y[0]));
cudaStat4 = cudaMalloc((void**)&y, 2*n*sizeof(y[0]));
// CHECK: cudaStat5 = hipMalloc((void**)&xInd,nnz_vector*sizeof(xInd[0]));
cudaStat5 = cudaMalloc((void**)&xInd,nnz_vector*sizeof(xInd[0]));
// CHECK: cudaStat6 = hipMalloc((void**)&xVal,nnz_vector*sizeof(xVal[0]));
cudaStat6 = cudaMalloc((void**)&xVal,nnz_vector*sizeof(xVal[0]));
// CHECK: if ((cudaStat1 != hipSuccess) ||
// CHECK: (cudaStat2 != hipSuccess) ||
// CHECK: (cudaStat3 != hipSuccess) ||
// CHECK: (cudaStat4 != hipSuccess) ||
// CHECK: (cudaStat5 != hipSuccess) ||
// CHECK: (cudaStat6 != hipSuccess)) {
if ((cudaStat1 != cudaSuccess) ||
(cudaStat2 != cudaSuccess) ||
(cudaStat3 != cudaSuccess) ||
(cudaStat4 != cudaSuccess) ||
(cudaStat5 != cudaSuccess) ||
(cudaStat6 != cudaSuccess)) {
CLEANUP("Device malloc failed");
return 1;
}
// CHECK: cudaStat1 = hipMemcpy(cooRowIndex, cooRowIndexHostPtr,
// CHECK: hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(cooRowIndex, cooRowIndexHostPtr,
(size_t)(nnz*sizeof(cooRowIndex[0])),
cudaMemcpyHostToDevice);
// CHECK: cudaStat2 = hipMemcpy(cooColIndex, cooColIndexHostPtr,
// CHECK: hipMemcpyHostToDevice);
cudaStat2 = cudaMemcpy(cooColIndex, cooColIndexHostPtr,
(size_t)(nnz*sizeof(cooColIndex[0])),
cudaMemcpyHostToDevice);
// CHECK: cudaStat3 = hipMemcpy(cooVal, cooValHostPtr,
// CHECK: hipMemcpyHostToDevice);
cudaStat3 = cudaMemcpy(cooVal, cooValHostPtr,
(size_t)(nnz*sizeof(cooVal[0])),
cudaMemcpyHostToDevice);
// CHECK: cudaStat4 = hipMemcpy(y, yHostPtr,
// CHECK: hipMemcpyHostToDevice);
cudaStat4 = cudaMemcpy(y, yHostPtr,
(size_t)(2*n*sizeof(y[0])),
cudaMemcpyHostToDevice);
// CHECK: cudaStat5 = hipMemcpy(xInd, xIndHostPtr,
// CHECK: hipMemcpyHostToDevice);
cudaStat5 = cudaMemcpy(xInd, xIndHostPtr,
(size_t)(nnz_vector*sizeof(xInd[0])),
cudaMemcpyHostToDevice);
// CHECK: cudaStat6 = hipMemcpy(xVal, xValHostPtr,
// CHECK: hipMemcpyHostToDevice);
cudaStat6 = cudaMemcpy(xVal, xValHostPtr,
(size_t)(nnz_vector*sizeof(xVal[0])),
cudaMemcpyHostToDevice);
// CHECK: if ((cudaStat1 != hipSuccess) ||
// CHECK: (cudaStat2 != hipSuccess) ||
// CHECK: (cudaStat3 != hipSuccess) ||
// CHECK: (cudaStat4 != hipSuccess) ||
// CHECK: (cudaStat5 != hipSuccess) ||
// CHECK: (cudaStat6 != hipSuccess)) {
if ((cudaStat1 != cudaSuccess) ||
(cudaStat2 != cudaSuccess) ||
(cudaStat3 != cudaSuccess) ||
(cudaStat4 != cudaSuccess) ||
(cudaStat5 != cudaSuccess) ||
(cudaStat6 != cudaSuccess)) {
CLEANUP("Memcpy from Host to Device failed");
return 1;
}
/* initialize cusparse library */
// CHECK: status= hipsparseCreate(&handle);
status= cusparseCreate(&handle);
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("CUSPARSE Library initialization failed");
return 1;
}
/* create and setup matrix descriptor */
// CHECK: status= hipsparseCreateMatDescr(&descr);
status= cusparseCreateMatDescr(&descr);
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("Matrix descriptor initialization failed");
return 1;
}
// CHECK: hipsparseSetMatType(descr,HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descr,CUSPARSE_MATRIX_TYPE_GENERAL);
// CHECK: hipsparseSetMatIndexBase(descr,HIPSPARSE_INDEX_BASE_ZERO);
cusparseSetMatIndexBase(descr,CUSPARSE_INDEX_BASE_ZERO);
/* exercise conversion routines (convert matrix from COO 2 CSR format) */
// CHECK: cudaStat1 = hipMalloc((void**)&csrRowPtr,(n+1)*sizeof(csrRowPtr[0]));
cudaStat1 = cudaMalloc((void**)&csrRowPtr,(n+1)*sizeof(csrRowPtr[0]));
// CHECK: if (cudaStat1 != hipSuccess) {
if (cudaStat1 != cudaSuccess) {
CLEANUP("Device malloc failed (csrRowPtr)");
return 1;
}
status= cusparseXcoo2csr(handle,cooRowIndex,nnz,n,
// CHECK: csrRowPtr,HIPSPARSE_INDEX_BASE_ZERO);
csrRowPtr,CUSPARSE_INDEX_BASE_ZERO);
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("Conversion from COO to CSR format failed");
return 1;
}
//csrRowPtr = [0 3 4 7 9]
// The following test only works for compute capability 1.3 and above
// because it needs double precision.
int devId;
// CHECK: hipDeviceProp_t prop;
cudaDeviceProp prop;
// CHECK: hipError_t cudaStat;
cudaError_t cudaStat;
// CHECK: cudaStat = hipGetDevice(&devId);
cudaStat = cudaGetDevice(&devId);
// CHECK: if (hipSuccess != cudaStat){
if (cudaSuccess != cudaStat){
// CLEANUP("hipGetDevice failed");
CLEANUP("cudaGetDevice failed");
// printf("Error: cudaStat %d, %s\n", cudaStat, hipGetErrorString(cudaStat));
printf("Error: cudaStat %d, %s\n", cudaStat, cudaGetErrorString(cudaStat));
return 1;
}
// CHECK: cudaStat = hipGetDeviceProperties( &prop, devId);
cudaStat = cudaGetDeviceProperties( &prop, devId);
// CHECK: if (hipSuccess != cudaStat) {
if (cudaSuccess != cudaStat) {
// CHECK: CLEANUP("hipGetDeviceProperties failed");
CLEANUP("cudaGetDeviceProperties failed");
// CHECK: printf("Error: cudaStat %d, %s\n", cudaStat, hipGetErrorString(cudaStat));
printf("Error: cudaStat %d, %s\n", cudaStat, cudaGetErrorString(cudaStat));
return 1;
}
int cc = 100*prop.major + 10*prop.minor;
if (cc < 130){
CLEANUP("waive the test because only sm13 and above are supported\n");
printf("the device has compute capability %d\n", cc);
printf("example test WAIVED");
return 2;
}
/* exercise Level 1 routines (scatter vector elements) */
// CHECK: status= hipsparseDsctr(handle, nnz_vector, xVal, xInd,
// CHECK: &y[n], HIPSPARSE_INDEX_BASE_ZERO);
status= cusparseDsctr(handle, nnz_vector, xVal, xInd,
&y[n], CUSPARSE_INDEX_BASE_ZERO);
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("Scatter from sparse to dense vector failed");
return 1;
}
//y = [10 20 30 40 | 100 200 70 400]
/* exercise Level 2 routines (csrmv) */
// CHECK: status= hipsparseDcsrmv(handle,HIPSPARSE_OPERATION_NON_TRANSPOSE, n, n, nnz,
status= cusparseDcsrmv(handle,CUSPARSE_OPERATION_NON_TRANSPOSE, n, n, nnz,
&dtwo, descr, cooVal, csrRowPtr, cooColIndex,
&y[0], &dthree, &y[n]);
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("Matrix-vector multiplication failed");
return 1;
}
//y = [10 20 30 40 | 680 760 1230 2240]
// CHECK: hipMemcpy(yHostPtr, y, (size_t)(2*n*sizeof(y[0])), hipMemcpyDeviceToHost);
cudaMemcpy(yHostPtr, y, (size_t)(2*n*sizeof(y[0])), cudaMemcpyDeviceToHost);
/* exercise Level 3 routines (csrmm) */
// cudaStat1 = hipMalloc((void**)&z, 2*(n+1)*sizeof(z[0]));
cudaStat1 = cudaMalloc((void**)&z, 2*(n+1)*sizeof(z[0]));
// CHECK: if (cudaStat1 != hipSuccess) {
if (cudaStat1 != cudaSuccess) {
CLEANUP("Device malloc failed (z)");
return 1;
}
// CHECK: cudaStat1 = hipMemset((void *)z,0, 2*(n+1)*sizeof(z[0]));
cudaStat1 = cudaMemset((void *)z,0, 2*(n+1)*sizeof(z[0]));
// CHECK: if (cudaStat1 != hipSuccess) {
if (cudaStat1 != cudaSuccess) {
CLEANUP("Memset on Device failed");
return 1;
}
// CHECK: status= hipsparseDcsrmm(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n,
status= cusparseDcsrmm(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n,
nnz, &dfive, descr, cooVal, csrRowPtr, cooColIndex,
y, n, &dzero, z, n+1);
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("Matrix-matrix multiplication failed");
return 1;
}
/* print final results (z) */
// CHECK: cudaStat1 = hipMemcpy(zHostPtr, z,
// CHECK: hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(zHostPtr, z,
(size_t)(2*(n+1)*sizeof(z[0])),
cudaMemcpyDeviceToHost);
// CHECK: if (cudaStat1 != hipSuccess) {
if (cudaStat1 != cudaSuccess) {
CLEANUP("Memcpy from Device to Host failed");
return 1;
}
//z = [950 400 2550 2600 0 | 49300 15200 132300 131200 0]
/* destroy matrix descriptor */
// status = hipsparseDestroyMatDescr(descr);
status = cusparseDestroyMatDescr(descr);
descr = 0;
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("Matrix descriptor destruction failed");
return 1;
}
/* destroy handle */
// CHECK: status = hipsparseDestroy(handle);
status = cusparseDestroy(handle);
handle = 0;
// CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) {
if (status != CUSPARSE_STATUS_SUCCESS) {
CLEANUP("CUSPARSE Library release of resources failed");
return 1;
}
/* check the results */
// Notice that CLEANUP() contains a call to cusparseDestroy(handle)
if ((zHostPtr[0] != 950.0) ||
(zHostPtr[1] != 400.0) ||
(zHostPtr[2] != 2550.0) ||
(zHostPtr[3] != 2600.0) ||
(zHostPtr[4] != 0.0) ||
(zHostPtr[5] != 49300.0) ||
(zHostPtr[6] != 15200.0) ||
(zHostPtr[7] != 132300.0) ||
(zHostPtr[8] != 131200.0) ||
(zHostPtr[9] != 0.0) ||
(yHostPtr[0] != 10.0) ||
(yHostPtr[1] != 20.0) ||
(yHostPtr[2] != 30.0) ||
(yHostPtr[3] != 40.0) ||
(yHostPtr[4] != 680.0) ||
(yHostPtr[5] != 760.0) ||
(yHostPtr[6] != 1230.0) ||
(yHostPtr[7] != 2240.0)) {
CLEANUP("example test FAILED");
return 1;
} else {
CLEANUP("example test PASSED");
return 0;
}
}
+284
Просмотреть файл
@@ -0,0 +1,284 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipblas.h>
#include <cublas_v2.h>
// CHECK: #include "hipsparse.h"
#include "cusparse.h"
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
int main(int argc, char*argv[])
{
// CHECK: hipblasHandle_t cublasH = NULL;
cublasHandle_t cublasH = NULL;
// CHECK: hipsparseHandle_t cusparseH = NULL;
cusparseHandle_t cusparseH = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseMatDescr_t descrA = NULL;
cusparseMatDescr_t descrA = NULL;
// CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS;
cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS;
// CHECK: hipsparseStatus_t cusparseStat = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t cusparseStat = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
// CHECK: hipError_t cudaStat2 = hipSuccess;
// CHECK: hipError_t cudaStat3 = hipSuccess;
// CHECK: hipError_t cudaStat4 = hipSuccess;
// CHECK: hipError_t cudaStat5 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
cudaError_t cudaStat2 = cudaSuccess;
cudaError_t cudaStat3 = cudaSuccess;
cudaError_t cudaStat4 = cudaSuccess;
cudaError_t cudaStat5 = cudaSuccess;
const int n = 4;
const int nnzA = 9;
/*
* | 1 0 2 3 |
* | 0 4 0 0 |
* A = | 5 0 6 7 |
* | 0 8 0 9 |
*
* eigevales are { -0.5311, 7.5311, 9.0000, 4.0000 }
*
* The largest eigenvaluse is 9 and corresponding eigenvector is
*
* | 0.3029 |
* v = | 0 |
* | 0.9350 |
* | 0.1844 |
*/
const int csrRowPtrA[n+1] = { 0, 3, 4, 7, 9 };
const int csrColIndA[nnzA] = {0, 2, 3, 1, 0, 2, 3, 1, 3 };
const double csrValA[nnzA] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };
const double lambda_exact[n] = { 9.0000, 7.5311, 4.0000, -0.5311 };
const double x0[n] = {1.0, 2.0, 3.0, 4.0 }; /* initial guess */
double x[n]; /* numerical eigenvector */
int *d_csrRowPtrA = NULL;
int *d_csrColIndA = NULL;
double *d_csrValA = NULL;
double *d_x = NULL; /* eigenvector */
double *d_y = NULL; /* workspace */
const double tol = 1.e-6;
const int max_ites = 30;
const double h_one = 1.0;
const double h_zero = 0.0;
printf("example of csrmv_mp \n");
printf("tol = %E \n", tol);
printf("max. iterations = %d \n", max_ites);
printf("1st eigenvaluse is %f\n", lambda_exact[0] );
printf("2nd eigenvaluse is %f\n", lambda_exact[1] );
double alpha = lambda_exact[1]/lambda_exact[0] ;
printf("convergence rate is %f\n", alpha );
double est_iterations = log(tol)/log(alpha);
printf("# of iterations required is %d\n", (int)ceil(est_iterations));
// step 1: create cublas/cusparse handle, bind a stream
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cublasStat = hipblasCreate(&cublasH);
cublasStat = cublasCreate(&cublasH);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: cublasStat = hipblasSetStream(cublasH, stream);
cublasStat = cublasSetStream(cublasH, stream);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: cusparseStat = hipsparseCreate(&cusparseH);
cusparseStat = cusparseCreate(&cusparseH);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat);
assert(CUSPARSE_STATUS_SUCCESS == cusparseStat);
// CHECK: cusparseStat = hipsparseSetStream(cusparseH, stream);
cusparseStat = cusparseSetStream(cusparseH, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat);
assert(CUSPARSE_STATUS_SUCCESS == cusparseStat);
// step 2: configuration of matrix A
// CHECK: cusparseStat = hipsparseCreateMatDescr(&descrA);
cusparseStat = cusparseCreateMatDescr(&descrA);
// assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat);
assert(CUSPARSE_STATUS_SUCCESS == cusparseStat);
// CHECK: hipsparseSetMatIndexBase(descrA,HIPSPARSE_INDEX_BASE_ZERO);
cusparseSetMatIndexBase(descrA,CUSPARSE_INDEX_BASE_ZERO);
// CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL );
cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL );
// step 3: copy A and x0 to device
// CHECK: cudaStat1 = hipMalloc ((void**)&d_csrRowPtrA, sizeof(int) * (n+1) );
cudaStat1 = cudaMalloc ((void**)&d_csrRowPtrA, sizeof(int) * (n+1) );
// CHECK: cudaStat2 = hipMalloc ((void**)&d_csrColIndA, sizeof(int) * nnzA );
cudaStat2 = cudaMalloc ((void**)&d_csrColIndA, sizeof(int) * nnzA );
// CHECK: cudaStat3 = hipMalloc ((void**)&d_csrValA , sizeof(double) * nnzA );
cudaStat3 = cudaMalloc ((void**)&d_csrValA , sizeof(double) * nnzA );
// CHECK: cudaStat4 = hipMalloc ((void**)&d_x , sizeof(double) * n );
cudaStat4 = cudaMalloc ((void**)&d_x , sizeof(double) * n );
// CHECK: cudaStat5 = hipMalloc ((void**)&d_y , sizeof(double) * n );
cudaStat5 = cudaMalloc ((void**)&d_y , sizeof(double) * n );
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
// CHECK: assert(hipSuccess == cudaStat4);
// CHECK: assert(hipSuccess == cudaStat5);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
assert(cudaSuccess == cudaStat4);
assert(cudaSuccess == cudaStat5);
// CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int) * (n+1) , hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int) * (n+1) , cudaMemcpyHostToDevice);
// CHECK: cudaStat2 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int) * nnzA , hipMemcpyHostToDevice);
cudaStat2 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int) * nnzA , cudaMemcpyHostToDevice);
// CHECK: cudaStat3 = hipMemcpy(d_csrValA , csrValA , sizeof(double) * nnzA , hipMemcpyHostToDevice);
cudaStat3 = cudaMemcpy(d_csrValA , csrValA , sizeof(double) * nnzA , cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
assert(cudaSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
assert(cudaSuccess == cudaStat3);
// step 4: power method
double lambda = 0.0;
double lambda_next = 0.0;
// 4.1: initial guess x0
cudaStat1 = cudaMemcpy(d_x, x0, sizeof(double) * n, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
for(int ite = 0 ; ite < max_ites ; ite++ ){
// 4.2: normalize vector x
// x = x / |x|
double nrm2_x;
// TODO: cublasStat = hipblasDnrm2_v2(cublasH,
cublasStat = cublasDnrm2_v2(cublasH,
n,
d_x,
1, // incx,
&nrm2_x /* host pointer */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
double one_over_nrm2_x = 1.0 / nrm2_x;
// TODO: cublasStat = hipblasDscal_v2( cublasH,
cublasStat = cublasDscal_v2( cublasH,
n,
&one_over_nrm2_x, /* host pointer */
d_x,
1 // incx
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// 4.3: y = A*x
// TODO: hipsparseStat = cusparseDcsrmv_mp(cusparseH,
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE
cusparseStat = cusparseDcsrmv_mp(cusparseH,
CUSPARSE_OPERATION_NON_TRANSPOSE,
n,
n,
nnzA,
&h_one,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
d_x,
&h_zero,
d_y);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat);
assert(CUSPARSE_STATUS_SUCCESS == cusparseStat);
// 4.4: lambda = y**T*x
// TODO: cublasStat = hipblasDdot_v2 ( cublasH,
cublasStat = cublasDdot_v2 ( cublasH,
n,
d_x,
1, // incx,
d_y,
1, // incy,
&lambda_next /* host pointer */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
double lambda_err = fabs( lambda_next - lambda_exact[0] );
printf("ite %d: lambda = %f, error = %E\n", ite, lambda_next, lambda_err );
// 4.5: check if converges
if ( (ite > 0) &&
fabs( lambda - lambda_next ) < tol
){
break; // converges
}
/*
* 4.6: x := y
* lambda = lambda_next
*
* so new approximation is (lambda, x), x is not normalized.
*/
// CHECK: cudaStat1 = hipMemcpy(d_x, d_y, sizeof(double) * n , hipMemcpyDeviceToDevice);
cudaStat1 = cudaMemcpy(d_x, d_y, sizeof(double) * n , cudaMemcpyDeviceToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
lambda = lambda_next;
}
// step 5: report eigen-pair
// CHECK: cudaStat1 = hipMemcpy(x, d_x, sizeof(double) * n, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(x, d_x, sizeof(double) * n, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printf("largest eigenvalue is %E\n", lambda );
printf("eigenvector = (matlab base-1)\n");
printMatrix(n, 1, x, n, "V0");
printf("=====\n");
// free resources
// CHECK: if (d_csrRowPtrA ) hipFree(d_csrRowPtrA);
if (d_csrRowPtrA ) cudaFree(d_csrRowPtrA);
// CHECK: if (d_csrColIndA ) hipFree(d_csrColIndA);
if (d_csrColIndA ) cudaFree(d_csrColIndA);
// CHECK: if (d_csrValA ) hipFree(d_csrValA);
if (d_csrValA ) cudaFree(d_csrValA);
// CHECK: if (d_x ) hipFree(d_x);
if (d_x ) cudaFree(d_x);
// CHeCK: if (d_y ) hipFree(d_y);
if (d_y ) cudaFree(d_y);
// CHECK: if (cublasH ) hipblasDestroy(cublasH);
if (cublasH ) cublasDestroy(cublasH);
// CHECK: if (cusparseH ) hipsparseDestroy(cusparseH);
if (cusparseH ) cusparseDestroy(cusparseH);
// CHECK: if (stream ) hipStreamDestroy(stream);
if (stream ) cudaStreamDestroy(stream);
// CHECK: if (descrA ) hipsparseDestroyMatDescr(descrA);
if (descrA ) cusparseDestroyMatDescr(descrA);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+229
Просмотреть файл
@@ -0,0 +1,229 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include "hipsparse.h"
#include "cusparse.h"
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t handle = NULL;
cusparseHandle_t handle = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
// CHECK: hipError_t cudaStat2 = hipSuccess;
// CHECK: hipError_t cudaStat3 = hipSuccess;
// CHECK: hipError_t cudaStat4 = hipSuccess;
// CHECK: hipError_t cudaStat5 = hipSuccess;
// CHECK: hipError_t cudaStat6 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
cudaError_t cudaStat2 = cudaSuccess;
cudaError_t cudaStat3 = cudaSuccess;
cudaError_t cudaStat4 = cudaSuccess;
cudaError_t cudaStat5 = cudaSuccess;
cudaError_t cudaStat6 = cudaSuccess;
/*
* A is a 3x3 sparse matrix
* | 1 2 0 |
* A = | 0 5 0 |
* | 0 8 0 |
*/
const int m = 3;
const int n = 3;
const int nnz = 4;
#if 0
/* index starts at 0 */
int h_cooRows[nnz] = { 2, 1, 0, 0 };
int h_cooCols[nnz] = { 1, 1, 0, 1 };
#else
/* index starts at -2 */
int h_cooRows[nnz] = { 0, -1, -2, -2 };
int h_cooCols[nnz] = { -1, -1, -2, -1 };
#endif
double h_cooVals[nnz] = { 8.0, 5.0, 1.0, 2.0 };
int h_P[nnz];
int *d_cooRows = NULL;
int *d_cooCols = NULL;
int *d_P = NULL;
double *d_cooVals = NULL;
double *d_cooVals_sorted = NULL;
size_t pBufferSizeInBytes = 0;
void *pBuffer = NULL;
printf("m = %d, n = %d, nnz=%d \n", m, n, nnz);
/* step 1: create cusparse handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&handle);
status = cusparseCreate(&handle);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(handle, stream);
status = cusparseSetStream(handle, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 2: allocate buffer */
// TODO: status = hipsparseXcoosort_bufferSizeExt(
status = cusparseXcoosort_bufferSizeExt(
handle,
m,
n,
nnz,
d_cooRows,
d_cooCols,
&pBufferSizeInBytes
);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("pBufferSizeInBytes = %lld bytes \n", (long long)pBufferSizeInBytes);
// CHECK: cudaStat1 = hipMalloc(&d_cooRows, sizeof(int)*nnz);
cudaStat1 = cudaMalloc(&d_cooRows, sizeof(int)*nnz);
// CHECK: cudaStat2 = hipMalloc(&d_cooCols, sizeof(int)*nnz);
cudaStat2 = cudaMalloc(&d_cooCols, sizeof(int)*nnz);
// CHECK: cudaStat3 = hipMalloc(&d_P, sizeof(int)*nnz);
cudaStat3 = cudaMalloc(&d_P, sizeof(int)*nnz);
// CHECK: cudaStat4 = hipMalloc(&d_cooVals, sizeof(double)*nnz);
cudaStat4 = cudaMalloc(&d_cooVals, sizeof(double)*nnz);
// CHECK: cudaStat5 = hipMalloc(&d_cooVals_sorted, sizeof(double)*nnz);
cudaStat5 = cudaMalloc(&d_cooVals_sorted, sizeof(double)*nnz);
// CHECK: cudaStat6 = hipMalloc(&pBuffer, sizeof(char)* pBufferSizeInBytes);
cudaStat6 = cudaMalloc(&pBuffer, sizeof(char)* pBufferSizeInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
// CHECK: assert(hipSuccess == cudaStat4);
// CHECK: assert(hipSuccess == cudaStat5);
// CHECK: assert(hipSuccess == cudaStat6);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
assert(cudaSuccess == cudaStat4);
assert(cudaSuccess == cudaStat5);
assert(cudaSuccess == cudaStat6);
// CHECK: cudaStat1 = hipMemcpy(d_cooRows, h_cooRows, sizeof(int)*nnz, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_cooRows, h_cooRows, sizeof(int)*nnz, cudaMemcpyHostToDevice);
// CHECK: cudaStat2 = hipMemcpy(d_cooCols, h_cooCols, sizeof(int)*nnz, hipMemcpyHostToDevice);
cudaStat2 = cudaMemcpy(d_cooCols, h_cooCols, sizeof(int)*nnz, cudaMemcpyHostToDevice);
// CHECK: cudaStat3 = hipMemcpy(d_cooVals, h_cooVals, sizeof(double)*nnz, hipMemcpyHostToDevice);
cudaStat3 = cudaMemcpy(d_cooVals, h_cooVals, sizeof(double)*nnz, cudaMemcpyHostToDevice);
// CHECK: cudaStat4 = hipDeviceSynchronize();
cudaStat4 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
// CHECK: assert(hipSuccess == cudaStat4);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
assert(cudaSuccess == cudaStat4);
/* step 3: setup permutation vector P to identity */
// TODO: status = hipsparseCreateIdentityPermutation(
status = cusparseCreateIdentityPermutation(
handle,
nnz,
d_P);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 4: sort COO format by Row */
// TODO: status = hipsparseXcoosortByRow(
status = cusparseXcoosortByRow(
handle,
m,
n,
nnz,
d_cooRows,
d_cooCols,
d_P,
pBuffer
);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 5: gather sorted cooVals */
// CHECK: status = hipsparseDgthr(
// CHECK: HIPSPARSE_INDEX_BASE_ZERO
status = cusparseDgthr(
handle,
nnz,
d_cooVals,
d_cooVals_sorted,
d_P,
CUSPARSE_INDEX_BASE_ZERO
);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* wait until the computation is done */
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: cudaStat2 = hipMemcpy(h_cooRows, d_cooRows, sizeof(int)*nnz, hipMemcpyDeviceToHost);
cudaStat2 = cudaMemcpy(h_cooRows, d_cooRows, sizeof(int)*nnz, cudaMemcpyDeviceToHost);
// CHECK: cudaStat3 = hipMemcpy(h_cooCols, d_cooCols, sizeof(int)*nnz, hipMemcpyDeviceToHost);
cudaStat3 = cudaMemcpy(h_cooCols, d_cooCols, sizeof(int)*nnz, cudaMemcpyDeviceToHost);
// CHECK: cudaStat4 = hipMemcpy(h_P, d_P, sizeof(int)*nnz, hipMemcpyDeviceToHost);
cudaStat4 = cudaMemcpy(h_P, d_P, sizeof(int)*nnz, cudaMemcpyDeviceToHost);
// CHECK: cudaStat5 = hipMemcpy(h_cooVals, d_cooVals_sorted, sizeof(double)*nnz, hipMemcpyDeviceToHost);
cudaStat5 = cudaMemcpy(h_cooVals, d_cooVals_sorted, sizeof(double)*nnz, cudaMemcpyDeviceToHost);
// CHECK: cudaStat6 = hipDeviceSynchronize();
cudaStat6 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
// CHECK: assert(hipSuccess == cudaStat4);
// CHECK: assert(hipSuccess == cudaStat5);
// CHECK: assert(hipSuccess == cudaStat6);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
assert(cudaSuccess == cudaStat4);
assert(cudaSuccess == cudaStat5);
assert(cudaSuccess == cudaStat6);
printf("sorted coo: \n");
for (int j = 0; j < nnz; j++) {
printf("(%d, %d, %f) \n", h_cooRows[j], h_cooCols[j], h_cooVals[j]);
}
for (int j = 0; j < nnz; j++) {
printf("P[%d] = %d \n", j, h_P[j]);
}
/* free resources */
// CHECK: if (d_cooRows) hipFree(d_cooRows);
if (d_cooRows) cudaFree(d_cooRows);
// CHECK: if (d_cooCols) hipFree(d_cooCols);
if (d_cooCols) cudaFree(d_cooCols);
// CHECK: if (d_P) hipFree(d_P);
if (d_P) cudaFree(d_P);
// CHECK: if (d_cooVals) hipFree(d_cooVals);
if (d_cooVals) cudaFree(d_cooVals);
// CHECK: if (d_cooVals_sorted) hipFree(d_cooVals_sorted);
if (d_cooVals_sorted) cudaFree(d_cooVals_sorted);
// CHECK: if (pBuffer) hipFree(pBuffer);
if (pBuffer) cudaFree(pBuffer);
// if (handle) hipsparseDestroy(handle);
if (handle) cusparseDestroy(handle);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+261
Просмотреть файл
@@ -0,0 +1,261 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
void printMatrix(int m, int n, const float*A, int lda, const char* name)
{
for (int row = 0; row < m; row++) {
for (int col = 0; col < n; col++) {
float Areg = A[row + col * lda];
printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg);
}
}
}
void printCsr(
int m,
int n,
int nnz,
// CHECK: const hipsparseMatDescr_t descrA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const char* name)
{
// CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1;
const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1;
printf("matrix %s is %d-by-%d, nnz=%d, base=%d\n", name, m, n, nnz, base);
for (int row = 0; row < m; row++) {
const int start = csrRowPtrA[row] - base;
const int end = csrRowPtrA[row + 1] - base;
for (int colidx = start; colidx < end; colidx++) {
const int col = csrColIndA[colidx] - base;
const float Areg = csrValA[colidx];
printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg);
}
}
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t handle = NULL;
cusparseHandle_t handle = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseMatDescr_t descrC = NULL;
cusparseMatDescr_t descrC = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
// CHECK: hipError_t cudaStat2 = hipSuccess;
// CHECK: hipError_t cudaStat3 = hipSuccess;
// CHECK: hipError_t cudaStat4 = hipSuccess;
// CHECK: hipError_t cudaStat5 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
cudaError_t cudaStat2 = cudaSuccess;
cudaError_t cudaStat3 = cudaSuccess;
cudaError_t cudaStat4 = cudaSuccess;
cudaError_t cudaStat5 = cudaSuccess;
const int m = 4;
const int n = 4;
const int lda = m;
/*
* | 1 0 2 -3 |
* | 0 4 0 0 |
* A = | 5 0 6 7 |
* | 0 8 0 9 |
*
*/
const float A[lda*n] = { 1, 0, 5, 0, 0, 4, 0, 8, 2, 0, 6, 0, -3, 0, 7, 9 };
int* csrRowPtrC = NULL;
int* csrColIndC = NULL;
float* csrValC = NULL;
float *d_A = NULL;
int *d_csrRowPtrC = NULL;
int *d_csrColIndC = NULL;
float *d_csrValC = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
int nnzC = 0;
float threshold = 4.1; /* remove Aij <= 4.1 */
// float threshold = 0; /* remove zeros */
printf("example of pruneDense2csr \n");
printf("prune |A(i,j)| <= threshold \n");
printf("threshold = %E \n", threshold);
printMatrix(m, n, A, lda, "A");
/* step 1: create cusparse handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&handle);
status = cusparseCreate(&handle);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(handle, stream);
status = cusparseSetStream(handle, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 2: configuration of matrix C */
// CHECK: status = hipsparseCreateMatDescr(&descrC);
status = cusparseCreateMatDescr(&descrC);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO);
cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO);
// CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL);
// CHECK: cudaStat1 = hipMalloc((void**)&d_A, sizeof(float)*lda*n);
cudaStat1 = cudaMalloc((void**)&d_A, sizeof(float)*lda*n);
// CHECK: cudaStat2 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
cudaStat2 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
/* step 3: query workspace */
// CHECK: cudaStat1 = hipMemcpy(d_A, A, sizeof(float)*lda*n, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_A, A, sizeof(float)*lda*n, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// TODO: status = hipsparseSpruneDense2csr_bufferSizeExt(
status = cusparseSpruneDense2csr_bufferSizeExt(
handle,
m,
n,
d_A,
lda,
&threshold,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes (prune) = %lld \n", (long long)lworkInBytes);
// CHECK: if (NULL != d_work) { hipFree(d_work); }
if (NULL != d_work) { cudaFree(d_work); }
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 4: compute csrRowPtrC and nnzC */
// TODO: status = hipsparseSpruneDense2csrNnz(
status = cusparseSpruneDense2csrNnz(
handle,
m,
n,
d_A,
lda,
&threshold,
descrC,
d_csrRowPtrC,
&nnzC, /* host */
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printf("nnzC = %d\n", nnzC);
if (0 == nnzC) {
printf("C is empty \n");
return 0;
}
/* step 5: compute csrColIndC and csrValC */
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
// CHECK: cudaStat2 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
cudaStat2 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
// TODO: status = hipsparseSpruneDense2csr(
status = cusparseSpruneDense2csr(
handle,
m,
n,
d_A,
lda,
&threshold,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6: output C */
csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1));
csrColIndC = (int*)malloc(sizeof(int)*nnzC);
csrValC = (float*)malloc(sizeof(float)*nnzC);
assert(NULL != csrRowPtrC);
assert(NULL != csrColIndC);
assert(NULL != csrValC);
// CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost);
// CHECK: cudaStat2 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost);
cudaStat2 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: cudaStat3 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost);
cudaStat3 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C");
/* free resources */
// CHECK: if (d_A) hipFree(d_A);
if (d_A) cudaFree(d_A);
// CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC);
if (d_csrRowPtrC) cudaFree(d_csrRowPtrC);
// CHECK: if (d_csrColIndC) hipFree(d_csrColIndC);
if (d_csrColIndC) cudaFree(d_csrColIndC);
// CHECK: if (d_csrValC) hipFree(d_csrValC);
if (d_csrValC) cudaFree(d_csrValC);
if (csrRowPtrC) free(csrRowPtrC);
if (csrColIndC) free(csrColIndC);
if (csrValC) free(csrValC);
// CHECK: if (handle) hipsparseDestroy(handle);
if (handle) cusparseDestroy(handle);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: if (descrC) hipsparseDestroyMatDescr(descrC);
if (descrC) cusparseDestroyMatDescr(descrC);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+288
Просмотреть файл
@@ -0,0 +1,288 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
void printCsr(
int m,
int n,
int nnz,
// CHECK: const hipsparseMatDescr_t descrA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const char* name)
{
// CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1;
const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1;
printf("matrix %s is %d-by-%d, nnz=%d, base=%d, output base-1\n", name, m, n, nnz, base);
for (int row = 0; row < m; row++) {
const int start = csrRowPtrA[row] - base;
const int end = csrRowPtrA[row + 1] - base;
for (int colidx = start; colidx < end; colidx++) {
const int col = csrColIndA[colidx] - base;
const float Areg = csrValA[colidx];
printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg);
}
}
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t handle = NULL;
cusparseHandle_t handle = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseMatDescr_t descrA = NULL;
cusparseMatDescr_t descrA = NULL;
// CHECK: hipsparseMatDescr_t descrC = NULL;
cusparseMatDescr_t descrC = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
const int m = 4;
const int n = 4;
const int nnzA = 9;
/*
* | 1 0 2 -3 |
* | 0 4 0 0 |
* A = | 5 0 6 7 |
* | 0 8 0 9 |
*
*/
const int csrRowPtrA[m + 1] = { 1, 4, 5, 8, 10 };
const int csrColIndA[nnzA] = { 1, 3, 4, 2, 1, 3, 4, 2, 4 };
const float csrValA[nnzA] = { 1, 2, -3, 4, 5, 6, 7, 8, 9 };
int* csrRowPtrC = NULL;
int* csrColIndC = NULL;
float* csrValC = NULL;
int *d_csrRowPtrA = NULL;
int *d_csrColIndA = NULL;
float *d_csrValA = NULL;
int *d_csrRowPtrC = NULL;
int *d_csrColIndC = NULL;
float *d_csrValC = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
int nnzC = 0;
float threshold = 4.1; /* remove Aij <= 4.1 */
// float threshold = 0; /* remove zeros */
printf("example of pruneCsr2csr \n");
printf("prune |A(i,j)| <= threshold \n");
printf("threshold = %E \n", threshold);
/* step 1: create cusparse handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&handle);
status = cusparseCreate(&handle);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(handle, stream);
status = cusparseSetStream(handle, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 2: configuration of matrix A and C */
// CHECK: status = hipsparseCreateMatDescr(&descrA);
status = cusparseCreateMatDescr(&descrA);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* A is base-1*/
// CHECK: hipsparseSetMatIndexBase(descrA, HIPSPARSE_INDEX_BASE_ONE);
cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE);
// CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
// CHECK: status = hipsparseCreateMatDescr(&descrC);
status = cusparseCreateMatDescr(&descrC);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* C is base-0 */
// CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO);
cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO);
// CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL);
printCsr(m, n, nnzA, descrA, csrValA, csrRowPtrA, csrColIndA, "A");
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1));
cudaStat1 = cudaMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1));
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA);
cudaStat1 = cudaMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrValA, sizeof(float)*nnzA);
cudaStat1 = cudaMalloc((void**)&d_csrValA, sizeof(float)*nnzA);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
cudaStat1 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: query workspace */
// TODO: status = hipsparseSpruneCsr2csr_bufferSizeExt(
status = cusparseSpruneCsr2csr_bufferSizeExt(
handle,
m,
n,
nnzA,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
&threshold,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes (prune) = %lld \n", (long long)lworkInBytes);
// CHECK: if (NULL != d_work) { hipFree(d_work); }
if (NULL != d_work) { cudaFree(d_work); }
// cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 4: compute csrRowPtrC and nnzC */
// TODO: status = hipsparseSpruneCsr2csrNnz(
status = cusparseSpruneCsr2csrNnz(
handle,
m,
n,
nnzA,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
&threshold,
descrC,
d_csrRowPtrC,
&nnzC, /* host */
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printf("nnzC = %d\n", nnzC);
if (0 == nnzC) {
printf("C is empty \n");
return 0;
}
/* step 5: compute csrColIndC and csrValC */
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
cudaStat1 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// TODO: status = hipsparseSpruneCsr2csr(
status = cusparseSpruneCsr2csr(
handle,
m,
n,
nnzA,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
&threshold,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6: output C */
csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1));
csrColIndC = (int*)malloc(sizeof(int)*nnzC);
csrValC = (float*)malloc(sizeof(float)*nnzC);
assert(NULL != csrRowPtrC);
assert(NULL != csrColIndC);
assert(NULL != csrValC);
// CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C");
/* free resources */
// CHECK: if (d_csrRowPtrA) hipFree(d_csrRowPtrA);
if (d_csrRowPtrA) cudaFree(d_csrRowPtrA);
// CHECK: if (d_csrColIndA) hipFree(d_csrColIndA);
if (d_csrColIndA) cudaFree(d_csrColIndA);
// CHECK: if (d_csrValA) hipFree(d_csrValA);
if (d_csrValA) cudaFree(d_csrValA);
// CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC);
if (d_csrRowPtrC) cudaFree(d_csrRowPtrC);
// CHECK: if (d_csrColIndC) hipFree(d_csrColIndC);
if (d_csrColIndC) cudaFree(d_csrColIndC);
// CHECK: if (d_csrValC) hipFree(d_csrValC);
if (d_csrValC) cudaFree(d_csrValC);
if (csrRowPtrC) free(csrRowPtrC);
if (csrColIndC) free(csrColIndC);
if (csrValC) free(csrValC);
// CHECK: if (handle) hipsparseDestroy(handle);
if (handle) cusparseDestroy(handle);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: if (descrA) hipsparseDestroyMatDescr(descrA);
if (descrA) cusparseDestroyMatDescr(descrA);
// CHECK: if (descrC) hipsparseDestroyMatDescr(descrC);
if (descrC) cusparseDestroyMatDescr(descrC);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+269
Просмотреть файл
@@ -0,0 +1,269 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
void printMatrix(int m, int n, const float*A, int lda, const char* name)
{
for (int row = 0; row < m; row++) {
for (int col = 0; col < n; col++) {
float Areg = A[row + col * lda];
printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg);
}
}
}
void printCsr(
int m,
int n,
int nnz,
// CHECK: const hipsparseMatDescr_t descrA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const char* name)
{
// CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1;
const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1;
printf("matrix %s is %d-by-%d, nnz=%d, base=%d, output base-1\n", name, m, n, nnz, base);
for (int row = 0; row < m; row++) {
const int start = csrRowPtrA[row] - base;
const int end = csrRowPtrA[row + 1] - base;
for (int colidx = start; colidx < end; colidx++) {
const int col = csrColIndA[colidx] - base;
const float Areg = csrValA[colidx];
printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg);
}
}
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t handle = NULL;
cusparseHandle_t handle = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseMatDescr_t descrC = NULL;
cusparseMatDescr_t descrC = NULL;
pruneInfo_t info = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
// CHECK: hipError_t cudaStat2 = hipSuccess;
// CHECK: hipError_t cudaStat3 = hipSuccess;
// CHECK: hipError_t cudaStat4 = hipSuccess;
// CHECK: hipError_t cudaStat5 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
cudaError_t cudaStat2 = cudaSuccess;
cudaError_t cudaStat3 = cudaSuccess;
cudaError_t cudaStat4 = cudaSuccess;
cudaError_t cudaStat5 = cudaSuccess;
const int m = 4;
const int n = 4;
const int lda = m;
/*
* | 1 0 2 -3 |
* | 0 4 0 0 |
* A = | 5 0 6 7 |
* | 0 8 0 9 |
*
*/
const float A[lda*n] = { 1, 0, 5, 0, 0, 4, 0, 8, 2, 0, 6, 0, -3, 0, 7, 9 };
int* csrRowPtrC = NULL;
int* csrColIndC = NULL;
float* csrValC = NULL;
float *d_A = NULL;
int *d_csrRowPtrC = NULL;
int *d_csrColIndC = NULL;
float *d_csrValC = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
int nnzC = 0;
float percentage = 50; /* 50% of nnz */
printf("example of pruneDense2csrByPercentage \n");
printf("prune out %.1f percentage of A \n", percentage);
printMatrix(m, n, A, lda, "A");
/* step 1: create cusparse handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&handle);
status = cusparseCreate(&handle);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(handle, stream);
status = cusparseSetStream(handle, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// TODO: status = hipsparseCreatePruneInfo(&info);
status = cusparseCreatePruneInfo(&info);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 2: configuration of matrix C */
// CHECK: status = hipsparseCreateMatDescr(&descrC);
status = cusparseCreateMatDescr(&descrC);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO);
cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO);
// CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL);
// CHECK: cudaStat1 = hipMalloc((void**)&d_A, sizeof(float)*lda*n);
cudaStat1 = cudaMalloc((void**)&d_A, sizeof(float)*lda*n);
// CHECK: cudaStat2 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
cudaStat2 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
// CHECK: cudaStat1 = hipMemcpy(d_A, A, sizeof(float)*lda*n, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_A, A, sizeof(float)*lda*n, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: query workspace */
// TODO: status = hipsparseSpruneDense2csrByPercentage_bufferSizeExt(
status = cusparseSpruneDense2csrByPercentage_bufferSizeExt(
handle,
m,
n,
d_A,
lda,
percentage,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
info,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes = %lld \n", (long long)lworkInBytes);
// CHECK: if (NULL != d_work) { hipFree(d_work); }
if (NULL != d_work) { cudaFree(d_work); }
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 4: compute csrRowPtrC and nnzC */
// TODO: status = hipsparseSpruneDense2csrNnzByPercentage(
status = cusparseSpruneDense2csrNnzByPercentage(
handle,
m,
n,
d_A,
lda,
percentage,
descrC,
d_csrRowPtrC,
&nnzC, /* host */
info,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printf("nnzC = %d\n", nnzC);
if (0 == nnzC) {
printf("C is empty \n");
return 0;
}
/* step 5: compute csrColIndC and csrValC */
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
// CHECK: cudaStat2 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
cudaStat2 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
assert(cudaSuccess == cudaStat2);
// TODO: status = hipsparseSpruneDense2csrByPercentage(
status = cusparseSpruneDense2csrByPercentage(
handle,
m,
n,
d_A,
lda,
percentage,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
info,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 7: output C */
csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1));
csrColIndC = (int*)malloc(sizeof(int)*nnzC);
csrValC = (float*)malloc(sizeof(float)*nnzC);
assert(NULL != csrRowPtrC);
assert(NULL != csrColIndC);
assert(NULL != csrValC);
// CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost);
// CHECK: cudaStat2 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost);
cudaStat2 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: cudaStat3 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost);
cudaStat3 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
// CHECK: assert(hipSuccess == cudaStat2);
// CHECK: assert(hipSuccess == cudaStat3);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C");
/* free resources */
// CHECK: if (d_A) hipFree(d_A);
if (d_A) cudaFree(d_A);
// CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC);
if (d_csrRowPtrC) cudaFree(d_csrRowPtrC);
// CHECK: if (d_csrColIndC) hipFree(d_csrColIndC);
if (d_csrColIndC) cudaFree(d_csrColIndC);
// CHECK: if (d_csrValC) hipFree(d_csrValC);
if (d_csrValC) cudaFree(d_csrValC);
if (csrRowPtrC) free(csrRowPtrC);
if (csrColIndC) free(csrColIndC);
if (csrValC) free(csrValC);
// CHECK: if (handle) hipsparseDestroy(handle);
if (handle) cusparseDestroy(handle);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: if (descrC) hipsparseDestroyMatDescr(descrC);
if (descrC) cusparseDestroyMatDescr(descrC);
// TODO: if (info) hipsparseDestroyPruneInfo(info);
if (info) cusparseDestroyPruneInfo(info);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+302
Просмотреть файл
@@ -0,0 +1,302 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
void printCsr(
int m,
int n,
int nnz,
// CHECK: const hipsparseMatDescr_t descrA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const char* name)
{
// CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1;
const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1;
printf("matrix %s is %d-by-%d, nnz=%d, base=%d, output base-1\n", name, m, n, nnz, base);
for (int row = 0; row < m; row++) {
const int start = csrRowPtrA[row] - base;
const int end = csrRowPtrA[row + 1] - base;
for (int colidx = start; colidx < end; colidx++) {
const int col = csrColIndA[colidx] - base;
const float Areg = csrValA[colidx];
printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg);
}
}
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t handle = NULL;
cusparseHandle_t handle = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseMatDescr_t descrA = NULL;
cusparseMatDescr_t descrA = NULL;
// CHECK: hipsparseMatDescr_t descrC = NULL;
cusparseMatDescr_t descrC = NULL;
pruneInfo_t info = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
const int m = 4;
const int n = 4;
const int nnzA = 9;
/*
* | 1 0 2 -3 |
* | 0 4 0 0 |
* A = | 5 0 6 7 |
* | 0 8 0 9 |
*
*/
const int csrRowPtrA[m + 1] = { 1, 4, 5, 8, 10 };
const int csrColIndA[nnzA] = { 1, 3, 4, 2, 1, 3, 4, 2, 4 };
const float csrValA[nnzA] = { 1, 2, -3, 4, 5, 6, 7, 8, 9 };
int* csrRowPtrC = NULL;
int* csrColIndC = NULL;
float* csrValC = NULL;
int *d_csrRowPtrA = NULL;
int *d_csrColIndA = NULL;
float *d_csrValA = NULL;
int *d_csrRowPtrC = NULL;
int *d_csrColIndC = NULL;
float *d_csrValC = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
int nnzC = 0;
float percentage = 20; /* remove 20% of nonzeros */
printf("example of pruneCsr2csrByPercentage \n");
printf("prune %.1f percent of nonzeros \n", percentage);
/* step 1: create cusparse handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&handle);
status = cusparseCreate(&handle);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(handle, stream);
status = cusparseSetStream(handle, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// TODO: status = hipsparseCreatePruneInfo(&info);
status = cusparseCreatePruneInfo(&info);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 2: configuration of matrix C */
// CHECK: status = hipsparseCreateMatDescr(&descrA);
status = cusparseCreateMatDescr(&descrA);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* A is base-1*/
// CHECK: hipsparseSetMatIndexBase(descrA, HIPSPARSE_INDEX_BASE_ONE);
cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE);
// CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
// CHECK: status = hipsparseCreateMatDescr(&descrC);
status = cusparseCreateMatDescr(&descrC);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* C is base-0 */
// CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO);
cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO);
// CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL);
printCsr(m, n, nnzA, descrA, csrValA, csrRowPtrA, csrColIndA, "A");
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1));
cudaStat1 = cudaMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1));
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA);
cudaStat1 = cudaMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrValA, sizeof(float)*nnzA);
cudaStat1 = cudaMalloc((void**)&d_csrValA, sizeof(float)*nnzA);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
cudaStat1 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1));
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: query workspace */
// TODO: status = hipsparseSpruneCsr2csrByPercentage_bufferSizeExt(
status = cusparseSpruneCsr2csrByPercentage_bufferSizeExt(
handle,
m,
n,
nnzA,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
percentage,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
info,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes = %lld \n", (long long)lworkInBytes);
// CHECK: if (NULL != d_work) { hipFree(d_work); }
if (NULL != d_work) { cudaFree(d_work); }
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 4: compute csrRowPtrC and nnzC */
// TODO: status = hipsparseSpruneCsr2csrNnzByPercentage(
status = cusparseSpruneCsr2csrNnzByPercentage(
handle,
m,
n,
nnzA,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
percentage,
descrC,
d_csrRowPtrC,
&nnzC, /* host */
info,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printf("nnzC = %d\n", nnzC);
if (0 == nnzC) {
printf("C is empty \n");
return 0;
}
/* step 5: compute csrColIndC and csrValC */
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
cudaStat1 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// TODO: status = hipsparseSpruneCsr2csrByPercentage(
status = cusparseSpruneCsr2csrByPercentage(
handle,
m,
n,
nnzA,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
percentage,
descrC,
d_csrValC,
d_csrRowPtrC,
d_csrColIndC,
info,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6: output C */
csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1));
csrColIndC = (int*)malloc(sizeof(int)*nnzC);
csrValC = (float*)malloc(sizeof(float)*nnzC);
assert(NULL != csrRowPtrC);
assert(NULL != csrColIndC);
assert(NULL != csrValC);
// CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C");
/* free resources */
// CHECK: if (d_csrRowPtrA) hipFree(d_csrRowPtrA);
if (d_csrRowPtrA) cudaFree(d_csrRowPtrA);
// CHECK: if (d_csrColIndA) hipFree(d_csrColIndA);
if (d_csrColIndA) cudaFree(d_csrColIndA);
// CHECK: if (d_csrValA) hipFree(d_csrValA);
if (d_csrValA) cudaFree(d_csrValA);
// CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC);
if (d_csrRowPtrC) cudaFree(d_csrRowPtrC);
// CHECK: if (d_csrColIndC) hipFree(d_csrColIndC);
if (d_csrColIndC) cudaFree(d_csrColIndC);
// CHECK: if (d_csrValC) hipFree(d_csrValC);
if (d_csrValC) cudaFree(d_csrValC);
if (csrRowPtrC) free(csrRowPtrC);
if (csrColIndC) free(csrColIndC);
if (csrValC) free(csrValC);
// CHECK: if (handle) hipsparseDestroy(handle);
if (handle) cusparseDestroy(handle);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: if (descrA) hipsparseDestroyMatDescr(descrA);
if (descrA) cusparseDestroyMatDescr(descrA);
// CHECK: if (descrC) hipsparseDestroyMatDescr(descrC);
if (descrC) cusparseDestroyMatDescr(descrC);
// TODO: if (info) hipsparseDestroyPruneInfo(info);
if (info) cusparseDestroyPruneInfo(info);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+413
Просмотреть файл
@@ -0,0 +1,413 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
// CHECK: #include <hipblas.h>
#include <cublas_v2.h>
// NOTE: CUDA 10.0
/*
* compute | b - A*x|_inf
*/
void residaul_eval(
int n,
const float *dl,
const float *d,
const float *du,
const float *b,
const float *x,
float *r_nrminf_ptr)
{
float r_nrminf = 0;
for (int i = 0; i < n; i++) {
float dot = 0;
if (i > 0) {
dot += dl[i] * x[i - 1];
}
dot += d[i] * x[i];
if (i < (n - 1)) {
dot += du[i] * x[i + 1];
}
float ri = b[i] - dot;
r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri);
}
*r_nrminf_ptr = r_nrminf;
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t cusparseH = NULL;
cusparseHandle_t cusparseH = NULL;
// CHECK: hipblasHandle_t cublasH = NULL;
cublasHandle_t cublasH = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS;
cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
const int n = 3;
const int batchSize = 2;
/*
* | 1 6 0 | | 1 | | -0.603960 |
* A1 =| 4 2 7 |, b1 = | 2 |, x1 = | 0.267327 |
* | 0 5 3 | | 3 | | 0.554455 |
*
* | 8 13 0 | | 4 | | -0.063291 |
* A2 =| 11 9 14 |, b2 = | 5 |, x2 = | 0.346641 |
* | 0 12 10 | | 6 | | 0.184031 |
*/
/*
* A = (dl, d, du), B and X are in aggregate format
*/
const float dl[n * batchSize] = { 0, 4, 5, 0, 11, 12 };
const float d[n * batchSize] = { 1, 2, 3, 8, 9, 10 };
const float du[n * batchSize] = { 6, 7, 0, 13, 14, 0 };
const float B[n * batchSize] = { 1, 2, 3, 4, 5, 6 };
float X[n * batchSize]; /* Xj = Aj \ Bj */
/* device memory
* (d_dl0, d_d0, d_du0) is aggregate format
* (d_dl, d_d, d_du) is interleaved format
*/
float *d_dl0 = NULL;
float *d_d0 = NULL;
float *d_du0 = NULL;
float *d_dl = NULL;
float *d_d = NULL;
float *d_du = NULL;
float *d_B = NULL;
float *d_X = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
/*
* algo = 0: cuThomas (unstable)
* algo = 1: LU with pivoting (stable)
* algo = 2: QR (stable)
*/
const int algo = 2;
const float h_one = 1;
const float h_zero = 0;
printf("example of gtsv (interleaved format) \n");
printf("choose algo = 0,1,2 to select different algorithms \n");
printf("n = %d, batchSize = %d, algo = %d \n", n, batchSize, algo);
/* step 1: create cusparse/cublas handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&cusparseH);
status = cusparseCreate(&cusparseH);
//CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(cusparseH, stream);
status = cusparseSetStream(cusparseH, stream);
//CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cublasStat = hipblasCreate(&cublasH);
cublasStat = cublasCreate(&cublasH);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: cublasStat = hipblasSetStream(cublasH, stream);
cublasStat = cublasSetStream(cublasH, stream);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* step 2: allocate device memory */
// CHECK: cudaStat1 = hipMalloc((void**)&d_dl0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dl0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_d0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_d0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_du0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_du0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_dl, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dl, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_d, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_d, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_du, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_du, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_X, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_X, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: prepare data in device, interleaved format */
// CHECK: cudaStat1 = hipMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_d0, d, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_d0, d, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_du0, du, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_du0, du, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
/* convert dl to interleaved format
* dl = transpose(dl0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of dl */
n, /* number of columns of dl */
&h_one,
d_dl0, /* dl0 is n-by-batchSize */
n, /* leading dimension of dl0 */
&h_zero,
NULL,
n, /* don't cae */
d_dl, /* dl is batchSize-by-n */
batchSize /* leading dimension of dl */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert d to interleaved format
* d = transpose(d0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of d */
n, /* number of columns of d */
&h_one,
d_d0, /* d0 is n-by-batchSize */
n, /* leading dimension of d0 */
&h_zero,
NULL,
n, /* don't cae */
d_d, /* d is batchSize-by-n */
batchSize /* leading dimension of d */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert du to interleaved format
* du = transpose(du0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of du */
n, /* number of columns of du */
&h_one,
d_du0, /* du0 is n-by-batchSize */
n, /* leading dimension of du0 */
&h_zero,
NULL,
n, /* don't cae */
d_du, /* du is batchSize-by-n */
batchSize /* leading dimension of du */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert B to interleaved format
* X = transpose(B)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of X */
n, /* number of columns of X */
&h_one,
d_B, /* B is n-by-batchSize */
n, /* leading dimension of B */
&h_zero,
NULL,
n, /* don't cae */
d_X, /* X is batchSize-by-n */
batchSize /* leading dimension of X */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* step 4: prepare workspace */
// NOTE: CUDA 10.0
// TODO: status = hipsparseSgtsvInterleavedBatch_bufferSizeExt(
status = cusparseSgtsvInterleavedBatch_bufferSizeExt(
cusparseH,
algo,
n,
d_dl,
d_d,
d_du,
d_X,
batchSize,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes = %lld \n", (long long)lworkInBytes);
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 5: solve Aj*xj = bj */
// NOTE: CUDA 10.0
// TODO: status = hipsparseSgtsvInterleavedBatch(
status = cusparseSgtsvInterleavedBatch(
cusparseH,
algo,
n,
d_dl,
d_d,
d_du,
d_X,
batchSize,
d_work);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6: convert X back to aggregate format */
/* B = transpose(X) */
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
n, /* number of rows of B */
batchSize, /* number of columns of B */
&h_one,
d_X, /* X is batchSize-by-n */
batchSize, /* leading dimension of X */
&h_zero,
NULL,
n, /* don't cae */
d_B, /* B is n-by-batchSize */
n /* leading dimension of B */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
/* step 7: residual evaluation */
// CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*batchSize, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*batchSize, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
printf("==== x1 = inv(A1)*b1 \n");
for (int j = 0; j < n; j++) {
printf("x1[%d] = %f\n", j, X[j]);
}
float r1_nrminf;
residaul_eval(
n,
dl,
d,
du,
B,
X,
&r1_nrminf
);
printf("|b1 - A1*x1| = %E\n", r1_nrminf);
printf("\n==== x2 = inv(A2)*b2 \n");
for (int j = 0; j < n; j++) {
printf("x2[%d] = %f\n", j, X[n + j]);
}
float r2_nrminf;
residaul_eval(
n,
dl + n,
d + n,
du + n,
B + n,
X + n,
&r2_nrminf
);
printf("|b2 - A2*x2| = %E\n", r2_nrminf);
/* free resources */
// CHECK: if (d_dl0) hipFree(d_dl0);
if (d_dl0) cudaFree(d_dl0);
// CHECK: if (d_d0) hipFree(d_d0);
if (d_d0) cudaFree(d_d0);
// CHECK: if (d_du0) hipFree(d_du0);
if (d_du0) cudaFree(d_du0);
// CHECK: if (d_dl) hipFree(d_dl);
if (d_dl) cudaFree(d_dl);
// CHECK: if (d_d) hipFree(d_d);
if (d_d) cudaFree(d_d);
// CHECK: if (d_du) hipFree(d_du);
if (d_du) cudaFree(d_du);
// CHECK: if (d_B) hipFree(d_B);
if (d_B) cudaFree(d_B);
// CHECK: if (d_X) hipFree(d_X);
if (d_X) cudaFree(d_X);
// CHECK: if (cusparseH) hipsparseDestroy(cusparseH);
if (cusparseH) cusparseDestroy(cusparseH);
// CHECK: if (cublasH) hipblasDestroy(cublasH);
if (cublasH) cublasDestroy(cublasH);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+414
Просмотреть файл
@@ -0,0 +1,414 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
// CHECK: #include <hipblas.h>
#include <cublas_v2.h>
// NOTE: CUDA 10.0
/*
* compute | b - A*x|_inf
*/
void residaul_eval(
int n,
const float *dl,
const float *d,
const float *du,
const float *b,
const float *x,
float *r_nrminf_ptr)
{
float r_nrminf = 0;
for (int i = 0; i < n; i++) {
float dot = 0;
if (i > 0) {
dot += dl[i] * x[i - 1];
}
dot += d[i] * x[i];
if (i < (n - 1)) {
dot += du[i] * x[i + 1];
}
float ri = b[i] - dot;
r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri);
}
*r_nrminf_ptr = r_nrminf;
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t cusparseH = NULL;
cusparseHandle_t cusparseH = NULL;
// CHECK: hipblasHandle_t cublasH = NULL;
cublasHandle_t cublasH = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS;
cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
const int n = 3;
const int batchSize = 2;
/*
* | 1 6 0 | | 1 | | -0.603960 |
* A1 =| 4 2 7 |, b1 = | 2 |, x1 = | 0.267327 |
* | 0 5 3 | | 3 | | 0.554455 |
*
* | 8 13 0 | | 4 | | -0.063291 |
* A2 =| 11 9 14 |, b2 = | 5 |, x2 = | 0.346641 |
* | 0 12 10 | | 6 | | 0.184031 |
*/
/*
* A = (dl, d, du), B and X are in aggregate format
*/
const float dl[n * batchSize] = { 0, 4, 5, 0, 11, 12 };
const float d[n * batchSize] = { 1, 2, 3, 8, 9, 10 };
const float du[n * batchSize] = { 6, 7, 0, 13, 14, 0 };
const float B[n * batchSize] = { 1, 2, 3, 4, 5, 6 };
float X[n * batchSize]; /* Xj = Aj \ Bj */
/* device memory
* (d_dl0, d_d0, d_du0) is aggregate format
* (d_dl, d_d, d_du) is interleaved format
*/
float *d_dl0 = NULL;
float *d_d0 = NULL;
float *d_du0 = NULL;
float *d_dl = NULL;
float *d_d = NULL;
float *d_du = NULL;
float *d_B = NULL;
float *d_X = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
/*
* algo = 0: cuThomas (unstable)
* algo = 1: LU with pivoting (stable)
* algo = 2: QR (stable)
*/
const int algo = 2;
const float h_one = 1;
const float h_zero = 0;
printf("example of gtsv (interleaved format) \n");
printf("choose algo = 0,1,2 to select different algorithms \n");
printf("n = %d, batchSize = %d, algo = %d \n", n, batchSize, algo);
/* step 1: create cusparse/cublas handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&cusparseH);
status = cusparseCreate(&cusparseH);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(cusparseH, stream);
status = cusparseSetStream(cusparseH, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cublasStat = hipblasCreate(&cublasH);
cublasStat = cublasCreate(&cublasH);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: cublasStat = hipblasSetStream(cublasH, stream);
cublasStat = cublasSetStream(cublasH, stream);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* step 2: allocate device memory */
// CHECK: cudaStat1 = hipMalloc((void**)&d_dl0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dl0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_d0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_d0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_du0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_du0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_dl, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dl, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_d, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_d, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_du, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_du, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_X, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_X, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: prepare data in device, interleaved format */
// CHECK: cudaStat1 = hipMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_d0, d, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_d0, d, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_du0, du, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_du0, du, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
/* convert dl to interleaved format
* dl = transpose(dl0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of dl */
n, /* number of columns of dl */
&h_one,
d_dl0, /* dl0 is n-by-batchSize */
n, /* leading dimension of dl0 */
&h_zero,
NULL,
n, /* don't care */
d_dl, /* dl is batchSize-by-n */
batchSize /* leading dimension of dl */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert d to interleaved format
* d = transpose(d0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T
// CHECK: HIPBLAS_OP_T
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of d */
n, /* number of columns of d */
&h_one,
d_d0, /* d0 is n-by-batchSize */
n, /* leading dimension of d0 */
&h_zero,
NULL,
n, /* don't cae */
d_d, /* d is batchSize-by-n */
batchSize /* leading dimension of d */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert du to interleaved format
* du = transpose(du0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T
// CHECK: HIPBLAS_OP_T
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of du */
n, /* number of columns of du */
&h_one,
d_du0, /* du0 is n-by-batchSize */
n, /* leading dimension of du0 */
&h_zero,
NULL,
n, /* don't cae */
d_du, /* du is batchSize-by-n */
batchSize /* leading dimension of du */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert B to interleaved format
* X = transpose(B)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T
// CHECK: HIPBLAS_OP_T
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of X */
n, /* number of columns of X */
&h_one,
d_B, /* B is n-by-batchSize */
n, /* leading dimension of B */
&h_zero,
NULL,
n, /* don't cae */
d_X, /* X is batchSize-by-n */
batchSize /* leading dimension of X */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* step 4: prepare workspace */
// NOTE: CUDA 10.0
// TODO: status = hipsparseSgtsvInterleavedBatch_bufferSizeExt(
status = cusparseSgtsvInterleavedBatch_bufferSizeExt(
cusparseH,
algo,
n,
d_dl,
d_d,
d_du,
d_X,
batchSize,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes = %lld \n", (long long)lworkInBytes);
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 5: solve Aj*xj = bj */
// NOTE: CUDA 10.0
// TODO: status = hipsparseSgtsvInterleavedBatch(
status = cusparseSgtsvInterleavedBatch(
cusparseH,
algo,
n,
d_dl,
d_d,
d_du,
d_X,
batchSize,
d_work);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6: convert X back to aggregate format */
/* B = transpose(X) */
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T
// CHECK: HIPBLAS_OP_T
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
n, /* number of rows of B */
batchSize, /* number of columns of B */
&h_one,
d_X, /* X is batchSize-by-n */
batchSize, /* leading dimension of X */
&h_zero,
NULL,
n, /* don't cae */
d_B, /* B is n-by-batchSize */
n /* leading dimension of B */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
/* step 7: residual evaluation */
// CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*batchSize, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*batchSize, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
printf("==== x1 = inv(A1)*b1 \n");
for (int j = 0; j < n; j++) {
printf("x1[%d] = %f\n", j, X[j]);
}
float r1_nrminf;
residaul_eval(
n,
dl,
d,
du,
B,
X,
&r1_nrminf
);
printf("|b1 - A1*x1| = %E\n", r1_nrminf);
printf("\n==== x2 = inv(A2)*b2 \n");
for (int j = 0; j < n; j++) {
printf("x2[%d] = %f\n", j, X[n + j]);
}
float r2_nrminf;
residaul_eval(
n,
dl + n,
d + n,
du + n,
B + n,
X + n,
&r2_nrminf
);
printf("|b2 - A2*x2| = %E\n", r2_nrminf);
/* free resources */
// CHECK: if (d_dl0) hipFree(d_dl0);
if (d_dl0) cudaFree(d_dl0);
// CHECK: if (d_d0) hipFree(d_d0);
if (d_d0) cudaFree(d_d0);
// CHECK: if (d_du0) hipFree(d_du0);
if (d_du0) cudaFree(d_du0);
// CHECK: if (d_dl) hipFree(d_dl);
if (d_dl) cudaFree(d_dl);
// CHECK: if (d_d) hipFree(d_d);
if (d_d) cudaFree(d_d);
// CHECK: if (d_du) hipFree(d_du);
if (d_du) cudaFree(d_du);
// CHECK: if (d_B) hipFree(d_B);
if (d_B) cudaFree(d_B);
// CHECK: if (d_X) hipFree(d_X);
if (d_X) cudaFree(d_X);
// CHECK: if (cusparseH) hipsparseDestroy(cusparseH);
if (cusparseH) cusparseDestroy(cusparseH);
// CHECK: if (cublasH) hipblasDestroy(cublasH);
if (cublasH) cublasDestroy(cublasH);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+507
Просмотреть файл
@@ -0,0 +1,507 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
// CHECK: #include <hipblas.h>
#include <cublas_v2.h>
// NOTE: CUDA 10.0
/*
* compute | b - A*x|_inf
*/
void residaul_eval(
int n,
const float *ds,
const float *dl,
const float *d,
const float *du,
const float *dw,
const float *b,
const float *x,
float *r_nrminf_ptr)
{
float r_nrminf = 0;
for (int i = 0; i < n; i++) {
float dot = 0;
if (i > 1) {
dot += ds[i] * x[i - 2];
}
if (i > 0) {
dot += dl[i] * x[i - 1];
}
dot += d[i] * x[i];
if (i < (n - 1)) {
dot += du[i] * x[i + 1];
}
if (i < (n - 2)) {
dot += dw[i] * x[i + 2];
}
float ri = b[i] - dot;
r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri);
}
*r_nrminf_ptr = r_nrminf;
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t cusparseH = NULL;
cusparseHandle_t cusparseH = NULL;
// CHECK: hipblasHandle_t cublasH = NULL;
cublasHandle_t cublasH = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS;
cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
const int n = 4;
const int batchSize = 2;
/*
* | 1 8 13 0 | | 1 | | -0.0592 |
* A1 =| 5 2 9 14 |, b1 = | 2 |, x1 = | 0.3428 |
* | 11 6 3 10 | | 3 | | -0.1295 |
* | 0 12 7 4 | | 4 | | 0.1982 |
*
* | 15 22 27 0 | | 5 | | -0.0012 |
* A2 =| 19 16 23 28 |, b2 = | 6 |, x2 = | 0.2792 |
* | 25 20 17 24 | | 7 | | -0.0416 |
* | 0 26 21 18 | | 8 | | 0.0898 |
*/
/*
* A = (ds, dl, d, du, dw), B and X are in aggregate format
*/
const float ds[n * batchSize] = { 0, 0, 11, 12, 0, 0, 25, 26 };
const float dl[n * batchSize] = { 0, 5, 6, 7, 0, 19, 20, 21 };
const float d[n * batchSize] = { 1, 2, 3, 4, 15, 16, 17, 18 };
const float du[n * batchSize] = { 8, 9, 10, 0, 22, 23, 24, 0 };
const float dw[n * batchSize] = { 13,14, 0, 0, 27, 28, 0, 0 };
const float B[n * batchSize] = { 1, 2, 3, 4, 5, 6, 7, 8 };
float X[n * batchSize]; /* Xj = Aj \ Bj */
/* device memory
* (d_ds0, d_dl0, d_d0, d_du0, d_dw0) is aggregate format
* (d_ds, d_dl, d_d, d_du, d_dw) is interleaved format
*/
float *d_ds0 = NULL;
float *d_dl0 = NULL;
float *d_d0 = NULL;
float *d_du0 = NULL;
float *d_dw0 = NULL;
float *d_ds = NULL;
float *d_dl = NULL;
float *d_d = NULL;
float *d_du = NULL;
float *d_dw = NULL;
float *d_B = NULL;
float *d_X = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
const float h_one = 1;
const float h_zero = 0;
int algo = 0; /* QR factorization */
printf("example of gpsv (interleaved format) \n");
printf("n = %d, batchSize = %d\n", n, batchSize);
/* step 1: create cusparse/cublas handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&cusparseH);
status = cusparseCreate(&cusparseH);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: status = hipsparseSetStream(cusparseH, stream);
status = cusparseSetStream(cusparseH, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cublasStat = hipblasCreate(&cublasH);
cublasStat = cublasCreate(cublasH);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: cublasStat = hipblasSetStream(cublasH, stream);
cublasStat = cublasSetStream(cublasH, stream);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* step 2: allocate device memory */
// CHECK: cudaStat1 = hipMalloc((void**)&d_ds0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_ds0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_dl0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dl0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_d0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_d0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_du0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_du0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_dw0, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dw0, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_ds, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_ds, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_dl, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dl, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_d, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_d, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_du, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_du, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_dw, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_dw, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_X, sizeof(float)*n*batchSize);
cudaStat1 = cudaMalloc((void**)&d_X, sizeof(float)*n*batchSize);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: prepare data in device, interleaved format */
// CHECK: cudaStat1 = hipMemcpy(d_ds0, ds, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_ds0, ds, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_d0, d, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_d0, d, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_du0, du, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_du0, du, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_dw0, dw, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_dw0, dw, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*batchSize, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
/* convert ds to interleaved format
* ds = transpose(ds0) */
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of ds */
n, /* number of columns of ds */
&h_one,
d_ds0, /* ds0 is n-by-batchSize */
n, /* leading dimension of ds0 */
&h_zero,
NULL,
n, /* don't cae */
d_ds, /* ds is batchSize-by-n */
batchSize); /* leading dimension of ds */
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert dl to interleaved format
* dl = transpose(dl0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of dl */
n, /* number of columns of dl */
&h_one,
d_dl0, /* dl0 is n-by-batchSize */
n, /* leading dimension of dl0 */
&h_zero,
NULL,
n, /* don't cae */
d_dl, /* dl is batchSize-by-n */
batchSize /* leading dimension of dl */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert d to interleaved format
* d = transpose(d0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of d */
n, /* number of columns of d */
&h_one,
d_d0, /* d0 is n-by-batchSize */
n, /* leading dimension of d0 */
&h_zero,
NULL,
n, /* don't cae */
d_d, /* d is batchSize-by-n */
batchSize /* leading dimension of d */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert du to interleaved format
* du = transpose(du0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of du */
n, /* number of columns of du */
&h_one,
d_du0, /* du0 is n-by-batchSize */
n, /* leading dimension of du0 */
&h_zero,
NULL,
n, /* don't cae */
d_du, /* du is batchSize-by-n */
batchSize /* leading dimension of du */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert dw to interleaved format
* dw = transpose(dw0)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of dw */
n, /* number of columns of dw */
&h_one,
d_dw0, /* dw0 is n-by-batchSize */
n, /* leading dimension of dw0 */
&h_zero,
NULL,
n, /* don't cae */
d_dw, /* dw is batchSize-by-n */
batchSize /* leading dimension of dw */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* convert B to interleaved format
* X = transpose(B)
*/
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
batchSize, /* number of rows of X */
n, /* number of columns of X */
&h_one,
d_B, /* B is n-by-batchSize */
n, /* leading dimension of B */
&h_zero,
NULL,
n, /* don't cae */
d_X, /* X is batchSize-by-n */
batchSize /* leading dimension of X */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
/* step 4: prepare workspace */
// NOTE: CUDA 10.0
// TODO: status = hipsparseSgpsvInterleavedBatch_bufferSizeExt(
status = cusparseSgpsvInterleavedBatch_bufferSizeExt(
cusparseH,
algo,
n,
d_ds,
d_dl,
d_d,
d_du,
d_dw,
d_X,
batchSize,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes = %lld \n", (long long)lworkInBytes);
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 5: solve Aj*xj = bj */
// NOTE: CUDA 10.0
// TODO: status = hipsparseSgpsvInterleavedBatch(
status = cusparseSgpsvInterleavedBatch(
cusparseH,
algo,
n,
d_ds,
d_dl,
d_d,
d_du,
d_dw,
d_X,
batchSize,
d_work);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6: convert X back to aggregate format */
/* B = transpose(X) */
// CHECK: cublasStat = hipblasSgeam(
// CHECK: HIPBLAS_OP_T,
// CHECK: HIPBLAS_OP_T,
cublasStat = cublasSgeam(
cublasH,
CUBLAS_OP_T, /* transa */
CUBLAS_OP_T, /* transb, don't care */
n, /* number of rows of B */
batchSize, /* number of columns of B */
&h_one,
d_X, /* X is batchSize-by-n */
batchSize, /* leading dimension of X */
&h_zero,
NULL,
n, /* don't cae */
d_B, /* B is n-by-batchSize */
n /* leading dimension of B */
);
// CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat);
assert(CUBLAS_STATUS_SUCCESS == cublasStat);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
/* step 7: residual evaluation */
// CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*batchSize, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*batchSize, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
printf("==== x1 = inv(A1)*b1 \n");
for (int j = 0; j < n; j++) {
printf("x1[%d] = %f\n", j, X[j]);
}
float r1_nrminf;
residaul_eval(
n,
ds,
dl,
d,
du,
dw,
B,
X,
&r1_nrminf
);
printf("|b1 - A1*x1| = %E\n", r1_nrminf);
printf("\n==== x2 = inv(A2)*b2 \n");
for (int j = 0; j < n; j++) {
printf("x2[%d] = %f\n", j, X[n + j]);
}
float r2_nrminf;
residaul_eval(
n,
ds + n,
dl + n,
d + n,
du + n,
dw + n,
B + n,
X + n,
&r2_nrminf
);
printf("|b2 - A2*x2| = %E\n", r2_nrminf);
/* free resources */
// CHECK: if (d_ds0) hipFree(d_ds0);
if (d_ds0) cudaFree(d_ds0);
// CHECK: if (d_dl0) hipFree(d_dl0);
if (d_dl0) cudaFree(d_dl0);
// CHECK: if (d_d0) hipFree(d_d0);
if (d_d0) cudaFree(d_d0);
// CHECK: if (d_du0) hipFree(d_du0);
if (d_du0) cudaFree(d_du0);
// CHECK: if (d_dw0) hipFree(d_dw0);
if (d_dw0) cudaFree(d_dw0);
// CHECK: if (d_ds) hipFree(d_ds);
if (d_ds) cudaFree(d_ds);
// CHECK: if (d_dl) hipFree(d_dl);
if (d_dl) cudaFree(d_dl);
// CHECK: if (d_d) hipFree(d_d);
if (d_d) cudaFree(d_d);
// CHECK: if (d_du) hipFree(d_du);
if (d_du) cudaFree(d_du);
// CHECK: if (d_dw) hipFree(d_dw);
if (d_dw) cudaFree(d_dw);
// CHECK: if (d_B) hipFree(d_B);
if (d_B) cudaFree(d_B);
// CHECK: if (d_X) hipFree(d_X);
if (d_X) cudaFree(d_X);
// CHECK: if (cusparseH) hipsparseDestroy(cusparseH);
if (cusparseH) cusparseDestroy(cusparseH);
// CHECK: if (cublasH) hipblasDestroy(cublasH);
if (cublasH) cublasDestroy(cublasH);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
+327
Просмотреть файл
@@ -0,0 +1,327 @@
// RUN: %run_test hipify "%s" "%t" %cuda_args
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CHECK: #include <hip/hip_runtime.h>
#include <cuda_runtime.h>
// CHECK: #include <hipsparse.h>
#include <cusparse.h>
// NOTE: CUDA 10.0
/* compute | b - A*x|_inf */
void residaul_eval(
int n,
// CHECK: const hipsparseMatDescr_t descrA,
const cusparseMatDescr_t descrA,
const float *csrVal,
const int *csrRowPtr,
const int *csrColInd,
const float *b,
const float *x,
float *r_nrminf_ptr)
{
// CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1;
const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1;
// CHECK: const int lower = (HIPSPARSE_FILL_MODE_LOWER == hipsparseGetMatFillMode(descrA)) ? 1 : 0;
const int lower = (CUSPARSE_FILL_MODE_LOWER == cusparseGetMatFillMode(descrA)) ? 1 : 0;
// CHECK: const int unit = (HIPSPARSE_DIAG_TYPE_UNIT == hipsparseGetMatDiagType(descrA)) ? 1 : 0;
const int unit = (CUSPARSE_DIAG_TYPE_UNIT == cusparseGetMatDiagType(descrA)) ? 1 : 0;
float r_nrminf = 0;
for (int row = 0; row < n; row++) {
const int start = csrRowPtr[row] - base;
const int end = csrRowPtr[row + 1] - base;
float dot = 0;
for (int colidx = start; colidx < end; colidx++) {
const int col = csrColInd[colidx] - base;
float Aij = csrVal[colidx];
float xj = x[col];
if ((row == col) && unit) {
Aij = 1.0;
}
int valid = (row >= col) && lower ||
(row <= col) && !lower;
if (valid) {
dot += Aij * xj;
}
}
float ri = b[row] - dot;
r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri);
}
*r_nrminf_ptr = r_nrminf;
}
int main(int argc, char*argv[])
{
// CHECK: hipsparseHandle_t handle = NULL;
cusparseHandle_t handle = NULL;
// CHECK: hipStream_t stream = NULL;
cudaStream_t stream = NULL;
// CHECK: hipsparseMatDescr_t descrA = NULL;
cusparseMatDescr_t descrA = NULL;
// NOTE: CUDA 10.0
// TODO: csrsm2Info_t info = NULL;
csrsm2Info_t info = NULL;
// CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS;
cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS;
// CHECK: hipError_t cudaStat1 = hipSuccess;
cudaError_t cudaStat1 = cudaSuccess;
const int nrhs = 2;
const int n = 4;
const int nnzA = 9;
// CHECK: const hipsparseSolvePolicy_t policy = HIPSPARSE_SOLVE_POLICY_NO_LEVEL;
const cusparseSolvePolicy_t policy = CUSPARSE_SOLVE_POLICY_NO_LEVEL;
const float h_one = 1.0;
/*
* | 1 0 2 -3 |
* | 0 4 0 0 |
* A = | 5 0 6 7 |
* | 0 8 0 9 |
*
* Regard A as a lower triangle matrix L with non-unit diagonal.
* | 1 5 | | 1 5 |
* Given B = | 2 6 |, X = L \ B = | 0.5 1.5 |
* | 3 7 | | -0.3333 -3 |
* | 4 8 | | 0 -0.4444 |
*/
const int csrRowPtrA[n + 1] = { 1, 4, 5, 8, 10 };
const int csrColIndA[nnzA] = { 1, 3, 4, 2, 1, 3, 4, 2, 4 };
const float csrValA[nnzA] = { 1, 2, -3, 4, 5, 6, 7, 8, 9 };
const float B[n*nrhs] = { 1,2,3,4,5,6,7,8 };
float X[n*nrhs];
int *d_csrRowPtrA = NULL;
int *d_csrColIndA = NULL;
float *d_csrValA = NULL;
float *d_B = NULL;
size_t lworkInBytes = 0;
char *d_work = NULL;
const int algo = 0; /* non-block version */
printf("example of csrsm2 \n");
/* step 1: create cusparse handle, bind a stream */
// CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking);
cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: status = hipsparseCreate(&handle);
status = cusparseCreate(&handle);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
status = cusparseSetStream(handle, stream);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// NOTE: CUDA 10.0
// TODO: status = hipsparseCreateCsrsm2Info(&info);
status = cusparseCreateCsrsm2Info(&info);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 2: configuration of matrix A */
status = cusparseCreateMatDescr(&descrA);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* A is base-1*/
// CHECK: hipsparseSetMatIndexBase(descrA, HIPSPARSE_INDEX_BASE_ONE);
cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE);
// CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
/* A is lower triangle */
// CHECK: hipsparseSetMatFillMode(descrA, HIPSPARSE_FILL_MODE_LOWER);
cusparseSetMatFillMode(descrA, CUSPARSE_FILL_MODE_LOWER);
/* A has non unit diagonal */
// CHECK: hipsparseSetMatDiagType(descrA, HIPSPARSE_DIAG_TYPE_NON_UNIT);
cusparseSetMatDiagType(descrA, CUSPARSE_DIAG_TYPE_NON_UNIT);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrA, sizeof(int)*(n + 1));
cudaStat1 = cudaMalloc((void**)&d_csrRowPtrA, sizeof(int)*(n + 1));
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA);
cudaStat1 = cudaMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_csrValA, sizeof(float)*nnzA);
cudaStat1 = cudaMalloc((void**)&d_csrValA, sizeof(float)*nnzA);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*nrhs);
cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*nrhs);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(n + 1), hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(n + 1), cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*nrhs, hipMemcpyHostToDevice);
cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*nrhs, cudaMemcpyHostToDevice);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 3: query workspace */
// NOTE: CUDA 10.0
// TODO: status = hipsparseScsrsm2_bufferSizeExt(
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE,
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE,
status = cusparseScsrsm2_bufferSizeExt(
handle,
algo,
CUSPARSE_OPERATION_NON_TRANSPOSE, /* transA */
CUSPARSE_OPERATION_NON_TRANSPOSE, /* transB */
n,
nrhs,
nnzA,
&h_one,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
d_B,
n, /* ldb */
info,
policy,
&lworkInBytes);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
printf("lworkInBytes = %lld \n", (long long)lworkInBytes);
// CHECK: if (NULL != d_work) { hipFree(d_work); }
if (NULL != d_work) { cudaFree(d_work); }
// CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes);
cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 4: analysis */
// NOTE: CUDA 10.0
// TODO: status = hipsparseScsrsm2_analysis(
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE,
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE,
status = cusparseScsrsm2_analysis(
handle,
algo,
CUSPARSE_OPERATION_NON_TRANSPOSE, /* transA */
CUSPARSE_OPERATION_NON_TRANSPOSE, /* transB */
n,
nrhs,
nnzA,
&h_one,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
d_B,
n, /* ldb */
info,
policy,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
/* step 5: solve L * X = B */
// NOTE: CUDA 10.0
// TODO: status = hipsparseScsrsm2_solve(
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE,
// CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE,
status = cusparseScsrsm2_solve(
handle,
algo,
CUSPARSE_OPERATION_NON_TRANSPOSE, /* transA */
CUSPARSE_OPERATION_NON_TRANSPOSE, /* transB */
n,
nrhs,
nnzA,
&h_one,
descrA,
d_csrValA,
d_csrRowPtrA,
d_csrColIndA,
d_B,
n, /* ldb */
info,
policy,
d_work);
// CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status);
assert(CUSPARSE_STATUS_SUCCESS == status);
// CHECK: cudaStat1 = hipDeviceSynchronize();
cudaStat1 = cudaDeviceSynchronize();
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
/* step 6:measure residual B - A*X */
// CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*nrhs, hipMemcpyDeviceToHost);
cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*nrhs, cudaMemcpyDeviceToHost);
// CHECK: assert(hipSuccess == cudaStat1);
assert(cudaSuccess == cudaStat1);
// CHECK: hipDeviceSynchronize();
cudaDeviceSynchronize();
printf("==== x1 = inv(A)*b1 \n");
for (int j = 0; j < n; j++) {
printf("x1[%d] = %f\n", j, X[j]);
}
float r1_nrminf;
residaul_eval(
n,
descrA,
csrValA,
csrRowPtrA,
csrColIndA,
B,
X,
&r1_nrminf
);
printf("|b1 - A*x1| = %E\n", r1_nrminf);
printf("==== x2 = inv(A)*b2 \n");
for (int j = 0; j < n; j++) {
printf("x2[%d] = %f\n", j, X[n + j]);
}
float r2_nrminf;
residaul_eval(
n,
descrA,
csrValA,
csrRowPtrA,
csrColIndA,
B + n,
X + n,
&r2_nrminf
);
printf("|b2 - A*x2| = %E\n", r2_nrminf);
/* free resources */
// CHECK: if (d_csrRowPtrA) hipFree(d_csrRowPtrA);
if (d_csrRowPtrA) cudaFree(d_csrRowPtrA);
// CHECK: if (d_csrColIndA) hipFree(d_csrColIndA);
if (d_csrColIndA) cudaFree(d_csrColIndA);
// CHECK: if (d_csrValA) hipFree(d_csrValA);
if (d_csrValA) cudaFree(d_csrValA);
// CHECK: if (d_B) hipFree(d_B);
if (d_B) cudaFree(d_B);
// CHECK: if (handle) hipsparseDestroy(handle);
if (handle) cusparseDestroy(handle);
// CHECK: if (stream) hipStreamDestroy(stream);
if (stream) cudaStreamDestroy(stream);
// CHECK: if (descrA) hipsparseDestroyMatDescr(descrA);
if (descrA) cusparseDestroyMatDescr(descrA);
// NOTE: CUDA 10.0
// TODO: if (info) hipsparseDestroyCsrsm2Info(info);
if (info) cusparseDestroyCsrsm2Info(info);
// CHECK: hipDeviceReset();
cudaDeviceReset();
return 0;
}
Просмотреть файл
Просмотреть файл
Просмотреть файл
Просмотреть файл
+20
Просмотреть файл
@@ -40,6 +40,12 @@ __global__ void Assign(int* Out) {
globalOut[tid] = globalIn[tid];
}
__device__ __constant__ int globalConst[NUM];
__global__ void checkAddress(int* addr, bool* out) {
*out = (globalConst == addr);
}
int main() {
int *A, *Am, *B, *Ad, *C, *Cm;
A = new int[NUM];
@@ -101,6 +107,20 @@ int main() {
assert(A[i] == B[i]);
assert(A[i] == C[i]);
}
bool *checkOkD;
bool checkOk = false;
size_t symbolSize = 0;
int *symbolAddress;
hipGetSymbolSize(&symbolSize, HIP_SYMBOL(globalConst));
hipGetSymbolAddress((void**) &symbolAddress, HIP_SYMBOL(globalConst));
hipMalloc((void**)&checkOkD, sizeof(bool));
hipLaunchKernelGGL(checkAddress, dim3(1, 1, 1), dim3(1, 1, 1), 0, 0, symbolAddress, checkOkD);
hipMemcpy(&checkOk, checkOkD, sizeof(bool), hipMemcpyDeviceToHost);
hipFree(checkOkD);
assert(checkOk);
assert(symbolSize == SIZE);
hipHostFree(Am);
hipHostFree(Cm);
hipFree(Ad);