From 25029fbb7d62a912f93979e8a8285cfed3a0a8ae Mon Sep 17 00:00:00 2001 From: huiyuxie Date: Wed, 2 Oct 2024 15:32:26 -1000 Subject: [PATCH] Start --- test/test_macros.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test_macros.jl b/test/test_macros.jl index 1cccb3cf..a4a8b11b 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -5,6 +5,23 @@ using Test: @test, @testset # Macro to test the type Float64 or Float32 ? +# Macro to time the execution of a kernel +macro timed_kernel(kernel, args...; kwargs...) + quote + # Time the kernel + local start = CUDA.Event() + local stop = CUDA.Event() + CUDA.@synchronize + CUDA.record!(start) + $kernel(args...; kwargs...) + CUDA.@synchronize + CUDA.record!(stop) + CUDA.@synchronize + local elapsed_time = CUDA.elapsed_time(start, stop) + elapsed_time + end +end + # Macro to test the exact equality of arrays from GPU and CPU macro test_equal(expr) # Parse the expression and check that it is of the form