Files
pytorch/torch/csrc/itt_wrapper.cpp
Taylor Robie b8f14b7877 [Profiler][Minor] Group and consolidate stub APIs (#85510)
There is a concept in profiler of a stub that wraps a profiling API. It was introduced for CUDA profiling before Kineto, and ITT has adopted it to call into VTune APIs. However for the most part we don't really interact with them when developing the PyTorch profiler.

Thus it makes sense to unify the fallback registration mechanism and create a subfolder to free up real estate in the top level `torch/csrc/profiler` directory.

Differential Revision: [D39108647](https://our.internmc.facebook.com/intern/diff/D39108647/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85510
Approved by: https://github.com/aaronenyeshi
2022-10-14 05:38:46 +00:00

29 lines
789 B
C++

#include <c10/macros/Export.h>
#include <ittnotify.h>
#include <torch/csrc/profiler/stubs/base.h>
namespace torch {
namespace profiler {
__itt_domain* _itt_domain = __itt_domain_create("PyTorch");
TORCH_API bool itt_is_available() {
return torch::profiler::impl::ittStubs()->enabled();
}
TORCH_API void itt_range_push(const char* msg) {
__itt_string_handle* hsMsg = __itt_string_handle_create(msg);
__itt_task_begin(_itt_domain, __itt_null, __itt_null, hsMsg);
}
TORCH_API void itt_range_pop() {
__itt_task_end(_itt_domain);
}
TORCH_API void itt_mark(const char* msg) {
__itt_string_handle* hsMsg = __itt_string_handle_create(msg);
__itt_task_begin(_itt_domain, __itt_null, __itt_null, hsMsg);
__itt_task_end(_itt_domain);
}
} // namespace profiler
} // namespace torch