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