CUDA: More exhaustive checks to determine when to do device linking

Previously CMake used fairly naive logic to determine when to do
device linking which caused unnecessary device linking to occur
frequently. We now use a more exhaustive algorithm to determine
when we have a need for device linking.

Fixes: #19238
This commit is contained in:
Robert Maynard
2019-05-09 09:13:39 -04:00
parent 3205c7c950
commit 81b4d10d8f
7 changed files with 112 additions and 107 deletions
+3 -15
View File
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileExecutableTargetGenerator.h"
#include <algorithm>
#include <memory> // IWYU pragma: keep
#include <set>
#include <sstream>
@@ -87,20 +86,9 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
return;
}
const std::string cuda_lang("CUDA");
cmGeneratorTarget::LinkClosure const* closure =
this->GeneratorTarget->GetLinkClosure(this->ConfigName);
const bool hasCUDA =
(std::find(closure->Languages.begin(), closure->Languages.end(),
cuda_lang) != closure->Languages.end());
bool doDeviceLinking = true;
if (const char* resolveDeviceSymbols =
this->GeneratorTarget->GetProperty("CUDA_RESOLVE_DEVICE_SYMBOLS")) {
doDeviceLinking = cmSystemTools::IsOn(resolveDeviceSymbols);
}
if (!hasCUDA || !doDeviceLinking) {
bool requiresDeviceLinking = requireDeviceLinking(
*this->GeneratorTarget, *this->LocalGenerator, this->ConfigName);
if (!requiresDeviceLinking) {
return;
}