forked from WaterLily-jl/WaterLily.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalloctest.jl
More file actions
29 lines (27 loc) · 1.22 KB
/
alloctest.jl
File metadata and controls
29 lines (27 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using BenchmarkTools, Printf
backend != "SIMD" && throw(ArgumentError("KernelAbstractions backend not allowed to run allocations tests, use SIMD backend"))
@testset "mom_step! allocations" begin
function Sim(θ;L=32,U=1,Re=100,perdir=())
function map(x,t)
s,c = sincos(θ)
SA[c -s; s c]*(x-SA[L,L])
end
function sdf(ξ,t)
p = ξ-SA[0,clamp(ξ[1],-L/2,L/2)]
√(p'*p)-2
end
Simulation((20L,20L),(U,0),L,ν=U*L/Re,body=AutoBody(sdf,map),T=Float32,perdir=perdir)
end
sim = Sim(Float32(π/36))
sim_step!(sim)
b = @benchmarkable mom_step!($sim.flow, $sim.pois) samples=100; tune!(b) # check 100 times
r = run(b)
println("▶ Allocated "*@sprintf("%.0f", r.memory/1e3)*" KiB")
@test r.memory < 50000 # less than 50 KiB allocated on the best mom_step! run (commit f721343 ≈ 8 KiB)
sim = Sim(Float32(π/36); perdir=(2,))
sim_step!(sim)
b = @benchmarkable mom_step!($sim.flow, $sim.pois) samples=100; tune!(b) # check 100 times
r = run(b)
println("▶ Allocated "*@sprintf("%.0f", r.memory/1e3)*" KiB")
@test r.memory < 50000 # less than 50 KiB allocated on the best mom_step! run (commit f721343 ≈ 8 KiB)
end