Skip to content

Commit

Permalink
Fix incorrect timing results for CUDA.@Elapsed (#2118)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfaingnaert authored Oct 23, 2023
1 parent 8dbcb2a commit 87fd247
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cudadrv/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ macro elapsed(ex...)
quote
t0, t1 = CuEvent(), CuEvent()
record(t0)
$(esc(ex))
$(esc(code))
record(t1)
synchronize(t1; blocking=$blocking)
elapsed(t0, t1)
Expand Down
8 changes: 8 additions & 0 deletions test/core/cudadrv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ end
@test (CUDA.@elapsed identity(nothing)) > 0
@test (CUDA.@elapsed blocking=true identity(nothing)) > 0

let
empty_fun() = nothing

# Check that the benchmarked code occurs as-is in the macro expansion.
me = @macroexpand1 CUDA.@elapsed empty_fun()
@test any(arg -> arg == :(empty_fun()), me.args)
end

CuEvent(CUDA.EVENT_BLOCKING_SYNC)
CuEvent(CUDA.EVENT_BLOCKING_SYNC | CUDA.EVENT_DISABLE_TIMING)

Expand Down

0 comments on commit 87fd247

Please sign in to comment.