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

WIP: Feature/probinso/hipcc support #596

Open
wants to merge 70 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7563ed8
recursive and regex
chapman39 Aug 3, 2022
0518043
gitignore workspace
chapman39 Aug 3, 2022
efb0907
desc
chapman39 Aug 3, 2022
19311d8
regex for properties
chapman39 Aug 9, 2022
0ce11e4
remove duplicates of entire tree
chapman39 Aug 10, 2022
6b79fce
remove enter
chapman39 Aug 10, 2022
ed3eae6
lowercase a
chapman39 Aug 10, 2022
8c938db
Merge remote-tracking branch 'origin/develop' into feature/chapman39/…
chapman39 Aug 10, 2022
44bdd7a
Update cmake/BLTMacros.cmake
chapman39 Aug 22, 2022
6a37c24
if regex undefined, don't use MATCHES
chapman39 Aug 22, 2022
c7fe954
tlist doesn't need a particular name
chapman39 Aug 22, 2022
9c3c6d2
Merge branch 'develop' into feature/chapman39/print_target_properties…
chapman39 Aug 23, 2022
56b745d
docs and simpler print
chapman39 Aug 23, 2022
76b7512
Merge branch 'feature/chapman39/print_target_properties_recursive' of…
chapman39 Aug 23, 2022
f6b9ac5
adding tioga
chapman39 Aug 23, 2022
4620b70
Merge branch 'develop' into feature/chapman39/replace_corona_with_tioga
chapman39 Aug 23, 2022
e86f979
remove corona and add tioga to ci
chapman39 Aug 23, 2022
fd157dd
Merge branch 'feature/chapman39/replace_corona_with_tioga' of github.…
chapman39 Aug 23, 2022
9d977f5
no --test-serial
chapman39 Aug 23, 2022
b6cb3a4
fix errors
chapman39 Aug 23, 2022
0e79e46
no build_on_tioga
chapman39 Aug 24, 2022
e950724
typo
chapman39 Aug 24, 2022
f697144
patch from ALE3D
robinson96 Aug 30, 2022
1e96e23
cleanup
robinson96 Aug 30, 2022
8cbd0d3
using flux
chapman39 Aug 30, 2022
7f57b0f
update flux cmds
chapman39 Sep 1, 2022
4141f19
fixed host-config path
chapman39 Sep 13, 2022
7b3b13d
Merge pull request #595 from LLNL/feature/chapman39/replace_corona_wi…
chapman39 Sep 13, 2022
6ae5448
Merge branch 'develop' into feature/chapman39/print_target_properties…
chapman39 Sep 13, 2022
3d08ef3
PROPERTY_VALUE_REGEX, prints blt_reg depends_on
chapman39 Sep 14, 2022
62261a0
typo
chapman39 Sep 16, 2022
0fcafac
updated docs, added examples, fixed bugs
chapman39 Sep 16, 2022
78ef818
Merge branch 'feature/chapman39/print_target_properties_recursive' of…
chapman39 Sep 16, 2022
d3c40a1
rename recursive function
chapman39 Sep 16, 2022
f314801
infinite loop edge case fix
chapman39 Sep 19, 2022
fd80b90
explain new print options
chapman39 Sep 21, 2022
376099c
apostrophe
chapman39 Sep 21, 2022
d808991
code style
chapman39 Sep 21, 2022
e31b6de
wording
chapman39 Sep 22, 2022
1f0463a
new macos imagename
chapman39 Sep 23, 2022
401f967
Update RELEASE-NOTES.md
chapman39 Sep 26, 2022
1bfd1d1
Add BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE variable
bmhan12 Sep 28, 2022
16fd27d
more fixes, switch to using BLT_BULD_HIP_WITH_HIPCC
robinson96 Sep 29, 2022
f2dbca5
clarity/ cleanup suggestions
chapman39 Sep 29, 2022
3a32077
Merge branch 'feature/chapman39/print_target_properties_recursive' of…
chapman39 Sep 29, 2022
74d1cd9
wording
chapman39 Sep 29, 2022
0142ece
wording for print target macro desc
chapman39 Sep 29, 2022
5aa089a
re-add 'property' to target type
chapman39 Oct 3, 2022
197eacc
Merge pull request #590 from LLNL/feature/chapman39/print_target_prop…
white238 Oct 4, 2022
6bd8250
add axom try_compile macro to blt
kennyweiss Oct 4, 2022
8b6a419
turn on CMP0067 even though it only works on some CMake versions
white238 Oct 4, 2022
7901598
documentation and release notes for blt_check_code_compiles
white238 Oct 4, 2022
a3e380e
add clarifying note
white238 Oct 4, 2022
a221641
add comment about bracket arguments
white238 Oct 4, 2022
517ccd4
Merge pull request #600 from LLNL/feature/white238/add_try_compile
white238 Oct 4, 2022
17890f4
Merge branch 'develop' into feature/han12/implicit_libs_exclude
bmhan12 Oct 4, 2022
43f0b41
Merge pull request #598 from LLNL/feature/han12/implicit_libs_exclude
white238 Oct 5, 2022
ee5d430
bump version
white238 Oct 5, 2022
84fe0d1
Merge pull request #601 from LLNL/v0.5.2-rc
white238 Oct 5, 2022
97ea54d
Merge pull request #602 from LLNL/main
white238 Oct 5, 2022
9cc55a2
Guard compiler flag against crayftn
BurlMHall Nov 18, 2022
5fbc647
release notes
white238 Nov 18, 2022
2b6676b
consistent formatting
white238 Nov 18, 2022
a624eb8
allow starting at 15.0.0
white238 Nov 18, 2022
8c22999
Merge pull request #608 from LLNL/bugfix/white238/crayftn_hip
white238 Nov 18, 2022
98ee862
Merge branch 'feature/probinso/hipcc_support' into ale3d
robinson96 Dec 8, 2022
8d39e04
merge blt changes from ale3d develop to new submodule.
robinson96 Jan 11, 2023
bf2d30b
whitespace cleanup.
robinson96 Jan 11, 2023
c92ef98
reduce differences from pristine.
robinson96 Jan 11, 2023
896f04f
fix logic in setting BLT_ADD_ROCM_PATH_COMPILER_FLAG
robinson96 Jan 14, 2023
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
4 changes: 3 additions & 1 deletion SetupBLT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ if (NOT BLT_LOADED)
# File extension lists used to filter sources based on languages for code checks
# and filtering Fortran sources out of cuda/hip source lists
# Note: this filtering is case-insensitive
set(BLT_C_FILE_EXTS ".cpp" ".hpp" ".cxx" ".hxx" ".c" ".h" ".cc" ".hh" ".inl" ".cu" ".cuh"
set(BLT_C_FILE_EXTS ".c" ".h"
CACHE STRING "List of known file extensions used for C/CXX sources")
Copy link
Member

Choose a reason for hiding this comment

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

Update the comment to say C rather than C/CXX. And the following comment should have CXX instead of C/CXX.

Copy link
Member

Choose a reason for hiding this comment

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

This will have pretty large user facing consequences and needs to be considered carefully.

Copy link
Member

Choose a reason for hiding this comment

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

set(BLT_CXX_FILE_EXTS ".cpp" ".hpp" ".cxx" ".hxx" ".cc" ".hh" ".inl" ".cu" ".cuh"
CACHE STRING "List of known file extensions used for C/CXX sources")
set(BLT_Fortran_FILE_EXTS ".f" ".f90"
CACHE STRING "List of known file extensions used for Fortran sources")
Expand Down
14 changes: 13 additions & 1 deletion cmake/BLTMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,13 @@ macro(blt_add_library)
DEPENDS_ON ${arg_DEPENDS_ON}
LIBRARY_TYPE ${_lib_type})
endif()
if (ENABLE_HIP)
blt_setup_hip_target(
NAME ${arg_NAME}
SOURCES ${arg_SOURCES}
DEPENDS_ON ${arg_DEPENDS_ON}
LIBRARY_TYPE ${_lib_type})
endif()
else()
#
# Header-only library support
Expand Down Expand Up @@ -732,7 +739,6 @@ macro(blt_add_library)
# the white-list of properties that are allowed
blt_clean_target(TARGET ${arg_NAME})
endif()

