mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-11 16:50:50 -05:00
Cuda: ResolveDeviceSymbols now properly execute everywhere.
The previous version had two bugs that caused the JIT runtime errors. 1. It was building the executable without separable compilation enabled 2. All kernel launches will fail if any kernel is missing a symbol, that is why the call to file2_launch_kernel had to be removed
This commit is contained in:
@@ -16,11 +16,11 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
#Goal for this example:
|
#Goal for this example:
|
||||||
#Build a static library that defines multiple methods and kernels that
|
# Build a static library that defines multiple methods and kernels that
|
||||||
#use each other.
|
# use each other.
|
||||||
#Use a custom command to build an executable that uses this static library
|
# Resolve the device symbols into that static library
|
||||||
#We do these together to verify that we can get a static library to do
|
# Verify that we can't use those device symbols from anything that links
|
||||||
#device symbol linking, and not have it done when the executable is made
|
# to the static library
|
||||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CUDA_STANDARD 11)
|
set(CMAKE_CUDA_STANDARD 11)
|
||||||
@@ -43,6 +43,10 @@ add_custom_command(TARGET CUDAResolveDeviceLib POST_BUILD
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(CudaOnlyResolveDeviceSymbols main.cu)
|
add_executable(CudaOnlyResolveDeviceSymbols main.cu)
|
||||||
|
set_target_properties(CudaOnlyResolveDeviceSymbols
|
||||||
|
PROPERTIES
|
||||||
|
CUDA_SEPARABLE_COMPILATION ON)
|
||||||
|
|
||||||
target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib)
|
target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|||||||
@@ -62,17 +62,8 @@ int main(int argc, char** argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cudaError_t err;
|
|
||||||
file2_launch_kernel(42);
|
|
||||||
err = cudaGetLastError();
|
|
||||||
if (err != cudaSuccess) {
|
|
||||||
std::cerr << "file2_launch_kernel: kernel launch failed: "
|
|
||||||
<< cudaGetErrorString(err) << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
main_launch_kernel(1);
|
main_launch_kernel(1);
|
||||||
err = cudaGetLastError();
|
cudaError_t err = cudaGetLastError();
|
||||||
if (err == cudaSuccess) {
|
if (err == cudaSuccess) {
|
||||||
// This kernel launch should fail as the file2_func was device linked
|
// This kernel launch should fail as the file2_func was device linked
|
||||||
// into the static library and is not usable by the executable
|
// into the static library and is not usable by the executable
|
||||||
|
|||||||
Reference in New Issue
Block a user