-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvectorization_tests.jl
57 lines (53 loc) · 1.26 KB
/
vectorization_tests.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
using Test
using InteractiveUtils
using FastBroadcast
using MuladdMacro
function foo9(a, b, c, d, e, f, g, h, i)
@muladd @.. a = b + 0.1 * (0.2c + 0.3d^2 + 0.4e + 0.5f^7 + 0.6g + 0.6h + 0.6i)
nothing
end
function foo26(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
@muladd @.. a =
b +
0.1 * (
0.2c +
0.3d +
0.4e +
0.5f +
0.6g +
0.6h +
0.6i^3 +
0.6j +
0.6k +
0.6l +
0.6m +
0.6n +
0.6o +
0.6p^5 +
0.6q +
0.6r +
0.6s +
0.6t +
0.6u +
0.6v^4 +
0.6w +
0.6x +
0.6y +
0.6z
)
nothing
end
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z =
[rand(100, 100, 2) for i = 1:26]
foo9(a, b, c, d, e, f, g, h, i)
foo26(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
if Base.JLOptions().check_bounds != 1
@test @allocated(foo9(a, b, c, d, e, f, g, h, i)) == 0
@test @allocated(
foo26(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
) == 0
io = IOBuffer()
InteractiveUtils.code_llvm(io, foo9, Base.typesof(a, b, c, d, e, f, g, h, i))
str = String(take!(io))
@test occursin("vector.body", str)
end