diff options
author | Brad King <brad.king@kitware.com> | 2023-09-18 19:46:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-09-21 19:34:37 (GMT) |
commit | 18158bf81ccb5269afcfa53cd671cf7f56dc70b5 (patch) | |
tree | c7877ec383af7831f4feb431ceb7dbe7d048d368 /Source | |
parent | 127b6fa06bf53ad9f31d041a7d11434ca2856c8e (diff) | |
download | CMake-18158bf81ccb5269afcfa53cd671cf7f56dc70b5.zip CMake-18158bf81ccb5269afcfa53cd671cf7f56dc70b5.tar.gz CMake-18158bf81ccb5269afcfa53cd671cf7f56dc70b5.tar.bz2 |
HIP: Add support for NVIDIA GPUs
Add support for using the CUDA Toolkit's NVCC to compile HIP code.
Fixes: #25143
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 11 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 80e3392..ca38be6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3579,9 +3579,11 @@ void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const } } -void cmGeneratorTarget::AddHIPArchitectureFlags(std::string& flags) const +void cmGeneratorTarget::AddHIPArchitectureFlags(cmBuildStep compileOrLink, + std::string const& config, + std::string& flags) const { - const std::string& arch = this->GetSafeProperty("HIP_ARCHITECTURES"); + std::string arch = this->GetSafeProperty("HIP_ARCHITECTURES"); if (arch.empty()) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, @@ -3594,6 +3596,11 @@ void cmGeneratorTarget::AddHIPArchitectureFlags(std::string& flags) const return; } + if (this->Makefile->GetSafeDefinition("CMAKE_HIP_PLATFORM") == "nvidia") { + return this->AddCUDAArchitectureFlagsImpl(compileOrLink, config, "HIP", + std::move(arch), flags); + } + cmList options(arch); for (std::string& option : options) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6a385ea..751f907 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -504,7 +504,9 @@ public: std::string& flags) const; void AddCUDAToolkitFlags(std::string& flags) const; - void AddHIPArchitectureFlags(std::string& flags) const; + void AddHIPArchitectureFlags(cmBuildStep compileOrLink, + std::string const& config, + std::string& flags) const; void AddISPCTargetFlags(std::string& flags) const; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 63c8aa8..2325579 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -87,6 +87,8 @@ static auto ruleReplaceVars = { "CMAKE_${LANG}_COMPILER", "CMAKE_TAPI", "CMAKE_CUDA_HOST_COMPILER", "CMAKE_CUDA_HOST_LINK_LAUNCHER", + "CMAKE_HIP_HOST_COMPILER", + "CMAKE_HIP_HOST_LINK_LAUNCHER", "CMAKE_CL_SHOWINCLUDES_PREFIX" }; cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile) @@ -2058,7 +2060,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, this->Makefile->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"); } } else if (lang == "HIP") { - target->AddHIPArchitectureFlags(flags); + target->AddHIPArchitectureFlags(compileOrLink, config, flags); } // Add VFS Overlay for Clang compilers |