Skip to content

Commit 30a1453

Browse files
committed
add+use timer() method on TimedLaunchStrategy
Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent 29c844c commit 30a1453

7 files changed

Lines changed: 15 additions & 8 deletions

File tree

vortex-cuda/benches/alp_cuda.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ where
105105
|b, array| {
106106
b.iter_custom(|iters| {
107107
let timed = TimedLaunchStrategy::default();
108-
let timer = Arc::clone(&timed.total_time_ns);
108+
let timer = timed.timer();
109109

110110
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
111111
.vortex_expect("failed to create execution context")

vortex-cuda/benches/bitpacked_cuda.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ where
119119
|b, array| {
120120
b.iter_custom(|iters| {
121121
let timed = TimedLaunchStrategy::default();
122-
let timer = Arc::clone(&timed.total_time_ns);
122+
let timer = timed.timer();
123123

124124
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
125125
.vortex_expect("failed to create execution context")
@@ -164,7 +164,7 @@ where
164164
|b, array| {
165165
b.iter_custom(|iters| {
166166
let timed = TimedLaunchStrategy::default();
167-
let timer = Arc::clone(&timed.total_time_ns);
167+
let timer = timed.timer();
168168

169169
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
170170
.vortex_expect("failed to create execution context")

vortex-cuda/benches/common/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ pub struct TimedLaunchStrategy {
1616
pub total_time_ns: Arc<AtomicU64>,
1717
}
1818

19+
impl TimedLaunchStrategy {
20+
/// Returns a shared handle to the accumulated kernel time, for reading after launches complete.
21+
pub fn timer(&self) -> Arc<AtomicU64> {
22+
Arc::clone(&self.total_time_ns)
23+
}
24+
}
25+
1926
impl LaunchStrategy for TimedLaunchStrategy {
2027
fn event_flags(&self) -> CUevent_flags {
2128
// using blocking_sync to make sure all events flush before we complete.

vortex-cuda/benches/date_time_parts_cuda.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn benchmark_datetimeparts(c: &mut Criterion) {
6464
|b, dtp_array| {
6565
b.iter_custom(|iters| {
6666
let timed = TimedLaunchStrategy::default();
67-
let timer = Arc::clone(&timed.total_time_ns);
67+
let timer = timed.timer();
6868

6969
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
7070
.vortex_expect("failed to create execution context")

vortex-cuda/benches/dict_cuda.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
|b, dict_array| {
9393
b.iter_custom(|iters| {
9494
let timed = TimedLaunchStrategy::default();
95-
let timer = Arc::clone(&timed.total_time_ns);
95+
let timer = timed.timer();
9696

9797
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
9898
.vortex_expect("failed to create execution context")

vortex-cuda/benches/for_cuda.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ where
8383
|b, for_array| {
8484
b.iter_custom(|iters| {
8585
let timed = TimedLaunchStrategy::default();
86-
let timer = Arc::clone(&timed.total_time_ns);
86+
let timer = timed.timer();
8787

8888
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
8989
.vortex_expect("failed to create execution context")
@@ -121,7 +121,7 @@ where
121121
|b, for_array| {
122122
b.iter_custom(|iters| {
123123
let timed = TimedLaunchStrategy::default();
124-
let timer = Arc::clone(&timed.total_time_ns);
124+
let timer = timed.timer();
125125

126126
let mut cuda_ctx = CudaSession::create_execution_ctx(&VortexSession::empty())
127127
.vortex_expect("failed to create execution context")

vortex-cuda/benches/runend_cuda.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ where
7777
|b, runend_array| {
7878
b.iter_custom(|iters| {
7979
let timed = TimedLaunchStrategy::default();
80-
let timer = Arc::clone(&timed.total_time_ns);
80+
let timer = timed.timer();
8181

8282
let mut cuda_ctx =
8383
CudaSession::create_execution_ctx(&VortexSession::empty())

0 commit comments

Comments
 (0)