mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-11-18 01:48:16 +08:00
Post v13.5 (#470)
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules")
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/DetectCudaArch.cmake")
|
||||
|
||||
if(SAMPLE_SKIP_BUILD)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(localityDomainsDrv LANGUAGES C CXX CUDA)
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/CudaSampleCommon.cmake")
|
||||
|
||||
find_package(CUDAToolkit REQUIRED)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set(CMAKE_CUDA_ARCHITECTURES 75 80 86 87 89 90 100 110 120)
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
|
||||
if(ENABLE_CUDA_DEBUG)
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (may significantly affect performance on some targets)
|
||||
else()
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo") # add line information to all builds for debug tools (exclusive to -G option)
|
||||
endif()
|
||||
|
||||
# Source file
|
||||
# Add target for localityDomainsDrv
|
||||
add_executable(localityDomainsDrv localityDomainsDrv.cpp)
|
||||
@@ -35,5 +33,5 @@ target_link_libraries(localityDomainsDrv PUBLIC
|
||||
)
|
||||
|
||||
# Include installation configuration
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/InstallSamples.cmake)
|
||||
include(InstallSamples)
|
||||
setup_samples_install()
|
||||
|
||||
@@ -38,7 +38,7 @@ How to:
|
||||
|
||||
### Software
|
||||
|
||||
- CUDA Toolkit and NVIDIA driver with locality domain support
|
||||
- CUDA Toolkit and NVIDIA driver with locality domain support (CUDA Driver API 13.1 or newer)
|
||||
- Linux or QNX on x86_64 or aarch64
|
||||
- CMake 3.20 or newer
|
||||
- A C++17-capable host compiler
|
||||
@@ -74,6 +74,8 @@ allocation 0x<address> is localized to locality domain 0
|
||||
...
|
||||
```
|
||||
|
||||
If device 0 reports no locality domains, the sample reports that it is waiving execution and exits with status 2 (waived). A successful run exits with status 0.
|
||||
|
||||
## Files
|
||||
|
||||
- `localityDomainsDrv.cpp` — Driver API example
|
||||
|
||||
@@ -62,6 +62,12 @@ int main()
|
||||
std::cout << "SMs per locality domain: " << localityDomainSmCount << std::endl;
|
||||
}
|
||||
|
||||
if (localityDomainCount == 0) {
|
||||
std::cout << "Waiving execution as the device does not support locality domains." << std::endl;
|
||||
cuCtxDestroy(context);
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Construct localized green contexts and streams
|
||||
std::vector<CUgreenCtx> greenContexts(localityDomainCount);
|
||||
std::vector<CUstream> streams(localityDomainCount);
|
||||
|
||||
Reference in New Issue
Block a user