endmacro(blt_add_library)


Expand Down Expand Up @@ -776,6 +782,12 @@ macro(blt_add_executable)
SOURCES ${arg_SOURCES}
DEPENDS_ON ${arg_DEPENDS_ON})
endif()
if (ENABLE_HIP)
blt_setup_hip_target(
NAME ${arg_NAME}
SOURCES ${arg_SOURCES}
DEPENDS_ON ${arg_DEPENDS_ON})
endif()

# CMake wants to load with C++ if any of the libraries are C++.
# Force to load with Fortran if the first file is Fortran.
Expand Down
94 changes: 92 additions & 2 deletions cmake/BLTPrivateMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ macro(blt_find_executable)
string(TOUPPER ${arg_NAME} _ucname)

message(STATUS "${arg_NAME} support is ${ENABLE_${_ucname}}")
if (ENABLE_${_ucname})
if (${ENABLE_${_ucname}})
set(_exes ${arg_NAME})
if (DEFINED arg_EXECUTABLES)
set(_exes ${arg_EXECUTABLES})
Expand Down Expand Up @@ -491,6 +491,87 @@ macro(blt_setup_target)

endmacro(blt_setup_target)

##------------------------------------------------------------------------------
## blt_setup_hip_target(NAME <name of target>
## SOURCES <list of sources>
## DEPENDS_ON <list of dependencies>
## LIBRARY_TYPE <STATIC, SHARED, OBJECT, or blank for executables>)
##------------------------------------------------------------------------------
macro(blt_setup_hip_target)

