Skip to content

Commit

Permalink
Merge pull request #608 from LLNL/bugfix/white238/crayftn_hip
Browse files Browse the repository at this point in the history
Fixes `crayftn` + hip
  • Loading branch information
white238 authored Nov 18, 2022
2 parents 97ea54d + a624eb8 commit 8c22999
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/

## [Unreleased] - Release date yyyy-mm-dd

### Fixed
- Guard HIP compiler flag ``--rocm-path=/path/to/rocm`` against Crayftn compiler earlier than 15.0.0.

## [Version 0.5.2] - Release date 2022-10-05

### Added
Expand Down
31 changes: 18 additions & 13 deletions cmake/thirdparty/SetupHIP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
#
# SPDX-License-Identifier: (BSD-3-Clause)

# Author: Noel Chalmers @ Advanced Micro Devices, Inc.
# Date: March 11, 2019

################################
# HIP
################################

if (NOT ROCM_PATH)
if(NOT ROCM_PATH)
find_path(ROCM_PATH
hip
ENV{ROCM_DIR}
Expand Down Expand Up @@ -43,7 +40,7 @@ if(DEFINED AMDGPU_TARGETS)
get_target_property(_hip_link_libs hip::device INTERFACE_LINK_LIBRARIES)

foreach(_target ${AMDGPU_TARGETS})
if (NOT "${CMAKE_HIP_ARCHITECTURES}" MATCHES "${_target}")
if(NOT "${CMAKE_HIP_ARCHITECTURES}" MATCHES "${_target}")
set(_flag "--offload-arch=${_target}")
set(_generator_compile_flag "$<$<COMPILE_LANGUAGE:CXX>:SHELL:${_flag}>")
set(_generator_link_flag "$<$<LINK_LANGUAGE:CXX>:${_flag}>")
Expand All @@ -65,14 +62,22 @@ endif()

# hip targets must be global for aliases when created as imported targets
set(_blt_hip_is_global On)
if (${BLT_EXPORT_THIRDPARTY})
if(${BLT_EXPORT_THIRDPARTY})
set(_blt_hip_is_global Off)
endif ()
endif()

blt_import_library(NAME blt_hip
COMPILE_FLAGS "--rocm-path=${ROCM_PATH}"
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}
GLOBAL ${_blt_hip_is_global})
# Guard against `--rocm-path` being added to crayftn less than version 15.0.0 due to
# invalid command line option error
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Cray" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15.0.0)
set(_blt_hip_compile_flags "$<$<COMPILE_LANGUAGE:CXX>:SHELL:--rocm-path=${ROCM_PATH}>")
else()
set(_blt_hip_compile_flags "--rocm-path=${ROCM_PATH}")
endif()

blt_import_library(NAME blt_hip
COMPILE_FLAGS ${_blt_hip_compile_flags}
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}
GLOBAL ${_blt_hip_is_global})

# Hard-copy inheritable properties instead of depending on hip::device so that we can export all required
# information in our target blt_hip
Expand All @@ -81,10 +86,10 @@ blt_inherit_target_info(TO blt_hip FROM hip::device OBJECT FALSE)
add_library(blt::hip ALIAS blt_hip)

blt_import_library(NAME blt_hip_runtime
INCLUDES ${HIP_INCLUDE_DIRS}
INCLUDES ${HIP_INCLUDE_DIRS}
TREAT_INCLUDES_AS_SYSTEM ON
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}
GLOBAL ${_blt_hip_is_global})
GLOBAL ${_blt_hip_is_global})

blt_inherit_target_info(TO blt_hip_runtime FROM hip::host OBJECT FALSE)

Expand Down

0 comments on commit 8c22999

Please sign in to comment.