CUDA: Use local shorthands for variables in Clang device link code
Helps reduce wrapping of lines making code more readable.
This commit is contained in:
parent
cf7e68087d
commit
15fde4c420
@ -1530,9 +1530,9 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule(
|
||||
return;
|
||||
}
|
||||
|
||||
cmLocalUnixMakefileGenerator3* localGen{ this->LocalGenerator };
|
||||
std::vector<std::string> architectures = cmExpandedList(architecturesStr);
|
||||
std::string const& relPath =
|
||||
this->LocalGenerator->GetHomeRelativeOutputPath();
|
||||
std::string const& relPath = localGen->GetHomeRelativeOutputPath();
|
||||
|
||||
// Ensure there are no duplicates.
|
||||
const std::vector<std::string> linkDeps = [&]() -> std::vector<std::string> {
|
||||
@ -1552,12 +1552,12 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule(
|
||||
|
||||
const std::string objectDir = this->GeneratorTarget->ObjectDirectory;
|
||||
const std::string relObjectDir =
|
||||
this->LocalGenerator->MaybeRelativeToCurBinDir(objectDir);
|
||||
localGen->MaybeRelativeToCurBinDir(objectDir);
|
||||
|
||||
// Construct a list of files associated with this executable that
|
||||
// may need to be cleaned.
|
||||
std::vector<std::string> cleanFiles;
|
||||
cleanFiles.push_back(this->LocalGenerator->MaybeRelativeToCurBinDir(output));
|
||||
cleanFiles.push_back(localGen->MaybeRelativeToCurBinDir(output));
|
||||
|
||||
std::string profiles;
|
||||
std::vector<std::string> fatbinaryDepends;
|
||||
@ -1594,8 +1594,8 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule(
|
||||
" -arch=sm_", architecture, registerFileCmd, " -o=$@ ",
|
||||
cmJoin(linkDeps, " "));
|
||||
|
||||
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, cubin,
|
||||
linkDeps, { command }, false);
|
||||
localGen->WriteMakeRule(*this->BuildFileStream, nullptr, cubin, linkDeps,
|
||||
{ command }, false);
|
||||
}
|
||||
|
||||
// Combine all architectures into a single fatbinary.
|
||||
@ -1609,9 +1609,8 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule(
|
||||
const std::string fatbinaryOutputRel =
|
||||
cmStrCat(relPath, relObjectDir, "cmake_cuda_fatbin.h");
|
||||
|
||||
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
|
||||
fatbinaryOutputRel, fatbinaryDepends,
|
||||
{ fatbinaryCommand }, false);
|
||||
localGen->WriteMakeRule(*this->BuildFileStream, nullptr, fatbinaryOutputRel,
|
||||
fatbinaryDepends, { fatbinaryCommand }, false);
|
||||
|
||||
// Compile the stub that registers the kernels and contains the
|
||||
// fatbinaries.
|
||||
@ -1630,13 +1629,12 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule(
|
||||
|
||||
std::string compileCmd = this->GetLinkRule("CMAKE_CUDA_DEVICE_LINK_COMPILE");
|
||||
std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
|
||||
this->LocalGenerator->CreateRulePlaceholderExpander());
|
||||
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
|
||||
compileCmd, vars);
|
||||
localGen->CreateRulePlaceholderExpander());
|
||||
rulePlaceholderExpander->ExpandRuleVariables(localGen, compileCmd, vars);
|
||||
|
||||
commands.emplace_back(compileCmd);
|
||||
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, output,
|
||||
{ fatbinaryOutputRel }, commands, false);
|
||||
localGen->WriteMakeRule(*this->BuildFileStream, nullptr, output,
|
||||
{ fatbinaryOutputRel }, commands, false);
|
||||
|
||||
// Clean all the possible executable names and symlinks.
|
||||
this->CleanFiles.insert(cleanFiles.begin(), cleanFiles.end());
|
||||
|
@ -744,9 +744,10 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatements(
|
||||
return deps;
|
||||
}();
|
||||
|
||||
cmGlobalNinjaGenerator* globalGen{ this->GetGlobalGenerator() };
|
||||
const std::string objectDir =
|
||||
cmStrCat(this->GeneratorTarget->GetSupportDirectory(),
|
||||
this->GetGlobalGenerator()->ConfigDirectory(config));
|
||||
globalGen->ConfigDirectory(config));
|
||||
const std::string ninjaOutputDir = this->ConvertToNinjaPath(objectDir);
|
||||
|
||||
cmNinjaBuild fatbinary(this->LanguageLinkerCudaFatbinaryRule(config));
|
||||
@ -777,26 +778,23 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatements(
|
||||
cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin);
|
||||
fatbinary.ExplicitDeps.emplace_back(cubin);
|
||||
|
||||
this->GetGlobalGenerator()->WriteBuild(this->GetCommonFileStream(), dlink);
|
||||
globalGen->WriteBuild(this->GetCommonFileStream(), dlink);
|
||||
}
|
||||
|
||||
// Combine all architectures into a single fatbinary.
|
||||
fatbinary.Outputs = { cmStrCat(ninjaOutputDir, "/cmake_cuda_fatbin.h") };
|
||||
this->GetGlobalGenerator()->WriteBuild(this->GetCommonFileStream(),
|
||||
fatbinary);
|
||||
globalGen->WriteBuild(this->GetCommonFileStream(), fatbinary);
|
||||
|
||||
// Compile the stub that registers the kernels and contains the fatbinaries.
|
||||
cmLocalNinjaGenerator* localGen{ this->GetLocalGenerator() };
|
||||
cmNinjaBuild dcompile(this->LanguageLinkerCudaDeviceCompileRule(config));
|
||||
dcompile.Outputs = { output };
|
||||
dcompile.ExplicitDeps = { cmStrCat(ninjaOutputDir, "/cmake_cuda_fatbin.h") };
|
||||
dcompile.Variables["FATBIN"] =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
cmStrCat(objectDir, "/cmake_cuda_fatbin.h"), cmOutputConverter::SHELL);
|
||||
dcompile.Variables["REGISTER"] =
|
||||
this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
cmStrCat(objectDir, "/cmake_cuda_register.h"), cmOutputConverter::SHELL);
|
||||
this->GetGlobalGenerator()->WriteBuild(this->GetCommonFileStream(),
|
||||
dcompile);
|
||||
dcompile.Variables["FATBIN"] = localGen->ConvertToOutputFormat(
|
||||
cmStrCat(objectDir, "/cmake_cuda_fatbin.h"), cmOutputConverter::SHELL);
|
||||
dcompile.Variables["REGISTER"] = localGen->ConvertToOutputFormat(
|
||||
cmStrCat(objectDir, "/cmake_cuda_register.h"), cmOutputConverter::SHELL);
|
||||
globalGen->WriteBuild(this->GetCommonFileStream(), dcompile);
|
||||
}
|
||||
|
||||
void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkStatement(
|
||||
|
Loading…
Reference in New Issue
Block a user