15
15
@nexprs $ N d-> inds_d = inds[d]
16
16
s = zero (eltype (itp))
17
17
@inbounds @nloops $ N i d-> inds_d begin
18
- s += @nref ($ N, itp, i)
18
+ s += @ncall ($ N, itp, i)
19
19
end
20
20
s
21
21
end
22
22
end
23
23
24
24
function sumvalues_indices (itp)
25
- inds = indices (itp)
25
+ inds = axes (itp)
26
26
n = Int (round (10 ^ (3 / ndims (itp))))
27
- ntuple (d-> collect (linspace (first (inds[d])+ 0.001 , last (inds[d])- 0.001 , n)), ndims (itp))
27
+ ntuple (d-> collect (range (first (inds[d])+ 0.001 , stop = last (inds[d])- 0.001 , length = n)), ndims (itp))
28
28
end
29
29
30
- strip_prefix (str) = replace (str, " Interpolations." , " " )
30
+ strip_prefix (str) = replace (str, " Interpolations." => " " )
31
31
benchstr (:: Type{T} ) where {T<: Interpolations.GridType } = strip_prefix (string (T))
32
32
33
33
benchstr (:: Type{Constant} ) = " Constant()"
@@ -49,25 +49,23 @@ for A in (collect(Float64, 1:3),
49
49
# Constant & Linear
50
50
for D in (Constant, Linear)
51
51
gstr = groupstr (D)
52
- for GT in (OnGrid, OnCell)
53
- Ac = copy (A)
54
- idstr = string (ndims (A), " d_" , benchstr (D), ' _' , benchstr (GT))
55
- suite[" bsplines" ][gstr][string (idstr, " _construct" )] =
56
- @benchmarkable interpolate ($ Ac, BSpline ($ D ()), $ GT ())
57
- itp = interpolate (copy (A), BSpline (D ()), GT ())
58
- inds = sumvalues_indices (itp)
59
- suite[" bsplines" ][gstr][string (idstr, " _use" )] =
60
- @benchmarkable sumvalues ($ itp, $ inds)
61
- end
52
+ Ac = copy (A)
53
+ idstr = string (ndims (A), " d_" , benchstr (D), ' _' , benchstr (OnGrid))
54
+ suite[" bsplines" ][gstr][string (idstr, " _construct" )] =
55
+ @benchmarkable interpolate ($ Ac, BSpline ($ D ()))
56
+ itp = interpolate (copy (A), BSpline (D ()))
57
+ inds = sumvalues_indices (itp)
58
+ suite[" bsplines" ][gstr][string (idstr, " _use" )] =
59
+ @benchmarkable sumvalues ($ itp, $ inds)
62
60
end
63
61
# Quadratic
64
62
gstr = groupstr (Quadratic)
65
63
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
66
64
Ac = copy (A)
67
65
idstr = string (ndims (A), " d_" , benchstr (Quadratic{BC}), ' _' , benchstr (GT))
68
66
suite[" bsplines" ][gstr][string (idstr, " _construct" )] =
69
- @benchmarkable interpolate ($ Ac, BSpline (Quadratic ($ BC ())), $ GT ())
70
- itp = interpolate (copy (A), BSpline (Quadratic (BC ())), GT ( ))
67
+ @benchmarkable interpolate ($ Ac, BSpline (Quadratic ($ BC ($ GT ())) ))
68
+ itp = interpolate (copy (A), BSpline (Quadratic (BC (GT ( )))))
71
69
inds = sumvalues_indices (itp)
72
70
suite[" bsplines" ][gstr][string (idstr, " _use" )] =
73
71
@benchmarkable sumvalues ($ itp, $ inds)
@@ -76,8 +74,8 @@ for A in (collect(Float64, 1:3),
76
74
Ac = copy (A)
77
75
idstr = string (ndims (A), " d_" , benchstr (Quadratic{BC}), ' _' , benchstr (OnCell))
78
76
suite[" bsplines" ][gstr][string (idstr, " _construct" )] =
79
- @benchmarkable interpolate! ($ Ac, BSpline (Quadratic ($ BC ())), OnCell ( ))
80
- itp = interpolate! (copy (A), BSpline (Quadratic (BC ())), OnCell ( ))
77
+ @benchmarkable interpolate! ($ Ac, BSpline (Quadratic ($ BC (OnCell ( )))))
78
+ itp = interpolate! (copy (A), BSpline (Quadratic (BC (OnCell ( )))))
81
79
inds = sumvalues_indices (itp)
82
80
suite[" bsplines" ][gstr][string (idstr, " _use" )] =
83
81
@benchmarkable sumvalues ($ itp, $ inds)
@@ -88,8 +86,8 @@ for A in (collect(Float64, 1:3),
88
86
Ac = copy (A)
89
87
idstr = string (ndims (A), " d_" , benchstr (Cubic{BC}), ' _' , benchstr (GT))
90
88
suite[" bsplines" ][gstr][string (idstr, " _construct" )] =
91
- @benchmarkable interpolate ($ Ac, BSpline (Cubic ($ BC ())), $ GT ())
92
- itp = interpolate (copy (A), BSpline (Cubic (BC ())), GT ( ))
89
+ @benchmarkable interpolate ($ Ac, BSpline (Cubic ($ BC ($ GT ())) ))
90
+ itp = interpolate (copy (A), BSpline (Cubic (BC (GT ( )))))
93
91
inds = sumvalues_indices (itp)
94
92
suite[" bsplines" ][gstr][string (idstr, " _use" )] =
95
93
@benchmarkable sumvalues ($ itp, $ inds)
@@ -101,7 +99,11 @@ paramspath = joinpath(dirname(@__FILE__), "params.json")
101
99
if isfile (paramspath)
102
100
loadparams! (suite, BenchmarkTools. load (paramspath)[1 ], :evals );
103
101
else
104
- info ( " Tuning suite (this may take a while)" )
102
+ @ info " Tuning suite (this may take a while)"
105
103
tune! (suite)
106
104
BenchmarkTools. save (paramspath, params (suite));
107
105
end
106
+
107
+ # To run the benchmarks:
108
+ # results = run(suite, verbose = true, seconds = 1)
109
+ # BenchmarkTools.save(filename, results)
0 commit comments