Mercurial > repos > public > sbplib_julia
comparison benchmark/benchmark_laplace.jl @ 1529:43aaf710463e refactor/equidistant_grid/signature
Change to signature of equidistant_grid to same style as many array methods.
See for example Array{T}(undef, dims...), zeros(T, dims...), fill(a, dims...) and more.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 11 Apr 2024 22:31:04 +0200 |
parents | 2ad2de55061a |
children | 471a948cd2b2 |
comparison
equal
deleted
inserted
replaced
1528:d641798539c2 | 1529:43aaf710463e |
---|---|
8 | 8 |
9 const operator_path = sbp_operators_path()*"standard_diagonal.toml" | 9 const operator_path = sbp_operators_path()*"standard_diagonal.toml" |
10 | 10 |
11 function benchmark_const_coeff_1d(;N = 100, order = 4) | 11 function benchmark_const_coeff_1d(;N = 100, order = 4) |
12 stencil_set = read_stencil_set(operator_path; order=order) | 12 stencil_set = read_stencil_set(operator_path; order=order) |
13 g = equidistant_grid(N, 0., 1.) | 13 g = equidistant_grid(0., 1., N) |
14 D = second_derivative(g, stencil_set) | 14 D = second_derivative(g, stencil_set) |
15 u = rand(size(g)...) | 15 u = rand(size(g)...) |
16 u_xx = rand(size(g)...) | 16 u_xx = rand(size(g)...) |
17 | 17 |
18 b_naive = @benchmark $u_xx .= $D*$u | 18 b_naive = @benchmark $u_xx .= $D*$u |
23 print_benchmark_result("Threaded region apply",b_thrd) | 23 print_benchmark_result("Threaded region apply",b_thrd) |
24 end | 24 end |
25 | 25 |
26 function benchmark_var_coeff_1d(;N = 100, order = 4) | 26 function benchmark_var_coeff_1d(;N = 100, order = 4) |
27 stencil_set = read_stencil_set(operator_path; order=order) | 27 stencil_set = read_stencil_set(operator_path; order=order) |
28 g = equidistant_grid(N, 0., 1.) | 28 g = equidistant_grid(0., 1., N) |
29 c = rand(size(g)...) | 29 c = rand(size(g)...) |
30 c_lz = eval_on(g, x -> 0.5) | 30 c_lz = eval_on(g, x -> 0.5) |
31 D = second_derivative_variable(g, c, stencil_set) | 31 D = second_derivative_variable(g, c, stencil_set) |
32 D_lz = second_derivative_variable(g, c_lz, stencil_set) | 32 D_lz = second_derivative_variable(g, c_lz, stencil_set) |
33 u = rand(size(g)...) | 33 u = rand(size(g)...) |
47 print_benchmark_result("Threaded region apply lazy coeff",b_thrd_lz) | 47 print_benchmark_result("Threaded region apply lazy coeff",b_thrd_lz) |
48 end | 48 end |
49 | 49 |
50 function benchmark_const_coeff_2d(;N = 100, order = 4) | 50 function benchmark_const_coeff_2d(;N = 100, order = 4) |
51 stencil_set = read_stencil_set(operator_path; order=order) | 51 stencil_set = read_stencil_set(operator_path; order=order) |
52 g = equidistant_grid((N,N), (0.,0.,),(1.,1.)) | 52 g = equidistant_grid((0.,0.,),(1.,1.), N, N) |
53 D = Laplace(g, stencil_set) | 53 D = Laplace(g, stencil_set) |
54 u = rand(size(g)...) | 54 u = rand(size(g)...) |
55 u_xx = rand(size(g)...) | 55 u_xx = rand(size(g)...) |
56 if order == 2 | 56 if order == 2 |
57 clz_sz = 1 | 57 clz_sz = 1 |
69 print_benchmark_result("Threaded region apply",b_thrd) | 69 print_benchmark_result("Threaded region apply",b_thrd) |
70 end | 70 end |
71 | 71 |
72 function benchmark_var_coeff_2d(;N = 100, order = 4) | 72 function benchmark_var_coeff_2d(;N = 100, order = 4) |
73 stencil_set = read_stencil_set(operator_path; order=order) | 73 stencil_set = read_stencil_set(operator_path; order=order) |
74 g = equidistant_grid((N,N), (0.,0.,),(1.,1.)) | 74 g = equidistant_grid((0.,0.,),(1.,1.), N, N) |
75 c = rand(size(g)...) | 75 c = rand(size(g)...) |
76 c_lz = eval_on(g, x-> 0.5) | 76 c_lz = eval_on(g, x-> 0.5) |
77 D = second_derivative_variable(g, c, stencil_set, 1) + second_derivative_variable(g, c, stencil_set, 2) | 77 D = second_derivative_variable(g, c, stencil_set, 1) + second_derivative_variable(g, c, stencil_set, 2) |
78 D_lz = second_derivative_variable(g, c_lz, stencil_set, 1) + second_derivative_variable(g, c_lz, stencil_set, 2) | 78 D_lz = second_derivative_variable(g, c_lz, stencil_set, 1) + second_derivative_variable(g, c_lz, stencil_set, 2) |
79 u = rand(size(g)...) | 79 u = rand(size(g)...) |