From ef70bc02ab3ff9a26b22b8075d899ccfde785db0 Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Wed, 13 Dec 2023 15:11:08 +0100 Subject: [PATCH] minor change --- test/benchmark.jl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/benchmark.jl b/test/benchmark.jl index 3534465..afc025b 100644 --- a/test/benchmark.jl +++ b/test/benchmark.jl @@ -3,29 +3,38 @@ using BenchmarkTools sz = (1024,1024) v = rand(sz...); -useCuda = false +useCuda = true if useCuda using CUDA CUDA.allowscalar(false); v = CuArray(v) + + macro mytime(expr) + return :( @btime CUDA.@sync $expr) + end +else + macro mytime(expr) + return :( @btime $expr) + end end sh = (335, 444) sv = ShiftedArray(v, sh) cv = CircShiftedArray(v, sh) + # timings stated for Dell Laptop XPS 15 (i7 11800) on Windows 10 -@btime q = $sv .+ 5.0 # bc version: 1.48 ms, CuArray bc: 0.016 ms, old version: 2.73 ms +@mytime q = $sv .+ 5.0; # bc version: 1.48 ms, CuArray bc: 0.099 ms, old version: 2.73 ms res = sv .+ 5.0 -@btime res .= $sv .+ 5.0 # bc version: 0.18 ms, CuArray bc: 0.015 ms, old version: 0.37 ms +@mytime res .= $sv .+ 5.0 # bc version: 0.18 ms, CuArray bc: 0.097 ms, old version: 0.37 ms sv = ShiftedArray(v, sh, default=0.0) resn = copy(v) -@btime $resn .= $sv .+ 5.0 # bc version: 0.28 ms, CuArray bc: 0.020 ms, old version: 0.42 ms +@mytime $resn .= $sv .+ 5.0; # bc version: 0.28 ms, CuArray bc: 0.118 ms, old version: 0.42 ms -@btime $res .= $sv .+ 5.0 .* $v .*$sv # bc version: 0.727 ms, CuArray bc: 0.039 ms, old version: 1.65 ms +@mytime $res .= $sv .+ 5.0 .* $v .*$sv; # bc version: 0.727 ms, CuArray bc: 0.264 ms, old version: 1.65 ms svi = ShiftedArrays.ifftshift(v) -@btime $resn .= $svi .+ 5.0 .* $v .*$svi # bc version: 0.53 ms, CuArray bc: 0.029 ms, old version: 3.98 ms -@btime $resn .= ShiftedArrays.fftshift($svi .+ 5.0 .* $v .*$svi) # bc version: 2.41 ms, CuArray bc: 0.050 ms, old version: 3.98 ms +@mytime $resn .= $svi .+ 5.0 .* $v .*$svi; # bc version: 0.53 ms, CuArray bc: 0.324 ms, old version: 3.98 ms +@mytime $resn .= ShiftedArrays.fftshift($svi .+ 5.0 .* $v .*$svi); # bc version: 2.41 ms, CuArray bc: 0.443 ms, old version: 3.98 ms