-
Notifications
You must be signed in to change notification settings - Fork 70
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
Enable compatibility with projects using HIP language #443
Open
lawruble13
wants to merge
2
commits into
ROCm:develop
Choose a base branch
from
lawruble13:hip-lang-compat
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+69
−30
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,10 +57,29 @@ list(APPEND CMAKE_MODULE_PATH | |
$ENV{ROCM_PATH}/llvm | ||
) | ||
|
||
# Detect if already using HIP language | ||
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) | ||
if(HIP IN_LIST ENABLED_LANGUAGES) | ||
# do stuff | ||
set(ROCRAND_LANG HIP) | ||
if (DEFINED CACHE{CMAKE_CXX_COMPILER} AND (CMAKE_CXX_COMPILER MATCHES ".*hipcc$" OR CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+")) | ||
# if the user's set the CXX compiler but not the HIP compiler, copy the value. | ||
set(CMAKE_HIP_COMPILER "${CMAKE_CXX_COMPILER}" CACHE PATH "The path to the HIP compiler.") | ||
endif() | ||
# if the user's set the HIP compiler but not the CXX compiler, copy the value. | ||
set(CMAKE_CXX_COMPILER "${CMAKE_HIP_COMPILER}" CACHE PATH "The path to the CXX compiler.") | ||
else() | ||
set(ROCRAND_LANG CXX) | ||
endif() | ||
|
||
# | ||
# rocRAND project | ||
# | ||
project(rocRAND CXX) | ||
project(rocRAND ${ROCRAND_LANG}) | ||
# If using the HIP language, enable CXX language as well | ||
if (ROCRAND_LANG STREQUAL HIP) | ||
enable_language(CXX) | ||
endif() | ||
# Set a default build type if none was specified | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to 'Release' as none was specified.") | ||
|
@@ -80,9 +99,9 @@ include(CMakeDependentOption) | |
include(cmake/Dependencies.cmake) | ||
|
||
# Detect compiler support for target ID | ||
if( CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" ) | ||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "--help" | ||
OUTPUT_VARIABLE CXX_OUTPUT | ||
if( CMAKE_${ROCRAND_LANG}_COMPILER MATCHES ".*/hipcc$" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hipcc cannot be used as the HIP language compiler. |
||
execute_process(COMMAND ${CMAKE_${ROCRAND_LANG}_COMPILER} "--help" | ||
OUTPUT_VARIABLE ${ROCRAND_LANG}_OUTPUT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_STRIP_TRAILING_WHITESPACE) | ||
string(REGEX MATCH ".mcode\-object\-version" TARGET_ID_SUPPORT ${CXX_OUTPUT}) | ||
|
@@ -118,17 +137,17 @@ endif() | |
# Build option to disable -Werror | ||
option(DISABLE_WERROR "Disable building with Werror" ON) | ||
|
||
# Build CXX flags | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
# Build CXX/HIP flags | ||
set(CMAKE_${ROCRAND_LANG}_STANDARD 11) | ||
set(CMAKE_${ROCRAND_LANG}_STANDARD_REQUIRED ON) | ||
set(CMAKE_${ROCRAND_LANG}_EXTENSIONS OFF) | ||
if(DISABLE_WERROR) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
set(CMAKE_${ROCRAND_LANG}_FLAGS "${CMAKE_${ROCRAND_LANG}_FLAGS} -Wall -Wextra") | ||
else() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") | ||
set(CMAKE_${ROCRAND_LANG}_FLAGS "${CMAKE_${ROCRAND_LANG}_FLAGS} -Wall -Wextra -Werror") | ||
endif() | ||
if(CODE_COVERAGE) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping") | ||
set(CMAKE_${ROCRAND_LANG}_FLAGS "${CMAKE_${ROCRAND_LANG}_FLAGS} -fprofile-instr-generate -fcoverage-mapping") | ||
endif() | ||
|
||
# HIP on Windows: xhip is required with clang++ to get __half defined | ||
|
@@ -141,7 +160,7 @@ if(BUILD_LEGACY_BENCHMARK) | |
message(DEPRECATION "Building the legacy benchmarks will be removed in a future release. Consider using the new benchmark suite.") | ||
endif() | ||
if(BUILD_ADDRESS_SANITIZER AND BUILD_SHARED_LIBS) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -shared-libasan") | ||
set(CMAKE_${ROCRAND_LANG}_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -shared-libasan") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -shared-libasan") | ||
add_link_options(-fuse-ld=lld) | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe just finish up #266 and suggest that users to set
-DROCRAND_CMAKE_HIP_LANGUAGE=ON
?