set(options)
set(singleValueArgs NAME LIBRARY_TYPE)
set(multiValueArgs SOURCES DEPENDS_ON)

# Parse the arguments
cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
"${multiValueArgs}" ${ARGN} )

# Check arguments
if ( NOT DEFINED arg_NAME )
message( FATAL_ERROR "Must provide a NAME argument to the 'blt_setup_hip_target' macro")
endif()

if ( NOT DEFINED arg_SOURCES )
message( FATAL_ERROR "Must provide SOURCES to the 'blt_setup_hip_target' macro")
endif()

# Determine if hip or hip_runtime are in DEPENDS_ON
list(FIND arg_DEPENDS_ON "blt::hip" _hip_index)
set(_depends_on_hip FALSE)
if(${_hip_index} GREATER -1)
set(_depends_on_hip TRUE)
endif()
list(FIND arg_DEPENDS_ON "blt::hip_runtime" _hip_runtime_index)
set(_depends_on_hip_runtime FALSE)
if(${_hip_runtime_index} GREATER -1)
set(_depends_on_hip_runtime TRUE)
endif()
message("DEPENDS ON HIP ${_depends_on_hip} DEPENDS_ON_HIP_RUNTIME ${_depends_on_hip_runtime}\n\t ${arg_DEPENDS_ON}")
Copy link
Member

Choose a reason for hiding this comment

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

Is this a debug message? There are a few others like it as well.

if (${_depends_on_hip_runtime} OR ${_depends_on_hip})
if (HIP_LINK_WITH_HIPCC)
set_target_properties( ${arg_NAME} PROPERTIES LINKER_LANGUAGE HIP)
# This will be propagated up to executable targets that depend on this
# library, which will need the HIP linker
set_target_properties( ${arg_NAME} PROPERTIES INTERFACE_BLT_LINKER_LANGUAGE_OVERRIDE HIP)
endif()
endif()

if (${_depends_on_hip})
# if hip is in depends_on, flag each file's language as HIP
# instead of leaving it up to CMake to decide
# Note: we don't do this when depending on just 'hip_runtime'
set(_hip_sources)
set(_non_hip_sources)
blt_split_source_list_by_language(SOURCES ${arg_SOURCES}
CXX_LIST _hip_sources
C_LIST _non_hip_sources
Fortran_LIST _non_hip_sources)
message("ALL_SOURCES: ${arg_SOURCES}\n\t HIP SOURCES ${_hip_sources}")
set_source_files_properties( ${_hip_sources} PROPERTIES
LANGUAGE HIP)

# if (HIP_SEPARABLE_COMPILATION)
Copy link
Member

Choose a reason for hiding this comment

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

Can you document why this isn't being used?

# set_source_files_properties( ${_hip_sources} PROPERTIES
# HIP_SEPARABLE_COMPILATION ON)
# set_target_properties( ${arg_NAME} PROPERTIES
# HIP_SEPARABLE_COMPILATION ON)
# endif()

