Mercurial > repos > public > sbplib_julia
changeset 1208:e679d4fab8ee performance/get_region_type_inference
Add some tests for allocations
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 03 Feb 2023 22:34:38 +0100 |
parents | f1c2a4fa0ee1 |
children | 8cc0707cb851 |
files | test/inference_trouble_test.jl |
diffstat | 1 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/inference_trouble_test.jl Fri Feb 03 22:34:38 2023 +0100 @@ -0,0 +1,36 @@ +using Test +using Sbplib +using Sbplib.Grids +using Sbplib.SbpOperators +using Sbplib.RegionIndices +using BenchmarkTools + +import Sbplib.SbpOperators: Stencil + + +@testset "First" begin + g = EquidistantGrid((10,10),(0.,0.), (1.,1.)) + v = evalOn(g, (x,y)->x^2+y^2+1) + H = inner_product(g, 1., [1/2]) + + @test @ballocated(LazyTensors.apply($H.t1, $H.t2*$v, 1,2)) == 0 + @test @ballocated(LazyTensors.apply($H.t1.tm, $(view(H.t2*v,:,1)), 2)) == 0 + + # Nedan är halvdåliga + @test @ballocated(LazyTensors.apply($H.t1.tm, $(view(H.t2*v,1,:)), 2)) == 0 + @test @ballocated(LazyTensors.apply($H.t1.tm, $(view(v,1,:)), 2)) == 0 + @test @ballocated(LazyTensors.apply($H.t1.tm, $(view(v,:,1)), 2)) == 0 + @test @ballocated(LazyTensors.apply($H.t1.tm, $(v[:,1]), 2)) == 0 +end + +@testset "Second" begin + g = EquidistantGrid(10,0., 1.) + v = evalOn(g, (x)->x^2+1) + H = inner_product(g, 1., [1/2]) + V = SbpOperators.VolumeOperator(g, Stencil(1.,center=1), (Stencil(1/2,center=1),), SbpOperators.even) + b = SbpOperators.BoundaryOperator(g, Stencil(1/2,center=1), Lower()) + + @test @ballocated(LazyTensors.apply($H, $H*$v, 2)) == 0 + @test @ballocated(LazyTensors.apply($V, $V*$v, 2)) == 0 +end +