pytorch/c10/cuda/CUDAMiscFunctions.cpp
Natalia Gimelshein 6284d2a82b wrap cudaStreamSynchronize calls (#61889)
Summary:
This is a first step towards creating context manager that errors out on synchronizing calls.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/61889

Reviewed By: albanD

Differential Revision: D29805280

Pulled By: ngimel

fbshipit-source-id: b66400fbe0941b7daa51e6b30abe27b9cccd4e8a
2021-07-21 19:30:52 -07:00

21 lines
621 B
C++

#include <c10/cuda/CUDAMiscFunctions.h>
#include <stdlib.h>
namespace c10 {
namespace cuda {
const char* get_cuda_check_suffix() noexcept {
static char* device_blocking_flag = getenv("CUDA_LAUNCH_BLOCKING");
static bool blocking_enabled =
(device_blocking_flag && atoi(device_blocking_flag));
if (blocking_enabled) {
return "";
} else {
return "\nCUDA kernel errors might be asynchronously reported at some"
" other API call,so the stacktrace below might be incorrect."
"\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1.";
}
}
} // namespace cuda
} // namespace c10