Skip to content

Commit

Permalink
Clarify HIP usage (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
lawruble13 authored Sep 13, 2024
1 parent d82427e commit a030e7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ if(GPU_TARGETS STREQUAL "all")
set(GPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "GPU architectures to compile for" FORCE)
endif()

if(NOT WIN32)
include(cmake/VerifyCompiler.cmake)
else()
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} $ENV{ROCM_PATH}/hip $ENV{ROCM_PATH}/llvm)
find_package(hip REQUIRED CONFIG PATHS ${HIP_DIR} $ENV{ROCM_PATH})
endif()
# Verify the compiler settings and include the HIP CMake package
include(cmake/VerifyCompiler.cmake)

# Build option to disable -Werror
option(DISABLE_WERROR "Disable building with Werror" ON)
Expand Down
14 changes: 7 additions & 7 deletions cmake/VerifyCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

list(APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH} $ENV{ROCM_PATH}/hip)
list(APPEND CMAKE_PREFIX_PATH $ENV{ROCM_PATH} $ENV{ROCM_PATH}/hip $ENV{ROCM_PATH})
if(CMAKE_CXX_COMPILER MATCHES ".*/nvcc$" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
find_package(hip QUIET CONFIG PATHS $ENV{ROCM_PATH})
if(NOT hip_FOUND)
find_package(HIP REQUIRED)
endif()
# Compiling for CUDA
find_package(hip REQUIRED CONFIG PATHS $ENV{ROCM_PATH})
if((HIP_COMPILER STREQUAL "clang"))
# TODO: The HIP package on NVIDIA platform is incorrect at few versions
set(HIP_COMPILER "nvcc" CACHE STRING "HIP Compiler" FORCE)
endif()
else()
message("Looking in $ENV{ROCM_PATH}...")
find_package(hip REQUIRED CONFIG PATHS $ENV{ROCM_PATH})
# compiling for ROCm
message("Looking in $ENV{ROCM_PATH}...")
find_package(hip REQUIRED CONFIG PATHS $ENV{ROCM_PATH})
endif()

if(HIP_COMPILER STREQUAL "nvcc")
# NVCC requires some additional setup
include(SetupNVCC)
elseif(HIP_COMPILER STREQUAL "clang")
if(NOT (CMAKE_CXX_COMPILER MATCHES ".*hipcc$" OR CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+"))
Expand Down

0 comments on commit a030e7f

Please sign in to comment.