pytorch/c10/cuda
Yuanyuan Chen f0745ddb11 Replace c10::call_once with static initialization (#166381)
This PR replaces c10::call_once calls with static initialization when possible. C++11 semantics guarantees that static initialization is atomic. Static initialization also has lower cost than using c10::call_once.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/166381
Approved by: https://github.com/malfet
2025-11-01 07:09:40 +00:00
..
impl Improve error message for CUDAGuardImpl, MPSGuardImpl, XPUGuardImpl (#149838) 2025-03-25 07:29:53 +00:00
test [ROCm][Windows] Fix offload gpu arch list in tests (#155212) 2025-06-05 20:30:28 +00:00
BUILD.bazel
build.bzl
CMakeLists.txt Use torch_compile_options for c10 libraries (#147821) 2025-03-18 01:54:23 +00:00
CUDAAlgorithm.h
CUDAAllocatorConfig.cpp Refine Allocator Config error message friendly (#165288) 2025-10-19 15:34:17 +00:00
CUDAAllocatorConfig.h Deprecate overlapped functions in CUDAAllocatorConfig (#165289) 2025-10-19 15:34:26 +00:00
CUDACachingAllocator.cpp [ROCm] fix test_allocator_backend (#166035) 2025-10-22 03:46:23 +00:00
CUDACachingAllocator.h [Mem Snapshot] Add Metadata Field (#165490) 2025-10-17 23:46:02 +00:00
CUDADeviceAssertion.h Suppress -Wunused-function for DSA (#150735) 2025-04-07 01:47:35 +00:00
CUDADeviceAssertionHost.cpp [1/N] Remove unused header inclusion (#165763) 2025-10-18 05:23:11 +00:00
CUDADeviceAssertionHost.h [BE] fix typos in c10/ (#156078) 2025-06-18 10:24:44 +00:00
CUDAException.cpp [BE] Preserve caller source location in the error message (#162808) 2025-09-15 13:29:43 +00:00
CUDAException.h [BE] Preserve caller source location in the error message (#162808) 2025-09-15 13:29:43 +00:00
CUDAFunctions.cpp [BE] Fix '_WIN32' is not defined warning (#162516) 2025-09-10 04:21:38 +00:00
CUDAFunctions.h check if USE_ROCM is defined (#158571) 2025-07-17 19:48:26 +00:00
CUDAGraphsC10Utils.h Add DeviceAllocator as the base device allocator (#138222) 2025-08-08 17:41:10 +00:00
CUDAGuard.h Enable more readability-redundant checks (#143963) 2024-12-30 14:49:33 +00:00
CUDAMacros.h Revert "Increase C10_COMPILE_TIME_MAX_GPUS to 128 (#144138)" 2025-01-14 19:04:12 +00:00
CUDAMallocAsyncAllocator.cpp [ROCm] fix test_allocator_backend (#166035) 2025-10-22 03:46:23 +00:00
CUDAMathCompat.h
CUDAMiscFunctions.cpp [1/N] Remove unused header inclusion (#165763) 2025-10-18 05:23:11 +00:00
CUDAMiscFunctions.h Mark unused parameters in C++ code (#164912) 2025-10-09 06:23:25 +00:00
CUDAStream.cpp Replace c10::call_once with static initialization (#166381) 2025-11-01 07:09:40 +00:00
CUDAStream.h Mark unused parameters in C++ code (#164912) 2025-10-09 06:23:25 +00:00
driver_api.cpp [1/N] Remove unused header inclusion (#165763) 2025-10-18 05:23:11 +00:00
driver_api.h [CUDA] Add experimental green context support for SM carveout (#159104) 2025-10-22 21:38:52 +00:00
README.md

c10/cuda is a core library with CUDA functionality. It is distinguished from c10 in that it links against the CUDA library, but like c10 it doesn't contain any kernels, and consists solely of core functionality that is generally useful when writing CUDA code; for example, C++ wrappers for the CUDA C API.

Important notes for developers. If you want to add files or functionality to this folder, TAKE NOTE. The code in this folder is very special, because on our AMD GPU build, we transpile it into c10/hip to provide a ROCm environment. Thus, if you write:

// c10/cuda/CUDAFoo.h
namespace c10 { namespace cuda {

void my_func();

}}

this will get transpiled into:

// c10/hip/HIPFoo.h
namespace c10 { namespace hip {

void my_func();

}}

Thus, if you add new functionality to c10, you must also update C10_MAPPINGS torch/utils/hipify/cuda_to_hip_mappings.py to transpile occurrences of cuda::my_func to hip::my_func. (At the moment, we do NOT have a catch all cuda:: to hip:: namespace conversion, as not all cuda namespaces are converted to hip::, even though c10's are.)

Transpilation inside this folder is controlled by CAFFE2_SPECIFIC_MAPPINGS (oddly enough.) C10_MAPPINGS apply to ALL source files.

If you add a new directory to this folder, you MUST update both c10/cuda/CMakeLists.txt and c10/hip/CMakeLists.txt