Files
pytorch/c10/util/WaitCounterDynamicBackend.h
Andrii Grynenko a141c6bb0d [pytorch][monitoring] Dynamic backend for WaitCounter (#135967)
Summary: This implements a default backend proxy that tries to look up a backend via dlsym. What this enables is dynamically loading a module with a backend implementation without having it statically linked with the application.

Differential Revision: D62549295

Pull Request resolved: https://github.com/pytorch/pytorch/pull/135967
Approved by: https://github.com/c-p-i-o
2024-09-15 18:07:49 +00:00

22 lines
662 B
C++

#pragma once
#include <cstdint>
#include <string_view>
namespace c10::monitor::detail {
struct WaitCounterDynamicBackend {
void* self{nullptr};
intptr_t (*start)(void* self, int64_t nowUs){nullptr};
void (*stop)(void* self, int64_t nowUs, intptr_t ctx){nullptr};
void (*destroy)(void* self){nullptr};
};
using WaitCounterDynamicBackendInit =
void (*)(WaitCounterDynamicBackend*, const char* key, std::size_t keyLen);
// This name needs to be updated if anything in the API above is changed.
constexpr std::string_view kWaitCounterDynamicBackendInitFn =
"c10_monitor_wait_counter_dynamic_backend_init_v1";
} // namespace c10::monitor::detail