Skip to content

Commit 791ce6a

Browse files
committed
Moved testsets into separate files and added a few static tests.
1 parent 607c6d3 commit 791ce6a

17 files changed

+2247
-2157
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ julia:
88
- 1.3
99
- nightly
1010
matrix:
11-
allow_failures:
12-
- julia: nightly
1311
fast_finish: true
1412
notifications:
1513
email: false

Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7171

7272
[[VectorizationBase]]
7373
deps = ["CpuId", "LinearAlgebra"]
74-
git-tree-sha1 = "07785cdd42d94d3b5b13e1ba67d3f8feee4e670c"
74+
git-tree-sha1 = "e4019f1c1e22f7d68dd153eb9283079af5d84866"
7575
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
76-
version = "0.2.5"
76+
version = "0.2.6"

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
1414
Parameters = "0"
1515
SIMDPirates = "0.3.9, 0.4, 0.5"
1616
SLEEFPirates = "0.3.5, 0.4, 0.5"
17-
VectorizationBase = "0.2.5, 0.3, 0.4"
17+
VectorizationBase = "0.2.6, 0.3, 0.4"
1818
julia = "1.1"
1919

2020
[extras]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
using Pkg
1313
Pkg.add("LoopVectorization")
1414
```
15-
15+
LoopVectorization is supported on Julia 1.1 and later. It is tested on Julia 1.1, 1.3, and nightly.
1616

1717
## Usage
1818

src/lowering.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function lower_unrolled_dynamic!(
263263
end
264264
Ut = U
265265
vecisunrolled = unrolled === vectorized
266-
local remblock::Expr
266+
remblock = Expr(:block)
267267
firstiter = true
268268
while true
269269
if firstiter # first iter
@@ -313,7 +313,6 @@ function lower_unrolled_dynamic!(
313313
else
314314
Expr(:call, :(!=), unrolled_stopsym, unrolled)
315315
end
316-
remblock = Expr(:block)
317316
push!(q.args, Expr(:if, comparison, remblock))
318317
elseif !(Ut < U - 1 + vecisunrolled) || Ut == Ureduct
319318
break
@@ -379,7 +378,7 @@ function lower_tiled(ls::LoopSet, vectorized::Symbol, U::Int, T::Int)
379378
nloops = num_loops(ls);
380379
firstiter = true
381380
mangledtiled = tiledsym(tiled)
382-
local qifelse::Expr
381+
qifelse = q # local declaration of qifelse; will be replaced before first use
383382
while Tt > 0
384383
tiledloopbody = Expr(:block)
385384
lower_unrolled!(tiledloopbody, ls, vectorized, U, Tt, W, typeT, unrolledloop)

test/broadcast.jl

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@testset "broadcast" begin
2+
M, N = 37, 47
3+
# M = 77;
4+
for T (Float32, Float64, Int32, Int64)
5+
@show T, @__LINE__
6+
R = T <: Integer ? (T(-100):T(100)) : T
7+
a = rand(R,100,100,100);
8+
b = rand(R,100,100,1);
9+
bl = LowDimArray{(true,true,false)}(b);
10+
br = reshape(b, (100,100));
11+
c1 = a .+ b;
12+
c2 = @avx a .+ bl;
13+
@test c1 c2
14+
fill!(c2, 99999); @avx c2 .= a .+ br;
15+
@test c1 c2
16+
fill!(c2, 99999); @avx c2 .= a .+ b;
17+
@test c1 c2
18+
br = reshape(b, (100,1,100));
19+
bl = LowDimArray{(true,false,true)}(br);
20+
@. c1 = a + br;
21+
fill!(c2, 99999); @avx @. c2 = a + bl;
22+
@test c1 c2
23+
fill!(c2, 99999); @avx @. c2 = a + br;
24+
@test c1 c2
25+
br = reshape(b, (1,100,100));
26+
bl = LowDimArray{(false,true,true)}(br);
27+
@. c1 = a + br;
28+
fill!(c2, 99999);
29+
@avx @. c2 = a + bl;
30+
@test c1 c2
31+
32+
a = rand(R, M); B = rand(R, M, N); c = rand(R, N); c′ = c';
33+
d1 = @. a + B * c′;
34+
d2 = @avx @. a + B * c′;
35+
@test d1 d2
36+
37+
@. d1 = a + B * c′;
38+
@avx @. d2 = a + B * c′;
39+
@test d1 d2
40+
41+
d3 = a .+ B * c;
42+
d4 = @avx a .+ B *ˡ c;
43+
@test d3 d4
44+
45+
fill!(d3, -1000.0);
46+
fill!(d4, 91000.0);
47+
48+
d3 .= a .+ B * c;
49+
@avx d4 .= a .+ B *ˡ c;
50+
@test d3 d4
51+
52+
fill!(d4, 91000.0);
53+
@avx @. d4 = a + B *ˡ c;
54+
@test d3 d4
55+
56+
M, K, N = 77, 83, 57;
57+
A = rand(R,M,K); B = rand(R,K,N); C = rand(R,M,N);
58+
At = copy(A')
59+
D1 = C .+ A * B;
60+
D2 = @avx C .+ A *ˡ B;
61+
@test D1 D2
62+
fill!(D2, -999999); D2 = @avx C .+ At' *ˡ B;
63+
@test D1 D2
64+
if T <: Union{Float32,Float64}
65+
D3 = cos.(B');
66+
D4 = @avx cos.(B');
67+
@test D3 D4
68+
69+
fill!(D3, -1e3); fill!(D4, 9e9);
70+
Bt = Transpose(B);
71+
@. D3 = exp(Bt);
72+
@avx @. D4 = exp(Bt);
73+
@test D3 D4
74+
75+
D1 = similar(B); D2 = similar(B);
76+
D1t = Transpose(D1);
77+
D2t = Transpose(D2);
78+
@. D1t = exp(Bt);
79+
@avx @. D2t = exp(Bt);
80+
@test D1t D2t
81+
82+
fill!(D1, -1e3);
83+
fill!(D2, 9e9);
84+
@. D1' = exp(Bt);
85+
lset = @avx @. D2' = exp(Bt);
86+
87+
@test D1 D2
88+
89+
a = rand(137);
90+
b1 = @avx @. 3*a + sin(a) + sqrt(a);
91+
b2 = @. 3*a + sin(a) + sqrt(a);
92+
@test b1 b2
93+
three = 3; fill!(b1, -9999);
94+
@avx @. b1 = three*a + sin(a) + sqrt(a);
95+
@test b1 b2
96+
97+
C = rand(100,10,10);
98+
D1 = C .^ 0.3;
99+
D2 = @avx C .^ 0.3;
100+
@test D1 D2
101+
end
102+
end
103+
end

test/copy.jl

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
@testset "copy" begin
2+
3+
function copyavx1!(x, y)
4+
@avx for i eachindex(x)
5+
x[i] = y[i]
6+
end
7+
end
8+
function copy_avx1!(x, y)
9+
@_avx for i eachindex(x)
10+
x[i] = y[i]
11+
end
12+
end
13+
function copyavx2!(x, y)
14+
@avx for i eachindex(x)
15+
yᵢ = y[i]
16+
x[i] = yᵢ
17+
end
18+
end
19+
function copy_avx2!(x, y)
20+
@_avx for i eachindex(x)
21+
yᵢ = y[i]
22+
x[i] = yᵢ
23+
end
24+
end
25+
function offset_copy!(A, B)
26+
@inbounds for i=1:size(A,1), j=1:size(B,2)
27+
A[i,j+2] = B[i,j]
28+
end
29+
end
30+
function offset_copyavx1!(A, B)
31+
@avx for i=1:size(A,1), j=1:size(B,2)
32+
A[i,j+2] = B[i,j]
33+
end
34+
end
35+
function offset_copy_avx1!(A, B)
36+
@_avx for i=1:size(A,1), j=1:size(B,2)
37+
A[i,j+2] = B[i,j]
38+
end
39+
end
40+
function offset_copyavx2!(A, B)
41+
@avx for i=1:size(A,1), j=1:size(B,2)
42+
Bᵢⱼ = B[i,j]
43+
A[i,j+2] = Bᵢⱼ
44+
end
45+
end
46+
function offset_copy_avx2!(A, B)
47+
@_avx for i=1:size(A,1), j=1:size(B,2)
48+
Bᵢⱼ = B[i,j]
49+
A[i,j+2] = Bᵢⱼ
50+
end
51+
end
52+
function make2point3avx!(x)
53+
@avx for i eachindex(x)
54+
x[i] = 2.3
55+
end
56+
end
57+
function make2point3_avx!(x)
58+
@_avx for i eachindex(x)
59+
x[i] = 2.3
60+
end
61+
end
62+
function make23avx!(x)
63+
@avx for i eachindex(x)
64+
x[i] = 23
65+
end
66+
end
67+
function make23_avx!(x)
68+
@_avx for i eachindex(x)
69+
x[i] = 23
70+
end
71+
end
72+
function myfillavx!(x, a)
73+
@avx for i eachindex(x)
74+
x[i] = a
75+
end
76+
end
77+
function myfill_avx!(x, a)
78+
@_avx for i eachindex(x)
79+
x[i] = a
80+
end
81+
end
82+
83+
for T (Float32, Float64, Int32, Int64)
84+
@show T, @__LINE__
85+
R = T <: Integer ? (-T(100):T(100)) : T
86+
x = rand(R, 237);
87+
q1 = similar(x); q2 = similar(x);
88+
89+
fill!(q2, -999999); copyavx1!(q2, x);
90+
@test x == q2
91+
fill!(q2, -999999); copy_avx1!(q2, x);
92+
@test x == q2
93+
fill!(q2, -999999); copyavx2!(q2, x);
94+
@test x == q2
95+
fill!(q2, -999999); copy_avx2!(q2, x);
96+
@test x == q2
97+
fill!(q2, -999999); @avx q2 .= x;
98+
@test x == q2
99+
100+
B = rand(R, 79, 83);
101+
A1 = zeros(T, 79, 85);
102+
A2 = zeros(T, 79, 85);
103+
offset_copy!(A1, B);
104+
fill!(A2, 0); offset_copyavx1!(A2, B);
105+
@test A1 == A2
106+
fill!(A2, 0); offset_copyavx2!(A2, B);
107+
@test A1 == A2
108+
fill!(A2, 0); offset_copy_avx1!(A2, B);
109+
@test A1 == A2
110+
fill!(A2, 0); offset_copy_avx2!(A2, B);
111+
@test A1 == A2
112+
113+
a = rand(R)
114+
myfillavx!(x, a);
115+
fill!(q2, a);
116+
@test x == q2
117+
a = rand(R)
118+
myfill_avx!(x, a);
119+
fill!(q2, a);
120+
@test x == q2
121+
a = rand(R)
122+
myfill_avx!(x, a);
123+
fill!(q2, a);
124+
@test x == q2
125+
a = rand(R)
126+
myfillavx!(x, a);
127+
fill!(q2, a);
128+
@test x == q2
129+
if T <: Union{Float32,Float64}
130+
make2point3avx!(x)
131+
fill!(q2, 2.3)
132+
@test x == q2
133+
fill!(x, -999999); make2point3_avx!(x)
134+
@test x == q2
135+
end
136+
a = rand(R)
137+
@avx x .= a;
138+
fill!(q2, a);
139+
@test x == q2
140+
a = rand(R)
141+
@avx x .= a;
142+
fill!(q2, a);
143+
@test x == q2
144+
145+
end
146+
end

0 commit comments

Comments
 (0)