1 | #include <c10/cuda/CUDAMiscFunctions.h> |
2 | #include <stdlib.h> |
3 | |
4 | namespace c10 { |
5 | namespace cuda { |
6 | |
7 | const char* get_cuda_check_suffix() noexcept { |
8 | static char* device_blocking_flag = getenv("CUDA_LAUNCH_BLOCKING" ); |
9 | static bool blocking_enabled = |
10 | (device_blocking_flag && atoi(device_blocking_flag)); |
11 | if (blocking_enabled) { |
12 | return "" ; |
13 | } else { |
14 | return "\nCUDA kernel errors might be asynchronously reported at some" |
15 | " other API call, so the stacktrace below might be incorrect." |
16 | "\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1." ; |
17 | } |
18 | } |
19 | std::mutex* getFreeMutex() { |
20 | static std::mutex cuda_free_mutex; |
21 | return &cuda_free_mutex; |
22 | } |
23 | |
24 | } // namespace cuda |
25 | } // namespace c10 |
26 | |