-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathIntegrateBenchs.jl
153 lines (122 loc) · 2.33 KB
/
IntegrateBenchs.jl
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
module IntegrateBenchs
using Test
using Gridap.Arrays
using Gridap.Fields
using Gridap.Fields: IntKernel
using Gridap.Fields: OtherMockBasis, MockBasis, MockField
using FillArrays
using Gridap.TensorValues
@noinline function loop(a,cache)
for i in eachindex(a)
ai = getindex!(cache,a,i)
end
nothing
end
@inline function repeat(n,f,args...)
for i in 1:n
f(args...)
end
nothing
end
function bench1(n)
fi = 2.0
wi = 3.0
ji = TensorValue(1.0,0.0,0.0,2.0)
np = 4
f = fill(fi,np)
w = fill(wi,np)
j = fill(ji,np)
k = IntKernel()
ck = kernel_cache(k,f,w,j)
@time repeat(n,apply_kernel!,ck,k,f,w,j)
end
function bench2(n)
fi = 2.0
wi = 3.0
ji = TensorValue(1.0,0.0,0.0,2.0)
np = 4
f = fill(fi,np,10)
w = fill(wi,np)
j = fill(ji,np)
k = IntKernel()
ck = kernel_cache(k,f,w,j)
@time repeat(n,apply_kernel!,ck,k,f,w,j)
end
function bench3(n)
np = 4
p = Point(2,2)
x = fill(p,np)
ndof = 8
d = 2
ri = 5.0
r = MockBasis{d}(ri,ndof)
v = 3.0
ndof = 8
w = fill(1/np,np)
c = fill(1.5,ndof)
f = OtherMockBasis{d}(ndof)
l = n
ac = fill(c,l)
af = Fill(f,l)
aϕ = lincomb(af,ac)
aj = ∇(aϕ)
aw = Fill(w,l)
ax = Fill(x,l)
ar = Fill(r,l)
ab = attachmap(ar,aϕ)
fmass = operate_arrays_of_fields(inner,ab,ab)
mmass = integrate(fmass,ax,aw,aj)
cmmass = array_cache(mmass)
@time loop(mmass,cmmass)
fstif = operate_arrays_of_fields(inner,∇(ab),∇(ab))
mstif = integrate(fstif,ax,aw,aj)
cmstif = array_cache(mstif)
@time loop(mstif,cmstif)
end
function bench4(n)
fi = 2.0
wi = 3.0
ji = TensorValue(1.0,0.0,0.0,2.0)
np = 4
f = fill(fi,np)
w = fill(wi,np)
j = fill(ji,np)
l = n
af = fill(f,l)
aw = fill(w,l)
aj = fill(j,l)
k = IntKernel()
s = apply(k,af,aw,aj)
cs = array_cache(s)
@time loop(s,cs)
end
function bench5(n)
fi = 2.0
wi = 3.0
ji = TensorValue(1.0,0.0,0.0,2.0)
np = 4
ndof = 10
f = fill(fi,np,ndof)
w = fill(wi,np)
j = fill(ji,np)
l = n
af = fill(f,l)
aw = fill(w,l)
aj = fill(j,l)
k = IntKernel()
s = apply(k,af,aw,aj)
cs = array_cache(s)
@time loop(s,cs)
@time repeat(n,getindex!,cs,s,1)
end
for n in (1,1,10,1000,100000)
@eval begin
println("+++ running suite for n = $($n) +++")
bench1($n)
bench2($n)
bench3($n)
bench4($n)
bench5($n)
end
end
end #module