mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 06:47:08 -05:00
HIP: Add support for NVIDIA GPUs
Add support for using the CUDA Toolkit's NVCC to compile HIP code. Fixes: #25143
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user