Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect timing results for CUDA.@elapsed #2118

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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