ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
cuda_compat.h
Go to the documentation of this file.
1
12#ifndef CUDA_COMPAT_H_
13#define CUDA_COMPAT_H_
14
15#include <iostream> // For std::ostream
16#include <stdexcept> // For std::invalid_argument
17#include <cuda.h> // defines CUDA_VERSION
18#include <cuda_runtime.h>
19#include <cufft.h>
20
21
22// NVTX header for CUDA versions prior to 12.9 vs. 12.9+
23// This block ensures the correct NVTX header path is used based on CUDA_VERSION.
24// - For CUDA Toolkit < 12.9, the legacy header "nvToolsExt.h" is included.
25// - For CUDA Toolkit >= 12.9, the modern header "nvtx3/nvToolsExt.h" is included,
26// and NVTX v2 is removed from 12.9.
27// This allows NVTX profiling APIs (e.g. nvtxRangePush) to be used consistently
28// across different CUDA versions.
29// See:
30// https://docs.nvidia.com/cuda/archive/12.9.0/cuda-toolkit-release-notes/index.html#id4
31#if defined(__CUDA) && defined(__USE_NVTX)
32#if CUDA_VERSION < 12090
33 #include "nvToolsExt.h"
34#else
35 #include "nvtx3/nvToolsExt.h"
36#endif
37#endif
38
39//-------------------------------------------------------------------------------------------------
40// Compatibility Layer Declarations
41//-------------------------------------------------------------------------------------------------
42namespace ModuleBase {
43namespace cuda_compat {
44
54void printDeprecatedDeviceInfo(std::ostream& os, const cudaDeviceProp& prop);
55
65void printComputeModeInfo(std::ostream& os, const cudaDeviceProp& prop);
66
76const char* cufftGetErrorStringCompat(cufftResult_t error);
77
78} // namespace cuda_compat
79} // namespace ModuleBase
80
81#endif // CUDA_COMPAT_H_
void printDeprecatedDeviceInfo(std::ostream &ofs_device, const cudaDeviceProp &deviceProp)
Prints device information that was deprecated or removed in CUDA 13.0.
Definition cuda_compat.cpp:9
const char * cufftGetErrorStringCompat(cufftResult_t error)
Provides a cross-CUDA-version string conversion for cuFFT error codes.
Definition cuda_compat.cpp:68
void printComputeModeInfo(std::ostream &ofs_device, const cudaDeviceProp &deviceProp)
Prints the device's compute mode using a legacy string mapping.
Definition cuda_compat.cpp:39
Definition array_pool.h:6