Skip to content

Commit dabd169

Browse files
KyleFromKitwarekwrobot
authored andcommitted
Merge topic 'cuda_separable_compilation_determined_by_compiler_id'
a233e4e CUDA: Compilers can now state they don't require a device linking step Acked-by: Kitware Robot <[email protected]> Merge-request: !3659
2 parents f952d9c + a233e4e commit dabd169

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
CUDA_RESOLVE_DEVICE_SYMBOLS
22
---------------------------
33

4-
CUDA only: Enables device linking for the specific library target
5-
6-
If set this will enable device linking on the library target. Normally
7-
device linking is deferred until a shared library or executable is generated,
8-
allowing for multiple static libraries to resolve device symbols at the same
9-
time when they are used by a shared library or executable.
4+
CUDA only: Enables device linking for the specific library target where
5+
required.
6+
7+
If set, this will tell the required compilers to enable device linking
8+
on the library target. Device linking is an additional link step
9+
required by some CUDA compilers when :prop_tgt:`CUDA_SEPARABLE_COMPILATION` is
10+
enabled. Normally device linking is deferred until a shared library or
11+
executable is generated, allowing for multiple static libraries to resolve
12+
device symbols at the same time when they are used by a shared library or
13+
executable.
1014

1115
By default static library targets have this property is disabled,
1216
while shared, module, and executable targets have this property enabled.

Modules/CMakeCUDAInformation.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ if(NOT CMAKE_CUDA_LINK_EXECUTABLE)
171171
"<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
172172
endif()
173173

174-
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
174+
if( CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
175+
CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
175176
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
176177
else()
177178
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")

Modules/Compiler/NVIDIA-CUDA.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True)
12
set(CMAKE_CUDA_VERBOSE_FLAG "-v")
23
set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v")
34

Source/cmLinkLineDeviceComputer.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "cmGeneratorTarget.h"
1414
#include "cmGlobalGenerator.h"
1515
#include "cmLocalGenerator.h"
16+
#include "cmMakefile.h"
1617
#include "cmStateDirectory.h"
1718
#include "cmStateSnapshot.h"
1819
#include "cmStateTypes.h"
@@ -156,6 +157,10 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
156157
return false;
157158
}
158159

160+
if (!lg.GetMakefile()->IsOn("CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE")) {
161+
return false;
162+
}
163+
159164
if (const char* resolveDeviceSymbols =
160165
target.GetProperty("CUDA_RESOLVE_DEVICE_SYMBOLS")) {
161166
// If CUDA_RESOLVE_DEVICE_SYMBOLS has been explicitly set we need

0 commit comments

Comments
 (0)