From f1823fbb56e23b088ad278e862673553018611d0 Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Tue, 16 Oct 2018 10:03:12 +0200 Subject: [PATCH 1/7] documentation: fixed wrong function names --- docs/source/library.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/library.rst b/docs/source/library.rst index b4ebcd40..2d90852d 100644 --- a/docs/source/library.rst +++ b/docs/source/library.rst @@ -766,7 +766,7 @@ rocsparse_csrsv_solve() :outline: .. doxygenfunction:: rocsparse_dcsrsv_solve -rocsparse_csrsv_analysis_clear() +rocsparse_csrsv_clear() ******************************** .. doxygenfunction:: rocsparse_csrsv_clear @@ -822,7 +822,7 @@ rocsparse_csrilu0() :outline: .. doxygenfunction:: rocsparse_dcsrilu0 -rocsparse_csrilu0_analysis_clear() +rocsparse_csrilu0_clear() ********************************** .. doxygenfunction:: rocsparse_csrilu0_clear From 117916d907e61ef8de59b9db6bc8834e7d4d5e95 Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Tue, 16 Oct 2018 13:16:11 +0200 Subject: [PATCH 2/7] changed csrsv and csrilu0 analysis to be not fully blocking --- library/src/handle.cpp | 12 +++++-- library/src/include/handle.h | 4 ++- library/src/level2/rocsparse_csrsv.hpp | 41 +++++++++++++---------- library/src/precond/rocsparse_csrilu0.hpp | 24 ++++++------- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/library/src/handle.cpp b/library/src/handle.cpp index 3897b640..e8c64b8d 100644 --- a/library/src/handle.cpp +++ b/library/src/handle.cpp @@ -223,10 +223,16 @@ rocsparse_status rocsparse_destroy_csrtr_info(rocsparse_csrtr_info info) } // Clean up - if(info->row_map != nullptr) + if(info->d_row_map != nullptr) { - RETURN_IF_HIP_ERROR(hipFree(info->row_map)); - info->row_map = nullptr; + RETURN_IF_HIP_ERROR(hipFree(info->d_row_map)); + info->d_row_map = nullptr; + } + + if(info->h_row_map != nullptr) + { + RETURN_IF_HIP_ERROR(hipFreeHost(info->h_row_map)); + info->h_row_map = nullptr; } if(info->csr_diag_ind != nullptr) diff --git a/library/src/include/handle.h b/library/src/include/handle.h index 7b76c2ee..b683d2ff 100644 --- a/library/src/include/handle.h +++ b/library/src/include/handle.h @@ -194,7 +194,9 @@ struct _rocsparse_csrtr_info // host array to hold number of rows per level std::vector rows_per_level; // device array to hold row permutation - rocsparse_int* row_map = nullptr; + rocsparse_int* d_row_map = nullptr; + // host array to hold row permutation + rocsparse_int* h_row_map = nullptr; // device array to hold pointer to diagonal entry rocsparse_int* csr_diag_ind = nullptr; // device pointer to hold zero pivot diff --git a/library/src/level2/rocsparse_csrsv.hpp b/library/src/level2/rocsparse_csrsv.hpp index 5c393fc0..0eac9268 100644 --- a/library/src/level2/rocsparse_csrsv.hpp +++ b/library/src/level2/rocsparse_csrsv.hpp @@ -198,6 +198,15 @@ static rocsparse_status rocsparse_csrtr_analysis(rocsparse_handle handle, // Allocate buffer to hold zero pivot RETURN_IF_HIP_ERROR(hipMalloc((void**)&info->zero_pivot, sizeof(rocsparse_int))); + // Allocate buffer to hold row map + RETURN_IF_HIP_ERROR(hipMalloc((void**)&info->d_row_map, sizeof(rocsparse_int) * (m + 1))); + + // Allocate host buffer to hold row map + RETURN_IF_HIP_ERROR(hipHostMalloc((void**)&info->h_row_map, sizeof(rocsparse_int) * (m + 1))); + + // Initialize row map + memset(info->h_row_map, 0, sizeof(rocsparse_int) * (m + 1)); + // Initialize zero pivot rocsparse_int max = std::numeric_limits::max(); RETURN_IF_HIP_ERROR( @@ -323,7 +332,6 @@ static rocsparse_status rocsparse_csrtr_analysis(rocsparse_handle handle, RETURN_IF_HIP_ERROR(hipMemcpy( done_array.data(), d_done_array, sizeof(rocsparse_int) * m, hipMemcpyDeviceToHost)); - std::vector row_map(m + 1, 0); std::vector counter(info->max_depth, 0); // Create row map @@ -333,14 +341,13 @@ static rocsparse_status rocsparse_csrtr_analysis(rocsparse_handle handle, rocsparse_int prev_level = level - 1; rocsparse_int depth_offset = (level == 0) ? 0 : info->rows_per_level[prev_level]; - row_map[depth_offset + counter[level]] = i; + info->h_row_map[depth_offset + counter[level]] = i; ++counter[level]; } // Copy row map to device - RETURN_IF_HIP_ERROR(hipMalloc((void**)&info->row_map, sizeof(rocsparse_int) * (m + 1))); - RETURN_IF_HIP_ERROR(hipMemcpy( - info->row_map, row_map.data(), sizeof(rocsparse_int) * (m + 1), hipMemcpyHostToDevice)); + RETURN_IF_HIP_ERROR(hipMemcpyAsync( + info->d_row_map, info->h_row_map, sizeof(rocsparse_int) * (m + 1), hipMemcpyHostToDevice, stream)); // Store some pointers to verify correct execution info->m = m; @@ -803,7 +810,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -825,7 +832,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -855,7 +862,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -877,7 +884,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -918,7 +925,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -940,7 +947,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -970,7 +977,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -992,7 +999,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, depth_offset, csrsv->zero_pivot, descr->base, @@ -1029,7 +1036,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, 0, csrsv->zero_pivot, descr->base, @@ -1051,7 +1058,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, 0, csrsv->zero_pivot, descr->base, @@ -1081,7 +1088,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, 0, csrsv->zero_pivot, descr->base, @@ -1103,7 +1110,7 @@ CSRSV_DIM + 1); x, y, d_done_array, - csrsv->row_map, + csrsv->d_row_map, 0, csrsv->zero_pivot, descr->base, diff --git a/library/src/precond/rocsparse_csrilu0.hpp b/library/src/precond/rocsparse_csrilu0.hpp index 73983500..a41c26b2 100644 --- a/library/src/precond/rocsparse_csrilu0.hpp +++ b/library/src/precond/rocsparse_csrilu0.hpp @@ -307,7 +307,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -324,7 +324,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -341,7 +341,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -358,7 +358,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -375,7 +375,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -392,7 +392,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -412,7 +412,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -429,7 +429,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -446,7 +446,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -463,7 +463,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -480,7 +480,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } @@ -497,7 +497,7 @@ rocsparse_status rocsparse_csrilu0_template(rocsparse_handle handle, csr_val, info->csrilu0_info->csr_diag_ind, d_done_array, - info->csrilu0_info->row_map, + info->csrilu0_info->d_row_map, info->csrilu0_info->zero_pivot, descr->base); } From 95c88cbda2a3ab27d21d424bdcb370328c806090 Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Tue, 16 Oct 2018 13:16:45 +0200 Subject: [PATCH 3/7] clang format --- library/src/level2/rocsparse_csrsv.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/src/level2/rocsparse_csrsv.hpp b/library/src/level2/rocsparse_csrsv.hpp index 0eac9268..504ae70c 100644 --- a/library/src/level2/rocsparse_csrsv.hpp +++ b/library/src/level2/rocsparse_csrsv.hpp @@ -346,8 +346,11 @@ static rocsparse_status rocsparse_csrtr_analysis(rocsparse_handle handle, } // Copy row map to device - RETURN_IF_HIP_ERROR(hipMemcpyAsync( - info->d_row_map, info->h_row_map, sizeof(rocsparse_int) * (m + 1), hipMemcpyHostToDevice, stream)); + RETURN_IF_HIP_ERROR(hipMemcpyAsync(info->d_row_map, + info->h_row_map, + sizeof(rocsparse_int) * (m + 1), + hipMemcpyHostToDevice, + stream)); // Store some pointers to verify correct execution info->m = m; From c48fcd7ae39dcf624b30b478d9491bc7700b22d6 Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Thu, 18 Oct 2018 08:12:09 +0200 Subject: [PATCH 4/7] its actually hip-config.cmake, so should be lower case hip --- library/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 50c0a4c5..2324ef22 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -95,7 +95,7 @@ rocm_install_targets(TARGETS rocsparse # Export targets rocm_export_targets(TARGETS roc::rocsparse PREFIX rocsparse - DEPENDS PACKAGE HIP + DEPENDS PACKAGE hip NAMESPACE roc:: ) From ab6c8e3055a76f396c67a7d668c766304c0ac211 Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Thu, 18 Oct 2018 08:37:05 +0200 Subject: [PATCH 5/7] added note for zero pivot functions: they are blocking! --- library/include/rocsparse-functions.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/include/rocsparse-functions.h b/library/include/rocsparse-functions.h index b6ff3f86..3f1ee16e 100644 --- a/library/include/rocsparse-functions.h +++ b/library/include/rocsparse-functions.h @@ -987,6 +987,9 @@ rocsparse_status rocsparse_zcsrmv(rocsparse_handle handle, * \p position can be in host or device memory. If no zero pivot has been found, * \p position is set to -1 and \ref rocsparse_status_success is returned instead. * + * \note \p rocsparse_csrsv_zero_pivot is a blocking function. It might influence + * performance negatively. + * * @param[in] * handle handle to the rocsparse library context queue. * @param[in] @@ -1918,6 +1921,9 @@ rocsparse_status rocsparse_zcsrmm(rocsparse_handle handle, * \p position can be in host or device memory. If no zero pivot has been found, * \p position is set to -1 and \ref rocsparse_status_success is returned instead. * + * \note \p rocsparse_csrilu0_zero_pivot is a blocking function. It might influence + * performance negatively. + * * @param[in] * handle handle to the rocsparse library context queue. * @param[in] From 87444d9f06071f3c516b73451ff2bfa2ce14dd2a Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Fri, 19 Oct 2018 09:01:06 +0200 Subject: [PATCH 6/7] replaced deprecated function --- library/src/handle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/handle.cpp b/library/src/handle.cpp index e8c64b8d..bfeab368 100644 --- a/library/src/handle.cpp +++ b/library/src/handle.cpp @@ -231,7 +231,7 @@ rocsparse_status rocsparse_destroy_csrtr_info(rocsparse_csrtr_info info) if(info->h_row_map != nullptr) { - RETURN_IF_HIP_ERROR(hipFreeHost(info->h_row_map)); + RETURN_IF_HIP_ERROR(hipHostFree(info->h_row_map)); info->h_row_map = nullptr; } From 60475982caaa6c28c7b5eeda75a448fd152197e7 Mon Sep 17 00:00:00 2001 From: Nico Trost Date: Fri, 19 Oct 2018 09:01:40 +0200 Subject: [PATCH 7/7] testing change in cmake files to overcome HIP_PLATFORM not set issue --- clients/benchmarks/CMakeLists.txt | 16 +++++++-------- clients/samples/CMakeLists.txt | 13 ++++++------ clients/tests/CMakeLists.txt | 16 +++++++-------- cmake/Dependencies.cmake | 34 +++++++++++++++---------------- cmake/SetToolchain.cmake | 4 +--- library/CMakeLists.txt | 12 +++++------ 6 files changed, 43 insertions(+), 52 deletions(-) diff --git a/clients/benchmarks/CMakeLists.txt b/clients/benchmarks/CMakeLists.txt index 4b23cb7e..76f6122d 100644 --- a/clients/benchmarks/CMakeLists.txt +++ b/clients/benchmarks/CMakeLists.txt @@ -59,7 +59,13 @@ target_include_directories(rocsparse-bench $ ) -if(HIP_PLATFORM STREQUAL "hcc") +if(HIP_PLATFORM STREQUAL "nvcc") + target_link_libraries(rocsparse-bench + PRIVATE + ${Boost_LIBRARIES} + roc::rocsparse + ) +else() target_link_libraries(rocsparse-bench PRIVATE ${Boost_LIBRARIES} @@ -75,11 +81,3 @@ if(HIP_PLATFORM STREQUAL "hcc") ) endforeach() endif() - -if(HIP_PLATFORM STREQUAL "nvcc") - target_link_libraries(rocsparse-bench - PRIVATE - ${Boost_LIBRARIES} - roc::rocsparse - ) -endif() diff --git a/clients/samples/CMakeLists.txt b/clients/samples/CMakeLists.txt index 428ca07c..a16f7bf4 100644 --- a/clients/samples/CMakeLists.txt +++ b/clients/samples/CMakeLists.txt @@ -35,7 +35,12 @@ function(add_rocsparse_example EXAMPLE_SOURCE) $ ) - if(HIP_PLATFORM STREQUAL "hcc") + if(HIP_PLATFORM STREQUAL "nvcc") + target_link_libraries(${EXAMPLE_TARGET} + PRIVATE + rocsparse + ) + else() target_link_libraries(${EXAMPLE_TARGET} PRIVATE rocsparse @@ -49,12 +54,6 @@ function(add_rocsparse_example EXAMPLE_SOURCE) endforeach() endif() - if(HIP_PLATFORM STREQUAL "nvcc") - target_link_libraries(${EXAMPLE_TARGET} - PRIVATE - rocsparse - ) - endif() set_target_properties(${EXAMPLE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/example" diff --git a/clients/tests/CMakeLists.txt b/clients/tests/CMakeLists.txt index 5f6adada..f341bd4b 100644 --- a/clients/tests/CMakeLists.txt +++ b/clients/tests/CMakeLists.txt @@ -113,7 +113,13 @@ target_include_directories(rocsparse-test $ ) -if(HIP_PLATFORM STREQUAL "hcc") +if(HIP_PLATFORM STREQUAL "nvcc") + target_link_libraries(rocsparse-test + PRIVATE + roc::rocsparse + ${GTEST_BOTH_LIBRARIES} + ) +else() target_link_libraries(rocsparse-test PRIVATE roc::rocsparse @@ -130,12 +136,4 @@ if(HIP_PLATFORM STREQUAL "hcc") endforeach() endif() -if(HIP_PLATFORM STREQUAL "nvcc") - target_link_libraries(rocsparse-test - PRIVATE - roc::rocsparse - ${GTEST_BOTH_LIBRARIES} - ) -endif() - add_test(rocsparse-test rocsparse-test) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index bfad9650..6404769e 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -30,15 +30,7 @@ find_package(Git REQUIRED) include(cmake/DownloadProject/DownloadProject.cmake) # HIP configuration -if(HIP_PLATFORM STREQUAL "hcc") - # Workaround until hcc & hip cmake modules fixes symlink logic in their config files. - # (Thanks to rocBLAS devs for finding workaround for this problem!) - list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc /opt/rocm/hip) - # Ignore hcc warning: argument unused during compilation: '-isystem /opt/rocm/hip/include' - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-command-line-argument") - find_package(hcc REQUIRED CONFIG PATHS /opt/rocm) - find_package(HIP REQUIRED CONFIG PATHS /opt/rocm) -elseif(HIP_PLATFORM STREQUAL "nvcc") +if(HIP_PLATFORM STREQUAL "nvcc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xcompiler -Wall") set(CMAKE_C_COMPILE_OPTIONS_PIC "-Xcompiler ${CMAKE_C_COMPILE_OPTIONS_PIC}" ) set(CMAKE_CXX_COMPILE_OPTIONS_PIC "-Xcompiler ${CMAKE_CXX_COMPILE_OPTIONS_PIC}" ) @@ -55,45 +47,53 @@ elseif(HIP_PLATFORM STREQUAL "nvcc") set(CMAKE_C_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-Xcompiler ${CMAKE_C_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}" ) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-Xcompiler ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch sm_35") +else() + # Workaround until hcc & hip cmake modules fixes symlink logic in their config files. + # (Thanks to rocBLAS devs for finding workaround for this problem!) + list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc /opt/rocm/hip) + # Ignore hcc warning: argument unused during compilation: '-isystem /opt/rocm/hip/include' + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-command-line-argument") + find_package(hcc REQUIRED CONFIG PATHS /opt/rocm) + find_package(HIP REQUIRED CONFIG PATHS /opt/rocm) endif() # rocPRIM package -if(HIP_PLATFORM STREQUAL "hcc") - find_package(ROCPRIM QUIET CONFIG PATHS /opt/rocm) +if(HIP_PLATFORM STREQUAL "nvcc") find_package(HIPCUB QUIET CONFIG PATHS /opt/rocm) - if(NOT ROCPRIM_FOUND) + if(NOT HIPCUB_FOUND) set(ROCPRIM_ROOT ${CMAKE_CURRENT_BINARY_DIR}/rocPRIM CACHE PATH "") message(STATUS "Downloading rocPRIM.") download_project(PROJ rocPRIM GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/rocPRIM.git GIT_TAG master INSTALL_DIR ${ROCPRIM_ROOT} - CMAKE_ARGS -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hcc + CMAKE_ARGS -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_COMPILER=${HIP_HIPCC_EXECUTABLE} LOG_DOWNLOAD TRUE LOG_CONFIGURE TRUE LOG_INSTALL TRUE BUILD_PROJECT TRUE UPDATE_DISCONNECT TRUE ) - find_package(ROCPRIM REQUIRED CONFIG PATHS ${ROCPRIM_ROOT}) find_package(HIPCUB REQUIRED CONFIG PATHS ${ROCPRIM_ROOT}) endif() -elseif(HIP_PLATFORM STREQUAL "nvcc") +else() + find_package(ROCPRIM QUIET CONFIG PATHS /opt/rocm) find_package(HIPCUB QUIET CONFIG PATHS /opt/rocm) - if(NOT HIPCUB_FOUND) + if(NOT ROCPRIM_FOUND) set(ROCPRIM_ROOT ${CMAKE_CURRENT_BINARY_DIR}/rocPRIM CACHE PATH "") message(STATUS "Downloading rocPRIM.") download_project(PROJ rocPRIM GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/rocPRIM.git GIT_TAG master INSTALL_DIR ${ROCPRIM_ROOT} - CMAKE_ARGS -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_COMPILER=${HIP_HIPCC_EXECUTABLE} + CMAKE_ARGS -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hcc LOG_DOWNLOAD TRUE LOG_CONFIGURE TRUE LOG_INSTALL TRUE BUILD_PROJECT TRUE UPDATE_DISCONNECT TRUE ) + find_package(ROCPRIM REQUIRED CONFIG PATHS ${ROCPRIM_ROOT}) find_package(HIPCUB REQUIRED CONFIG PATHS ${ROCPRIM_ROOT}) endif() endif() diff --git a/cmake/SetToolchain.cmake b/cmake/SetToolchain.cmake index 35d7be12..afd50740 100644 --- a/cmake/SetToolchain.cmake +++ b/cmake/SetToolchain.cmake @@ -45,7 +45,7 @@ if(HIP_PLATFORM STREQUAL "nvcc" OR HIP_COMPILER STREQUAL "clang") endif() mark_as_advanced(HIP_HIPCC_EXECUTABLE) set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE}) -elseif(HIP_PLATFORM STREQUAL "hcc") +else() # Find HCC executable find_program( HIP_HCC_EXECUTABLE @@ -65,6 +65,4 @@ elseif(HIP_PLATFORM STREQUAL "hcc") endif() mark_as_advanced(HIP_HCC_EXECUTABLE) set(CMAKE_CXX_COMPILER ${HIP_HCC_EXECUTABLE}) -else() - message(FATAL_ERROR "HIP_PLATFORM must be 'hcc/nvcc' (AMD ROCm platform).") endif() diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 2324ef22..500d3f6b 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -50,7 +50,7 @@ add_library(rocsparse ${rocsparse_source} ${rocsparse_headers_public}) add_library(roc::rocsparse ALIAS rocsparse) # Target link libraries -if(HIP_PLATFORM STREQUAL "hcc") +if(NOT HIP_PLATFORM STREQUAL "nvcc") target_link_libraries(rocsparse PRIVATE hip::hip_hcc hip::hip_device hcc::hccshared) foreach(target ${AMDGPU_TARGETS}) target_link_libraries(rocsparse PRIVATE --amdgpu-target=${target}) @@ -68,7 +68,7 @@ target_include_directories(rocsparse ) # Target properties -if(HIP_PLATFORM STREQUAL "hcc") +if(NOT HIP_PLATFORM STREQUAL "nvcc") set_target_properties(rocsparse PROPERTIES VERSION ${rocsparse_VERSION} SOVERSION ${rocsparse_SOVERSION}) set_target_properties(rocsparse PROPERTIES CXX_VISIBILITY_PRESET "hidden" VISIBILITY_INLINES_HIDDEN ON) endif() @@ -76,7 +76,7 @@ set_target_properties(rocsparse PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_B set_target_properties(rocsparse PROPERTIES DEBUG_POSTFIX "-d") # Target definitions -if(HIP_PLATFORM STREQUAL "hcc") +if(NOT HIP_PLATFORM STREQUAL "nvcc") target_compile_definitions(rocsparse PRIVATE ROCPRIM_HIP_API=1) endif() @@ -114,12 +114,10 @@ endif() set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "\${CPACK_PACKAGING_INSTALL_PREFIX}" "\${CPACK_PACKAGING_INSTALL_PREFIX}/include") # Package name differs for CUDA backend -if(HIP_PLATFORM STREQUAL "hcc") - set(package_name rocsparse) -endif() - if(HIP_PLATFORM STREQUAL "nvcc") set(package_name rocsparse-alt) +else() + set(package_name rocsparse) endif() set(ROCSPARSE_CONFIG_DIR "\${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Path placed into ldconfig file")