ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2
//
3
// SPDX-License-Identifier: GPL-3.0-or-later
4
5
#pragma once
6
#include "reusex/core/logging.hpp"
7
#include "reusex/vision/tensor_rt/common/check.hpp"
8
9
namespace
reusex::vision::tensor_rt::nv
{
10
11
class
EventTimer
{
12
public
:
13
EventTimer
() {
14
checkRuntime
(cudaEventCreate(&begin_));
15
checkRuntime
(cudaEventCreate(&end_));
16
}
17
18
virtual
~EventTimer
() {
19
checkRuntime
(cudaEventDestroy(begin_));
20
checkRuntime
(cudaEventDestroy(end_));
21
}
22
23
void
start
(cudaStream_t stream =
nullptr
) {
24
stream_ = stream;
25
checkRuntime
(cudaEventRecord(begin_, stream));
26
}
27
28
float
stop
(
const
char
*prefix =
"timer"
) {
29
float
times = 0;
30
checkRuntime
(cudaEventRecord(end_, stream_));
31
checkRuntime
(cudaEventSynchronize(end_));
32
checkRuntime
(cudaEventElapsedTime(×, begin_, end_));
33
reusex::info
(
"[⏰ {}] : {:.5f} ms"
, prefix, times);
34
return
times;
35
}
36
37
private
:
38
cudaStream_t stream_ =
nullptr
;
39
cudaEvent_t begin_ =
nullptr
, end_ =
nullptr
;
40
};
41
42
};
// namespace reusex::vision::tensor_rt::nv
checkRuntime
#define checkRuntime(call)
Definition
check.hpp:40
reusex::vision::tensor_rt::nv::EventTimer::start
void start(cudaStream_t stream=nullptr)
Definition
timer.hpp:23
reusex::vision::tensor_rt::nv::EventTimer::~EventTimer
virtual ~EventTimer()
Definition
timer.hpp:18
reusex::vision::tensor_rt::nv::EventTimer::stop
float stop(const char *prefix="timer")
Definition
timer.hpp:28
reusex::vision::tensor_rt::nv::EventTimer::EventTimer
EventTimer()
Definition
timer.hpp:13
reusex::vision::tensor_rt::nv
Definition
check.hpp:16
reusex::info
void info(fmt::format_string< Args... > format, Args &&...args)
Definition
logging.hpp:86
libs
reusex
include
vision
tensor_rt
common
timer.hpp
Generated by
1.17.0