1#ifndef __NVTX_PROFILER_HPP__
2#define __NVTX_PROFILER_HPP__
4#if defined(SIRIUS_CUDA_NVTX)
6#include <unordered_map>
13namespace nvtxprofiler {
17 void start(std::string
const &str) {
18 timers_[str] = nvtxRangeStartA(str.c_str());
21 void stop(std::string
const &str) {
22 auto result = timers_.find(str);
23 if (result == timers_.end())
return;
24 nvtxRangeEnd(result->second);
25 timers_.erase(result);
29 std::unordered_map<std::string, nvtxRangeId_t> timers_;
34 ScopedTiming(std::string identifier, Timer &timer) :
35 identifier_(identifier), timer_(timer) {
36 timer.start(identifier_);
39 ScopedTiming(
const ScopedTiming&) =
delete;
40 ScopedTiming(ScopedTiming&&) =
delete;
41 auto operator=(
const ScopedTiming&) -> ScopedTiming& =
delete;
42 auto operator=(ScopedTiming &&) -> ScopedTiming& =
delete;
45 timer_.stop(identifier_);
49 std::string identifier_;
Namespace of the SIRIUS library.