Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ add_rocprim_benchmark_hip(benchmark_hip_warp_sort.cpp)
add_rocprim_benchmark_hip(benchmark_hip_device_memory.cpp)

# rocPRIM HC benchmarks
if(HIP_COMPILER STREQUAL "HCC")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also disable HC example in https://github.com/ROCmSoftwarePlatform/rocPRIM/blob/master/example/CMakeLists.txt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I had examples OFF during my compiles, I'll add this

add_rocprim_benchmark_hc(benchmark_hc_block_discontinuity.cpp)
add_rocprim_benchmark_hc(benchmark_hc_block_exchange.cpp)
add_rocprim_benchmark_hc(benchmark_hc_block_histogram.cpp)
Expand All @@ -95,3 +96,4 @@ add_rocprim_benchmark_hc(benchmark_hc_device_select.cpp)
add_rocprim_benchmark_hc(benchmark_hc_device_transform.cpp)
add_rocprim_benchmark_hc(benchmark_hc_warp_scan.cpp)
add_rocprim_benchmark_hc(benchmark_hc_warp_sort.cpp)
endif()
27 changes: 23 additions & 4 deletions cmake/VerifyCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,36 @@ if(HIP_PLATFORM STREQUAL "nvcc")
include(cmake/SetupNVCC.cmake)
message(STATUS "rocPRIM does not support NVCC. Only hipCUB will be available.")
elseif(HIP_PLATFORM STREQUAL "hcc")
if(NOT (CMAKE_CXX_COMPILER MATCHES ".*/hcc$"))
message(FATAL_ERROR "On ROCm platform 'hcc' must be used as C++ compiler.")
if(NOT (CMAKE_CXX_COMPILER MATCHES ".*/hcc$" OR CMAKE_CXX_COMPILER MATCHES ".*/hipcc$"))
message(FATAL_ERROR "On ROCm platform 'hcc' or 'clang' must be used as C++ compiler.")
else()
# Determine if CXX Compiler is hcc, hip-clang or other
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "--version" OUTPUT_VARIABLE CXX_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[A-Za-z]* ?clang version" TMP_CXX_VERSION ${CXX_OUTPUT})
string(REGEX MATCH "[A-Za-z]+" CXX_VERSION_STRING ${TMP_CXX_VERSION})
if(CXX_VERSION_STRING MATCHES "HCC")
set(HIP_COMPILER "hcc" CACHE STRING "HIP Compiler")
elseif(CXX_VERSION_STRING MATCHES "clang")
set(HIP_COMPILER "clang" CACHE STRING "HIP Compiler")
else()
message(FATAL_ERROR "CXX Compiler version ${CXX_VERSION_STRING} unsupported.")
endif()
message(STATUS "HIP Compiler: " ${HIP_COMPILER})

# 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} -Wno-unused-command-line-argument")
find_package(hcc REQUIRED CONFIG PATHS /opt/rocm)
if(HIP_COMPILER STREQUAL "HCC")
find_package(hcc REQUIRED CONFIG PATHS /opt/rocm)
else()
find_package(hcc QUIET CONFIG PATHS /opt/rocm)
endif()
find_package(hip REQUIRED CONFIG PATHS /opt/rocm)
endif()
else()
message(FATAL_ERROR "HIP_PLATFORM must be 'hcc' (AMD ROCm platform) or `nvcc` (NVIDIA CUDA platform).")
message(FATAL_ERROR "HIP_PLATFORM must be 'hcc' or 'clang' (AMD ROCm platform) or `nvcc` (NVIDIA CUDA platform).")
endif()
36 changes: 25 additions & 11 deletions rocprim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ target_include_directories(rocprim

# This target allows using only HC interface, links only
# against HC/HSA library, doesn't require HIP
add_library(rocprim_hc INTERFACE)
target_link_libraries(rocprim_hc
INTERFACE
rocprim
hcc::hccrt
hcc::hc_am
)
target_compile_definitions(rocprim_hc
INTERFACE
ROCPRIM_HC_API=1
)
if(HIP_COMPILER STREQUAL "HCC" OR hcc_FOUND)
add_library(rocprim_hc INTERFACE)
target_link_libraries(rocprim_hc
INTERFACE
rocprim
hcc::hccrt
hcc::hc_am
)
target_compile_definitions(rocprim_hc
INTERFACE
ROCPRIM_HC_API=1
)
endif()


# This target allows using both HIP and HC interfaces,
# links against HIP library (which depends on HC)
Expand All @@ -76,13 +79,24 @@ set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})