if (DEFINED arg_LIBRARY_TYPE)
if (${arg_LIBRARY_TYPE} STREQUAL "static")
set_target_properties( ${arg_NAME} PROPERTIES
CMAKE_HIP_CREATE_STATIC_LIBRARY ON)
else()
set_target_properties( ${arg_NAME} PROPERTIES
CMAKE_HIP_CREATE_STATIC_LIBRARY OFF)
endif()
endif()

endif()
# message(FATAL_ERROR "stopping")
endmacro(blt_setup_hip_target)


##------------------------------------------------------------------------------
## blt_setup_cuda_target(NAME <name of target>
Expand Down Expand Up @@ -546,6 +627,7 @@ macro(blt_setup_cuda_target)
set(_non_cuda_sources)
blt_split_source_list_by_language(SOURCES ${arg_SOURCES}
C_LIST _cuda_sources
CXX_LIST _cuda_sources
Fortran_LIST _non_cuda_sources)

set_source_files_properties( ${_cuda_sources} PROPERTIES
Expand Down Expand Up @@ -622,6 +704,7 @@ endmacro(blt_make_file_ext_regex)
##------------------------------------------------------------------------------
## blt_split_source_list_by_language( SOURCES <sources>
## C_LIST <list name>
## CXX_LIST <list name>
## Fortran_LIST <list name>
## Python_LIST <list name>
## CMAKE_LIST <list name>)
Expand All @@ -637,7 +720,7 @@ endmacro(blt_make_file_ext_regex)
macro(blt_split_source_list_by_language)

set(options)
set(singleValueArgs C_LIST Fortran_LIST Python_LIST CMAKE_LIST)
set(singleValueArgs C_LIST CXX_LIST Fortran_LIST Python_LIST CMAKE_LIST)
set(multiValueArgs SOURCES)

# Parse the arguments
Expand All @@ -653,6 +736,9 @@ macro(blt_split_source_list_by_language)
set(BLT_C_FILE_REGEX)
blt_make_file_ext_regex(EXTENSIONS ${BLT_C_FILE_EXTS}
OUTPUT_REGEX BLT_C_FILE_REGEX)
set(BLT_CXX_FILE_REGEX)
blt_make_file_ext_regex(EXTENSIONS ${BLT_CXX_FILE_EXTS}
OUTPUT_REGEX BLT_CXX_FILE_REGEX)
set(BLT_Fortran_FILE_REGEX)
blt_make_file_ext_regex(EXTENSIONS ${BLT_Fortran_FILE_EXTS}
OUTPUT_REGEX BLT_Fortran_FILE_REGEX)
Expand Down Expand Up @@ -686,6 +772,10 @@ macro(blt_split_source_list_by_language)
if (DEFINED arg_C_LIST)
list(APPEND ${arg_C_LIST} "${_file}")
endif()
elseif("${_lower_file}" MATCHES "${BLT_CXX_FILE_REGEX}")
if (DEFINED arg_CXX_LIST)
list(APPEND ${arg_CXX_LIST} "${_file}")
endif()
elseif("${_lower_file}" MATCHES "${BLT_Fortran_FILE_REGEX}")
if (DEFINED arg_Fortran_LIST)
list(APPEND ${arg_Fortran_LIST} "${_file}")
Expand Down
48 changes: 48 additions & 0 deletions cmake/thirdparty/SetupHIP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (NOT ROCM_PATH)
/opt/rocm)
endif()


# Update CMAKE_PREFIX_PATH to make sure all the configs that hip depends on are
# found.
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${ROCM_PATH}")
Expand All @@ -31,6 +32,9 @@ find_package(hip REQUIRED CONFIG PATHS ${HIP_PATH} ${ROCM_PATH})
message(STATUS "ROCM path: ${ROCM_PATH}")
message(STATUS "HIP version: ${hip_VERSION}")

if ( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21.0" )
enable_language(HIP)
endif()
# 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)
Expand All @@ -54,9 +58,47 @@ if(DEFINED AMDGPU_TARGETS)
list(REMOVE_ITEM _hip_link_libs ${_flag})
endif()
endforeach()
if (${BLT_BUILD_HIP_WITH_HIPCC})
list(REMOVE_ITEM _hip_compile_options "$<$<COMPILE_LANGUAGE:CXX>:SHELL:-mllvm")
list(REMOVE_ITEM _hip_compile_options "-amdgpu-early-inline-all=true")
list(REMOVE_ITEM _hip_compile_options "-mllvm")
list(REMOVE_ITEM _hip_compile_options "-amdgpu-function-calls=false>")
get_target_property(_hip_lang_compile_options hip-lang::device INTERFACE_COMPILE_OPTIONS)
set(_flag "-mllvm-amdgpu-early-inline-all=true-mllvm-amdgpu-function-calls=false")
set(_generator_compile_flag "$<$<COMPILE_LANGUAGE:HIP>:SHELL:${_flag}>")
list(REMOVE_ITEM _hip_lang_compile_options "$<$<COMPILE_LANGUAGE:HIP>:SHELL:-mllvm")
list(REMOVE_ITEM _hip_lang_compile_options "-amdgpu-early-inline-all=true")
list(REMOVE_ITEM _hip_lang_compile_options "-mllvm")
list(REMOVE_ITEM _hip_lang_compile_options "-amdgpu-function-calls=false>")
set_property(TARGET hip-lang::device PROPERTY INTERFACE_COMPILE_OPTIONS ${_hip_lang_compile_options})
endif()

# when we are using hipcc instead of amdclang, the hip cmake stuff fails to find the clang runtime link libraries
# and leaves CLANGRT_BUILTINS-NOTFOUND in the interface. We remove it here.
# Note sometimes the entry is the last entry of a generator expression, ending in '>', so we use transform to
# preserve the '>'
if (${BLT_BUILD_HIP_WITH_HIPCC})
get_target_property(_hip_lang_link_libs hip-lang::device INTERFACE_LINK_LIBRARIES)
get_target_property(_hip_host_link_libs hip::host INTERFACE_LINK_LIBRARIES)
list(TRANSFORM _hip_lang_link_libs REPLACE "CLANGRT_BUILTINS-NOTFOUND" "")
list(TRANSFORM _hip_host_link_libs REPLACE "CLANGRT_BUILTINS-NOTFOUND" "")
set_property(TARGET hip::host PROPERTY INTERFACE_LINK_LIBRARIES ${_hip_host_link_libs})
set_property(TARGET hip-lang::device PROPERTY INTERFACE_LINK_LIBRARIES ${_hip_lang_link_libs})
# also transform preexisting _hip_link_libs before set occurs after this conditional block
list(TRANSFORM _hip_link_libs REPLACE "CLANGRT_BUILTINS-NOTFOUND" "")
endif()

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 (${BLT_BUILD_HIP_WITH_HIPCC})
# remove interface include directories - these are bugged in ROCM 5.2.1
set_property(TARGET hip-lang::device PROPERTY INTERFACE_INCLUDE_DIRECTORIES "")
set_property(TARGET hip::device PROPERTY INTERFACE_INCLUDE_DIRECTORIES "")
set_property(TARGET hip::host PROPERTY INTERFACE_INCLUDE_DIRECTORIES "")
set_property(TARGET hip-lang::device PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "")
set_property(TARGET hip::device PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "")
set_property(TARGET hip::host PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "")
endif()

if(DEFINED CMAKE_HIP_ARCHITECTURES)
set(AMDGPU_TARGETS "${CMAKE_HIP_ARCHITECTURES}" CACHE STRING "" FORCE)
Expand All @@ -69,10 +111,16 @@ if (${BLT_EXPORT_THIRDPARTY})
set(_blt_hip_is_global Off)
endif ()

if (${BLT_BUILD_HIP_WITH_HIPCC})
blt_import_library(NAME blt_hip
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}
GLOBAL ${_blt_hip_is_global})
else()
blt_import_library(NAME blt_hip
COMPILE_FLAGS "--rocm-path=${ROCM_PATH}"
EXPORTABLE ${BLT_EXPORT_THIRDPARTY}
GLOBAL ${_blt_hip_is_global})
endif()

# Hard-copy inheritable properties instead of depending on hip::device so that we can export all required
# information in our target blt_hip
Expand Down