Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch hip::device target to allow compilation/running without FindHIP #541

Merged
merged 8 commits into from
Nov 8, 2021
26 changes: 26 additions & 0 deletions cmake/thirdparty/SetupHIP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,29 @@ blt_import_library(NAME blt::hip_runtime
DEPENDS_ON hip::host
TREAT_INCLUDES_AS_SYSTEM ON
EXPORTABLE ${BLT_EXPORT_THIRDPARTY})

# AMDGPU_TARGETS should be defined in the hip-config.cmake that gets "included" via find_package(hip)
# This file is also what hardcodes the --offload-arch flags we're removing here
if(DEFINED AMDGPU_TARGETS)
joshessman-llnl marked this conversation as resolved.
Show resolved Hide resolved
# If we haven't selected a particular architecture via CMAKE_HIP_ARCHITECTURES,
# we want to remove the unconditionally added compile/link flags from the hip::device target.
# FIXME: This may cause problems for targets whose HIP_ARCHITECTURES property differs
# from CMAKE_HIP_ARCHITECTURES - this only happens when a user manually modifies
# the property after it is initialized
get_target_property(_hip_compile_options hip::device INTERFACE_COMPILE_OPTIONS)
get_target_property(_hip_link_libs hip::device INTERFACE_LINK_LIBRARIES)

foreach(_target ${AMDGPU_TARGETS})
if (NOT "${CMAKE_HIP_ARCHITECTURES}" MATCHES "${_target}")
list(REMOVE_ITEM _hip_compile_options "--offload-arch=${_target}")
list(REMOVE_ITEM _hip_link_libs "--offload-arch=${_target}")
endif()
endforeach()

set_property(TARGET hip::device PROPERTY INTERFACE_COMPILE_OPTIONS ${_hip_compile_options})
set_property(TARGET hip::device PROPERTY INTERFACE_LINK_LIBRARIES ${_hip_link_libs})

if(DEFINED CMAKE_HIP_ARCHITECTURES)
set(AMDGPU_TARGETS "${CMAKE_HIP_ARCHITECTURES}" CACHE STRING "" FORCE)
endif()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# HPE Cray cce@12.0.0 compilers
# HPE Cray cce@12.0.1 compilers
#------------------------------------------------------------------------------
# _blt_tutorial_compiler_config_start
set(CCE_HOME "/usr/tce/packages/cce-tce/cce-12.0.0")
set(CCE_HOME "/usr/tce/packages/cce-tce/cce-12.0.1")
set(CMAKE_C_COMPILER "${CCE_HOME}/bin/craycc" CACHE PATH "")
set(CMAKE_CXX_COMPILER "${CCE_HOME}/bin/crayCC" CACHE PATH "")

Expand All @@ -30,7 +30,7 @@ set(CMAKE_Fortran_COMPILER "${CCE_HOME}/bin/crayftn" CACHE PATH "")
# _blt_tutorial_mpi_config_start
set(ENABLE_MPI ON CACHE BOOL "")

set(MPI_HOME "/usr/tce/packages/cray-mpich-tce/cray-mpich-8.1.5.6-cce-12.0.0/")
set(MPI_HOME "/usr/tce/packages/cray-mpich-tce/cray-mpich-8.1.7-cce-12.0.1/")
set(MPI_C_COMPILER "${MPI_HOME}/bin/mpicc" CACHE PATH "")

set(MPI_CXX_COMPILER "${MPI_HOME}/bin/mpicxx" CACHE PATH "")
Expand All @@ -44,9 +44,9 @@ set(MPI_Fortran_COMPILER "${MPI_HOME}/bin/mpif90" CACHE PATH "")
# _blt_tutorial_hip_config_start
set(ENABLE_HIP ON CACHE BOOL "")

set(ROCM_PATH "/opt/rocm-4.1.0/" CACHE PATH "")

set(BLT_CLANG_HIP_ARCH "gfx908" CACHE STRING "")
set(ROCM_PATH "/opt/rocm-4.2.0/" CACHE PATH "")
set(HIP_PLATFORM "clang" CACHE STRING "")
set(CMAKE_HIP_ARCHITECTURES "gfx908" CACHE STRING "gfx architecture to use when generating HIP/ROCm code")

# _blt_tutorial_hip_config_end

44 changes: 44 additions & 0 deletions host-configs/llnl/toss_4_x86_64_ib_cray/cce@12.0.3_clang_hip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2017-2021, Lawrence Livermore National Security, LLC and
kennyweiss marked this conversation as resolved.
Show resolved Hide resolved
# other BLT Project Developers. See the top-level LICENSE file for details
#
# SPDX-License-Identifier: (BSD-3-Clause)

#------------------------------------------------------------------------------
# Example host-config file for the rzwhamo cluster at LLNL
#------------------------------------------------------------------------------
# This file provides CMake with paths / details for:
# C,C++, & Fortran compilers + MPI & HIP
# using tce wrappers, rather than HPE Cray PE compiler drivers
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# HPE Cray cce@12.0.3 compilers
#------------------------------------------------------------------------------
set(CCE_HOME "/usr/tce/packages/cce-tce/cce-12.0.3")
set(CMAKE_C_COMPILER "${CCE_HOME}/bin/craycc" CACHE PATH "")
set(CMAKE_CXX_COMPILER "${CCE_HOME}/bin/crayCC" CACHE PATH "")

# Fortran support
set(ENABLE_FORTRAN ON CACHE BOOL "")
set(CMAKE_Fortran_COMPILER "${CCE_HOME}/bin/crayftn" CACHE PATH "")

#------------------------------------------------------------------------------
# MPI Support
#------------------------------------------------------------------------------
set(ENABLE_MPI ON CACHE BOOL "")

set(MPI_HOME "/usr/tce/packages/cray-mpich-tce/cray-mpich-8.1.8-cce-12.0.3/")
set(MPI_C_COMPILER "${MPI_HOME}/bin/mpicc" CACHE PATH "")

set(MPI_CXX_COMPILER "${MPI_HOME}/bin/mpicxx" CACHE PATH "")

set(MPI_Fortran_COMPILER "${MPI_HOME}/bin/mpif90" CACHE PATH "")

#------------------------------------------------------------------------------
# HIP support
#------------------------------------------------------------------------------
set(ENABLE_HIP ON CACHE BOOL "")

set(ROCM_PATH "/opt/rocm-4.5.0/" CACHE PATH "")
set(HIP_PLATFORM "clang" CACHE STRING "")
set(CMAKE_HIP_ARCHITECTURES "gfx908" CACHE STRING "gfx architecture to use when generating HIP/ROCm code")
2 changes: 1 addition & 1 deletion tests/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ endif()

message(STATUS "Exercising blt_print_target_properties macro on some targets and non-targets.")
message(STATUS "")
foreach(_target gtest example t_example_smoke not-a-target blt_header_only mpi cuda cuda_runtime)
foreach(_target gtest example t_example_smoke not-a-target blt_header_only mpi cuda cuda_runtime hip hip_runtime)
blt_print_target_properties(TARGET ${_target})
endforeach()

Expand Down