# We need to install headers manually as rocm_install_targets
# does not support header-only libraries (INTERFACE targets)
if(rocprim_hc)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(TARGET rocprim_hc).

Everything else looks ok. We will test it tomorrow and merge if it works ok on our CI with hcc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

rocm_install_targets(
TARGETS rocprim rocprim_hip rocprim_hc
# INCLUDE
# ${CMAKE_SOURCE_DIR}/rocprim/include
# ${CMAKE_BINARY_DIR}/rocprim/include
PREFIX rocprim
)
else()
rocm_install_targets(
TARGETS rocprim rocprim_hip
# INCLUDE
# ${CMAKE_SOURCE_DIR}/rocprim/include
# ${CMAKE_BINARY_DIR}/rocprim/include
PREFIX rocprim
)
endif()

install(
DIRECTORY
"include/"
Expand Down
25 changes: 17 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ function(add_hc_test TEST_NAME TEST_SOURCES)
PUBLIC
${GTEST_INCLUDE_DIRS}
)
target_link_libraries(${TEST_TARGET}
PRIVATE
hcc::hccrt
hcc::hc_am
${GTEST_BOTH_LIBRARIES}
)
if(HIP_COMPILER STREQUAL "HCC")
target_link_libraries(${TEST_TARGET}
PRIVATE
hcc::hccrt
hcc::hc_am
${GTEST_BOTH_LIBRARIES}
)
elseif(HIP_COMPILER STREQUAL "clang")
target_link_libraries(${TEST_TARGET}
PRIVATE
${GTEST_BOTH_LIBRARIES}
)
endif()
foreach(amdgpu_target ${AMDGPU_TARGETS})
target_link_libraries(${TEST_TARGET}
PRIVATE
Expand All @@ -86,8 +93,10 @@ endfunction()

# HC and HIP tests without using rocPRIM
if(HIP_PLATFORM STREQUAL "hcc")
add_hip_test("hc.device_api" test_hip_api.cpp)
add_hc_test ("hip.device_api" test_hc_api.cpp)
add_hip_test("hip.device_api" test_hip_api.cpp)
if(HIP_COMPILER STREQUAL "HCC")
add_hc_test ("hc.device_api" test_hc_api.cpp)
endif()
endif()

# rocPRIM test (run only on ROCm/hcc)
Expand Down
2 changes: 2 additions & 0 deletions test/rocprim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ endfunction()
#

# HCP basic test, which also checks if there are no linkage problems when there are multiple sources
if(HIP_COMPILER STREQUAL "HCC")
add_rocprim_test_hc("rocprim.hc.basic_test" "test_hc_basic.cpp;detail/get_rocprim_version_hc.cpp")

add_rocprim_test_hc("rocprim.hc.arg_index_iterator" test_hc_arg_index_iterator.cpp)
Expand Down Expand Up @@ -98,6 +99,7 @@ add_rocprim_test_hc("rocprim.hc.warp_reduce" test_hc_warp_reduce.cpp)
add_rocprim_test_hc("rocprim.hc.warp_scan" test_hc_warp_scan.cpp)
add_rocprim_test_hc("rocprim.hc.warp_sort" test_hc_warp_sort.cpp)
add_rocprim_test_hc("rocprim.hc.zip_iterator" test_hc_zip_iterator.cpp)
endif()

#
# rocPRIM HIP API tests
Expand Down