Skip to content

Commit

Permalink
Merge minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrost57 committed Oct 15, 2018
2 parents 05ebf1d + 70440b9 commit be680c7
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 59 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ else()
endif()

# hipSPARSE project
project(hipsparse VERSION 0.1.3.1 LANGUAGES CXX)
set(hipsparse_SOVERSION 0)
project(hipsparse LANGUAGES CXX)

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand All @@ -58,6 +57,10 @@ option(BUILD_VERBOSE "Output additional build information" OFF)
# Dependencies
include(cmake/Dependencies.cmake)

# Setup version
rocm_setup_version(VERSION 0.1.3.2 NO_GIT_TAG_VERSION)
set(hipsparse_SOVERSION 0)

# hipSPARSE library
add_subdirectory(library)

Expand Down
8 changes: 6 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ def docker_build_inside_image( def build_image, compiler_data compiler_args, doc
set -x
rm -rf ${docker_context} && mkdir -p ${docker_context}
mv ${paths.project_build_prefix}/build/release/*.deb ${docker_context}
dpkg -c ${docker_context}/*.deb
# Temp rocsparse mv because repo.radeon.com does not have debs for rocsparse
mv ${paths.project_build_prefix}/*.deb ${docker_context}
dpkg -c ${docker_context}/*rocsparse*.deb
dpkg -c ${docker_context}/*hipsparse*.deb
"""
archiveArtifacts artifacts: "${docker_context}/*.deb", fingerprint: true

Expand Down Expand Up @@ -493,7 +497,7 @@ def build_pipeline( compiler_data compiler_args, docker_data docker_args, projec
//},
rocm_ubuntu:
{
node( 'docker && rocm && gfx900')
node( 'docker && rocm19 && gfx900')
{
def hcc_docker_args = new docker_data(
from_image:'rocm/dev-ubuntu-16.04:1.9.0',
Expand Down
2 changes: 1 addition & 1 deletion clients/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if(NOT TARGET hipsparse)
endif()

# Hip headers required of all clients; clients use hip to allocate device memory
find_package(hip REQUIRED CONFIG PATHS /opt/rocm)
find_package(HIP REQUIRED CONFIG PATHS /opt/rocm)

if(BUILD_CLIENTS_SAMPLES)
add_subdirectory(samples)
Expand Down
4 changes: 2 additions & 2 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ include(cmake/DownloadProject/DownloadProject.cmake)

# Either rocSPARSE or cuSPARSE is required
if(NOT BUILD_CUDA)
find_package(rocSPARSE 0.1.3 REQUIRED) # ROCm 1.9
find_package(hip 1.5.18353 REQUIRED CONFIG PATHS /opt/rocm) # ROCm 1.9
find_package(rocsparse 0.1.3 REQUIRED) # ROCm 1.9
find_package(HIP 1.5.18353 REQUIRED CONFIG PATHS /opt/rocm) # ROCm 1.9
else()
find_package(CUDA REQUIRED)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/Verbose.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# ########################################################################

message(STATUS "hipsparse_VERSION : ${hipsparse_VERSION}")
message(STATUS "hipsparse_VERSION : ${hipsparse_VERSION}")
message(STATUS "\t==>CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}")
message(STATUS "\t==>BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}")
message(STATUS "\t==>CMAKE_INSTALL_PREFIX link : ${CMAKE_INSTALL_PREFIX}")
Expand Down
1 change: 1 addition & 0 deletions docker/dockerfile-install-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY *.deb /tmp/

# Install the debian package
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --allow-unauthenticated -y \
/tmp/rocsparse-*.deb \
/tmp/hipsparse-*.deb \
&& rm -f /tmp/*.deb \
&& apt-get clean \
Expand Down
2 changes: 1 addition & 1 deletion library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ rocm_install_targets(TARGETS hipsparse
# Export targets
rocm_export_targets(TARGETS roc::hipsparse
PREFIX hipsparse
DEPENDS PACKAGE hip
DEPENDS PACKAGE HIP
NAMESPACE roc::
)

Expand Down
203 changes: 153 additions & 50 deletions library/src/hcc_detail/hipsparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ extern "C" {
} \
}

#define RETURN_IF_HIPSPARSE_ERROR(INPUT_STATUS_FOR_CHECK) \
{ \
hipsparseStatus_t TMP_STATUS_FOR_CHECK = INPUT_STATUS_FOR_CHECK; \
if(TMP_STATUS_FOR_CHECK != HIPSPARSE_STATUS_SUCCESS) \
{ \
return TMP_STATUS_FOR_CHECK; \
} \
}

#define RETURN_IF_ROCSPARSE_ERROR(INPUT_STATUS_FOR_CHECK) \
{ \
rocsparse_status TMP_STATUS_FOR_CHECK = INPUT_STATUS_FOR_CHECK; \
Expand Down Expand Up @@ -419,8 +428,18 @@ hipsparseStatus_t hipsparseSdoti(hipsparseHandle_t handle,
float* result,
hipsparseIndexBase_t idxBase)
{
return rocSPARSEStatusToHIPStatus(rocsparse_sdoti(
// Obtain stream, to explicitly sync (cusparse doti is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// Doti
RETURN_IF_ROCSPARSE_ERROR(rocsparse_sdoti(
(rocsparse_handle)handle, nnz, xVal, xInd, y, result, hipBaseToHCCBase(idxBase)));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseDdoti(hipsparseHandle_t handle,
Expand All @@ -431,8 +450,18 @@ hipsparseStatus_t hipsparseDdoti(hipsparseHandle_t handle,
double* result,
hipsparseIndexBase_t idxBase)
{
return rocSPARSEStatusToHIPStatus(rocsparse_ddoti(
// Obtain stream, to explicitly sync (cusparse doti is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// Doti
RETURN_IF_ROCSPARSE_ERROR(rocsparse_ddoti(
(rocsparse_handle)handle, nnz, xVal, xInd, y, result, hipBaseToHCCBase(idxBase)));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseSgthr(hipsparseHandle_t handle,
Expand Down Expand Up @@ -590,8 +619,18 @@ hipsparseStatus_t hipsparseDcsrmv(hipsparseHandle_t handle,
hipsparseStatus_t
hipsparseXcsrsv2_zeroPivot(hipsparseHandle_t handle, csrsv2Info_t info, int* position)
{
return rocSPARSEStatusToHIPStatus(rocsparse_csrsv_zero_pivot(
// Obtain stream, to explicitly sync (cusparse csrsv2_zeropivot is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// csrsv zero pivot
RETURN_IF_ROCSPARSE_ERROR(rocsparse_csrsv_zero_pivot(
(rocsparse_handle)handle, nullptr, (rocsparse_mat_info)info, position));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseScsrsv2_bufferSize(hipsparseHandle_t handle,
Expand Down Expand Up @@ -724,18 +763,28 @@ hipsparseStatus_t hipsparseScsrsv2_analysis(hipsparseHandle_t handle,
hipsparseSolvePolicy_t policy,
void* pBuffer)
{
return rocSPARSEStatusToHIPStatus(rocsparse_scsrsv_analysis((rocsparse_handle)handle,
hipOperationToHCCOperation(transA),
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));
// Obtain stream, to explicitly sync (cusparse csrsv2_analysis is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// csrsv analysis
RETURN_IF_ROCSPARSE_ERROR(rocsparse_scsrsv_analysis((rocsparse_handle)handle,
hipOperationToHCCOperation(transA),
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseDcsrsv2_analysis(hipsparseHandle_t handle,
Expand All @@ -750,18 +799,28 @@ hipsparseStatus_t hipsparseDcsrsv2_analysis(hipsparseHandle_t handle,
hipsparseSolvePolicy_t policy,
void* pBuffer)
{
return rocSPARSEStatusToHIPStatus(rocsparse_dcsrsv_analysis((rocsparse_handle)handle,
hipOperationToHCCOperation(transA),
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));
// Obtain stream, to explicitly sync (cusparse csrsv2_analysis is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// csrsv analysis
RETURN_IF_ROCSPARSE_ERROR(rocsparse_dcsrsv_analysis((rocsparse_handle)handle,
hipOperationToHCCOperation(transA),
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseScsrsv2_solve(hipsparseHandle_t handle,
Expand Down Expand Up @@ -1013,8 +1072,18 @@ hipsparseStatus_t hipsparseDcsrmm2(hipsparseHandle_t handle,
hipsparseStatus_t
hipsparseXcsrilu02_zeroPivot(hipsparseHandle_t handle, csrilu02Info_t info, int* position)
{
return rocSPARSEStatusToHIPStatus(
// Obtain stream, to explicitly sync (cusparse csrilu02_zeropivot is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// csrilu0 zero pivot
RETURN_IF_ROCSPARSE_ERROR(
rocsparse_csrilu0_zero_pivot((rocsparse_handle)handle, (rocsparse_mat_info)info, position));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseScsrilu02_bufferSize(hipsparseHandle_t handle,
Expand Down Expand Up @@ -1136,17 +1205,27 @@ hipsparseStatus_t hipsparseScsrilu02_analysis(hipsparseHandle_t handle,
hipsparseSolvePolicy_t policy,
void* pBuffer)
{
return rocSPARSEStatusToHIPStatus(rocsparse_scsrilu0_analysis((rocsparse_handle)handle,
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));
// Obtain stream, to explicitly sync (cusparse csrilu02_analysis is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// csrilu0 analysis
RETURN_IF_ROCSPARSE_ERROR(rocsparse_scsrilu0_analysis((rocsparse_handle)handle,
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseDcsrilu02_analysis(hipsparseHandle_t handle,
Expand All @@ -1160,17 +1239,27 @@ hipsparseStatus_t hipsparseDcsrilu02_analysis(hipsparseHandle_t handle,
hipsparseSolvePolicy_t policy,
void* pBuffer)
{
return rocSPARSEStatusToHIPStatus(rocsparse_dcsrilu0_analysis((rocsparse_handle)handle,
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));
// Obtain stream, to explicitly sync (cusparse csrilu02_analysis is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// csrilu0 analysis
RETURN_IF_ROCSPARSE_ERROR(rocsparse_dcsrilu0_analysis((rocsparse_handle)handle,
m,
nnz,
(rocsparse_mat_descr)descrA,
csrSortedValA,
csrSortedRowPtrA,
csrSortedColIndA,
(rocsparse_mat_info)info,
rocsparse_analysis_policy_force,
rocsparse_solve_policy_auto,
pBuffer));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

hipsparseStatus_t hipsparseScsrilu02(hipsparseHandle_t handle,
Expand Down Expand Up @@ -1262,6 +1351,10 @@ hipsparseStatus_t hipsparseScsr2csc(hipsparseHandle_t handle,
void* buffer = nullptr;
RETURN_IF_HIP_ERROR(hipMalloc(&buffer, buffer_size));

// Obtain stream, to explicitly sync (cusparse csr2csc is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// Format conversion
RETURN_IF_ROCSPARSE_ERROR(rocsparse_scsr2csc((rocsparse_handle)handle,
m,
Expand All @@ -1280,6 +1373,9 @@ hipsparseStatus_t hipsparseScsr2csc(hipsparseHandle_t handle,
// Free buffer
RETURN_IF_HIP_ERROR(hipFree(buffer));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -1311,6 +1407,10 @@ hipsparseStatus_t hipsparseDcsr2csc(hipsparseHandle_t handle,
void* buffer = nullptr;
RETURN_IF_HIP_ERROR(hipMalloc(&buffer, buffer_size));

// Obtain stream, to explicitly sync (cusparse csr2csc is blocking)
hipStream_t stream;
RETURN_IF_HIPSPARSE_ERROR(hipsparseGetStream(handle, &stream));

// Format conversion
RETURN_IF_ROCSPARSE_ERROR(rocsparse_dcsr2csc((rocsparse_handle)handle,
m,
Expand All @@ -1329,6 +1429,9 @@ hipsparseStatus_t hipsparseDcsr2csc(hipsparseHandle_t handle,
// Free buffer
RETURN_IF_HIP_ERROR(hipFree(buffer));

// Synchronize stream
RETURN_IF_HIP_ERROR(hipStreamSynchronize(stream));

return HIPSPARSE_STATUS_SUCCESS;
}

Expand Down

0 comments on commit be680c7

Please sign in to comment.