ReUseX
0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <
ReUseX/vision/tensor_rt/common/check.hpp
>
3
#include <spdlog/spdlog.h>
4
5
namespace
ReUseX::vision::tensor_rt::nv
{
6
7
class
EventTimer
{
8
public
:
9
EventTimer
() {
10
checkRuntime
(cudaEventCreate(&begin_));
11
checkRuntime
(cudaEventCreate(&end_));
12
}
13
14
virtual
~EventTimer
() {
15
checkRuntime
(cudaEventDestroy(begin_));
16
checkRuntime
(cudaEventDestroy(end_));
17
}
18
19
void
start
(cudaStream_t stream =
nullptr
) {
20
stream_ = stream;
21
checkRuntime
(cudaEventRecord(begin_, stream));
22
}
23
24
float
stop
(
const
char
*prefix =
"timer"
) {
25
float
times = 0;
26
checkRuntime
(cudaEventRecord(end_, stream_));
27
checkRuntime
(cudaEventSynchronize(end_));
28
checkRuntime
(cudaEventElapsedTime(×, begin_, end_));
29
spdlog::info(
"[⏰ {}] : {:.5f} ms"
, prefix, times);
30
return
times;
31
}
32
33
private
:
34
cudaStream_t stream_ =
nullptr
;
35
cudaEvent_t begin_ =
nullptr
, end_ =
nullptr
;
36
};
37
38
};
// namespace ReUseX::vision::tensor_rt::nv
check.hpp
checkRuntime
#define checkRuntime(call)
Definition
check.hpp:34
ReUseX::vision::tensor_rt::nv::EventTimer::~EventTimer
virtual ~EventTimer()
Definition
timer.hpp:14
ReUseX::vision::tensor_rt::nv::EventTimer::EventTimer
EventTimer()
Definition
timer.hpp:9
ReUseX::vision::tensor_rt::nv::EventTimer::start
void start(cudaStream_t stream=nullptr)
Definition
timer.hpp:19
ReUseX::vision::tensor_rt::nv::EventTimer::stop
float stop(const char *prefix="timer")
Definition
timer.hpp:24
ReUseX::vision::tensor_rt::nv
Definition
check.hpp:10
libs
reusex
include
ReUseX
vision
tensor_rt
common
timer.hpp
Generated by
1.16.1