Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/stencil_test.jl @ 904:47f5451cdfc4 feature/variable_derivatives
Add type stability tests for nested stencil application
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 15 Feb 2022 07:54:52 +0100 |
parents | a7f898b1ce1e |
children | a3bc90c59e8e |
comparison
equal
deleted
inserted
replaced
903:a7f898b1ce1e | 904:47f5451cdfc4 |
---|---|
42 | 42 |
43 @testset "promotion" begin | 43 @testset "promotion" begin |
44 @test promote(Stencil(1,1;center=1), Stencil(2.,2.;center=2)) == (Stencil(1.,1.;center=1), Stencil(2.,2.;center=2)) | 44 @test promote(Stencil(1,1;center=1), Stencil(2.,2.;center=2)) == (Stencil(1.,1.;center=1), Stencil(2.,2.;center=2)) |
45 end | 45 end |
46 | 46 |
47 @testset "type inference" begin | 47 @testset "type stability" begin |
48 s_int = CenteredStencil(1,2,3) | 48 s_int = CenteredStencil(1,2,3) |
49 s_float = CenteredStencil(1.,2.,3.) | 49 s_float = CenteredStencil(1.,2.,3.) |
50 v_int = rand(1:10,10); | 50 v_int = rand(1:10,10); |
51 v_float = rand(10); | 51 v_float = rand(10); |
52 | 52 |
53 @inferred SbpOperators.apply_stencil(s_int, v_int, 2) | 53 @inferred SbpOperators.apply_stencil(s_int, v_int, 2) |
54 @inferred SbpOperators.apply_stencil(s_float, v_float, 2) | 54 @inferred SbpOperators.apply_stencil(s_float, v_float, 2) |
55 @inferred SbpOperators.apply_stencil(s_int, v_float, 2) | 55 @inferred SbpOperators.apply_stencil(s_int, v_float, 2) |
56 @inferred SbpOperators.apply_stencil(s_float, v_int, 2) | 56 @inferred SbpOperators.apply_stencil(s_float, v_int, 2) |
57 | |
58 # TODO: apply backwards | |
57 end | 59 end |
58 end | 60 end |
59 | 61 |
60 @testset "NestedStencil" begin | 62 @testset "NestedStencil" begin |
61 | 63 |
132 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-4,-7,-3; center=1) | 134 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-4,-7,-3; center=1) |
133 | 135 |
134 @test SbpOperators.apply_stencil(ns, c, v, 4) == 5*7 + 11*11 + 6*13 | 136 @test SbpOperators.apply_stencil(ns, c, v, 4) == 5*7 + 11*11 + 6*13 |
135 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -3*3 - 7*5 - 4*7 | 137 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -3*3 - 7*5 - 4*7 |
136 end | 138 end |
139 | |
140 @testset "type stability" begin | |
141 s_int = CenteredNestedStencil((1,2,3),(1,2,3),(1,2,3)) | |
142 s_float = CenteredNestedStencil((1.,2.,3.),(1.,2.,3.),(1.,2.,3.)) | |
143 | |
144 v_int = rand(1:10,10); | |
145 v_float = rand(10); | |
146 | |
147 c_int = rand(1:10,10); | |
148 c_float = rand(10); | |
149 | |
150 @inferred SbpOperators.apply_stencil(s_int, c_int, v_int, 2) | |
151 @inferred SbpOperators.apply_stencil(s_float, c_int, v_float, 2) | |
152 @inferred SbpOperators.apply_stencil(s_int, c_int, v_float, 2) | |
153 @inferred SbpOperators.apply_stencil(s_float, c_int, v_int, 2) | |
154 | |
155 @inferred SbpOperators.apply_stencil(s_int, c_float, v_int, 2) | |
156 @inferred SbpOperators.apply_stencil(s_float, c_float, v_float, 2) | |
157 @inferred SbpOperators.apply_stencil(s_int, c_float, v_float, 2) | |
158 @inferred SbpOperators.apply_stencil(s_float, c_float, v_int, 2) | |
159 | |
160 # TODO: apply backwards | |
161 end | |
162 | |
137 end | 163 end |