1
1
using LoopVectorization, Test
2
- # T = Float32
3
-
4
- macro outline (ex)
5
- quote
6
- (() -> begin
7
- Base. @_noinline_meta
8
- $ (esc (ex))
9
- end )()
10
- end
11
- end
2
+ T = Float32
12
3
13
4
function test_broadcast (:: Type{T} ) where {T}
14
5
M, N = 37 , 47
@@ -22,35 +13,35 @@ function test_broadcast(::Type{T}) where {T}
22
13
23
14
br = reshape (b, (99 ,99 ));
24
15
c1 = a .+ b;
25
- c2 = @outline @ turbo a .+ bl;
16
+ c2 = @turbo inline = false a .+ bl;
26
17
@test c1 ≈ c2
27
- fill! (c2, 99999 ); @outline @ turbo c2 .= a .+ br;
18
+ fill! (c2, 99999 ); @turbo inline = false c2 .= a .+ br;
28
19
@test c1 ≈ c2
29
- fill! (c2, 99999 ); @outline @ turbo c2 .= a .+ b;
20
+ fill! (c2, 99999 ); @turbo inline = false c2 .= a .+ b;
30
21
@test c1 ≈ c2
31
22
br = reshape (b, (99 ,1 ,99 ));
32
23
bl = LowDimArray {(true,false,true)} (br);
33
24
@test size (bl) == size (br)
34
25
@test LoopVectorization. ArrayInterface. size (bl) === (size (br,1 ),LoopVectorization. StaticInt (1 ),size (br,3 ))
35
26
@. c1 = a + br;
36
- fill! (c2, 99999 ); @outline @ turbo @. c2 = a + bl;
27
+ fill! (c2, 99999 ); @turbo inline = false @. c2 = a + bl;
37
28
@test c1 ≈ c2
38
- fill! (c2, 99999 ); @outline @ turbo @. c2 = a + br;
29
+ fill! (c2, 99999 ); @turbo inline = false @. c2 = a + br;
39
30
@test c1 ≈ c2
40
31
br = reshape (b, (1 ,99 ,99 ));
41
32
bl = LowDimArray {(false,)} (br);
42
33
@test size (bl) == size (br)
43
34
@test LoopVectorization. ArrayInterface. size (bl) === (LoopVectorization. StaticInt (1 ),size (br,2 ),size (br,3 ))
44
35
@. c1 = a + br;
45
36
fill! (c2, 99999 );
46
- @test c1 ≈ @outline @ turbo @. c2 = a + bl
37
+ @test c1 ≈ @turbo inline = false @. c2 = a + bl
47
38
# @test c1 ≈ c2
48
39
br = reshape (rand (R,99 ), (1 ,99 ,1 ));
49
40
bl = LowDimArray {(false,)} (br);
50
41
@test size (bl) == size (br)
51
42
@. c1 = a + br;
52
43
fill! (c2, 99999 );
53
- @outline @ turbo @. c2 = a + bl;
44
+ @turbo inline = false @. c2 = a + bl;
54
45
@test c1 ≈ c2
55
46
56
47
if T <: Integer
@@ -59,76 +50,76 @@ function test_broadcast(::Type{T}) where {T}
59
50
xs = rand (T, M);
60
51
end
61
52
max_ = maximum (xs, dims= 1 );
62
- @test (@outline @ turbo exp .(xs .- LowDimArray {(false,)} (max_))) ≈ exp .(xs .- LowDimArray {(false,)} (max_))
53
+ @test (@turbo inline = false exp .(xs .- LowDimArray {(false,)} (max_))) ≈ exp .(xs .- LowDimArray {(false,)} (max_))
63
54
@test size (LowDimArray {(false,)} (max_)) == size (max_)
64
55
65
56
if T === Int32
66
57
a = rand (T (1 ): T (100 ), 73 , 1 );
67
- @test sqrt .(Float32 .(a)) ≈ @outline @ turbo sqrt .(a)
58
+ @test sqrt .(Float32 .(a)) ≈ @turbo inline = false sqrt .(a)
68
59
elseif T === Int64
69
60
a = rand (T (1 ): T (100 ), 73 , 1 );
70
- @test sqrt .(a) ≈ @outline @ tturbo sqrt .(a)
61
+ @test sqrt .(a) ≈ @tturbo inline = false sqrt .(a)
71
62
else
72
63
a = rand (T, 73 , 1 );
73
- @test sqrt .(a) ≈ @outline @ turbo sqrt .(a)
64
+ @test sqrt .(a) ≈ @turbo inline = false sqrt .(a)
74
65
end
75
66
76
67
a = rand (R, M); B = rand (R, M, N); c = rand (R, N); c′ = c' ;
77
68
d1 = @. a + B * c′;
78
- d2 = @outline @ tturbo @. a + B * c′;
69
+ d2 = @tturbo inline = false @. a + B * c′;
79
70
@test d1 ≈ d2
80
71
81
72
@. d1 = a + B * c′;
82
- @outline @ turbo @. d2 = a + B * c′;
73
+ @turbo inline = false @. d2 = a + B * c′;
83
74
@test d1 ≈ d2
84
75
85
76
d3 = a .+ B * c;
86
- d4 = @outline @ turbo a .+ B * ˡ c;
77
+ d4 = @turbo inline = false a .+ B * ˡ c;
87
78
@test d3 ≈ d4
88
79
89
80
fill! (d3, - 1000.0 );
90
81
fill! (d4, 91000.0 );
91
82
92
83
d3 .= a .+ B * c;
93
- @outline @ turbo d4 .= a .+ B * ˡ c;
84
+ @turbo inline = false d4 .= a .+ B * ˡ c;
94
85
@test d3 ≈ d4
95
86
96
87
fill! (d4, 91000.0 );
97
- @outline @ turbo @. d4 = a + B * ˡ c;
88
+ @turbo inline = false @. d4 = a + B * ˡ c;
98
89
@test d3 ≈ d4
99
90
100
91
M, K, N = 77 , 83 , 57 ;
101
92
A = rand (R,M,K); B = rand (R,K,N); C = rand (R,M,N);
102
93
At = copy (A' );
103
94
D1 = C .+ A * B;
104
- D2 = @outline @ tturbo C .+ A .* ˡ B;
95
+ D2 = @tturbo inline = false C .+ A .* ˡ B;
105
96
@test D1 ≈ D2
106
97
if RUN_SLOW_TESTS
107
- fill! (D2, - 999999 ); D2 = @outline @ turbo C .+ At' * ˡ B;
98
+ fill! (D2, - 999999 ); D2 = @turbo inline = false C .+ At' * ˡ B;
108
99
@test D1 ≈ D2
109
- fill! (D2, - 999999 ); @test A * B ≈ (@outline @ turbo @. D2 = A * ˡ B)
100
+ fill! (D2, - 999999 ); @test A * B ≈ (@turbo inline = false @. D2 = A * ˡ B)
110
101
D1 .= view (C, 1 , :)' .+ A * B;
111
102
fill! (D2, - 999999 );
112
- @outline @ turbo D2 .= view (C, 1 , :)' .+ A .* ˡ B;
103
+ @turbo inline = false D2 .= view (C, 1 , :)' .+ A .* ˡ B;
113
104
@test D1 ≈ D2
114
105
C3d = rand (R,3 ,M,N);
115
106
D1 .= view (C3d, 1 , :, :) .+ A * B;
116
107
fill! (D2, - 999999 );
117
- @outline @ tturbo D2 .= view (C3d, 1 , :, :) .+ A .* ˡ B;
108
+ @tturbo inline = false D2 .= view (C3d, 1 , :, :) .+ A .* ˡ B;
118
109
@test D1 ≈ D2
119
110
end
120
111
D1 .= 9999 ;
121
- @outline @ turbo D2 .= 9999 ;
112
+ @turbo inline = false D2 .= 9999 ;
122
113
@test D1 == D2
123
114
D1 .= - 99999 ;
124
- @outline @ tturbo D2' .= - 99999 ;
115
+ @tturbo inline = false D2' .= - 99999 ;
125
116
@test D1 == D2
126
117
127
118
b = rand (T,K); x = rand (R,N);
128
119
D1 .= C .+ A * (b .+ x' );
129
- @outline @ tturbo @. D2 = C + A * ˡ (b + x' );
120
+ @tturbo inline = false @. D2 = C + A * ˡ (b + x' );
130
121
@test D1 ≈ D2
131
- D2 = @outline @ turbo @. C + A * ˡ (b + x' );
122
+ D2 = @turbo inline = false @. C + A * ˡ (b + x' );
132
123
@test D1 ≈ D2
133
124
if T === Int64
134
125
xd = rand (- 1_000_000_000_000 : 1_000_000_000_000 ,89 );
@@ -143,43 +134,43 @@ function test_broadcast(::Type{T}) where {T}
143
134
144
135
if T <: Union{Float32,Float64}
145
136
D3 = cos .(B' );
146
- D4 = @outline @ turbo cos .(B' );
137
+ D4 = @turbo inline = false cos .(B' );
147
138
@test D3 ≈ D4
148
139
149
140
fill! (D3, - 1e3 ); fill! (D4, 9e9 );
150
141
Bt = transpose (B);
151
142
@. D3 = exp (Bt);
152
- @outline @ tturbo @. D4 = exp (Bt);
143
+ @tturbo inline = false @. D4 = exp (Bt);
153
144
@test D3 ≈ D4
154
145
155
146
D1 = similar (B); D2 = similar (B);
156
147
D1t = transpose (D1);
157
148
D2t = transpose (D2);
158
149
@. D1t = exp (Bt);
159
- @outline @ turbo @. D2t = exp (Bt);
150
+ @turbo inline = false @. D2t = exp (Bt);
160
151
@test D1t ≈ D2t
161
152
162
153
fill! (D1, - 1e3 );
163
154
fill! (D2, 9e9 );
164
155
@. D1' = exp (Bt);
165
- lset = @outline @ tturbo @. D2' = exp (Bt);
156
+ lset = @tturbo inline = false @. D2' = exp (Bt);
166
157
167
158
@test D1 ≈ D2
168
159
169
160
a = rand (137 );
170
- b1 = @outline @ turbo @. 3 * a + sin (a) + sqrt (a);
161
+ b1 = @turbo inline = false @. 3 * a + sin (a) + sqrt (a);
171
162
b2 = @. 3 * a + sin (a) + sqrt (a);
172
163
@test b1 ≈ b2
173
164
three = 3 ; fill! (b1, - 9999 );
174
- @outline @ tturbo @. b1 = three* a + sin (a) + sqrt (a);
165
+ @tturbo inline = false @. b1 = three* a + sin (a) + sqrt (a);
175
166
@test b1 ≈ b2
176
167
177
168
C = rand (100 ,10 ,10 );
178
169
D1 = C .^ 0.3 ;
179
- D2 = @outline @ tturbo C .^ 0.3 ;
170
+ D2 = @tturbo inline = false C .^ 0.3 ;
180
171
@test D1 ≈ D2
181
172
@. D1 = C ^ 2 ;
182
- @outline @ turbo @. D2 = C ^ 2 ;
173
+ @turbo inline = false @. D2 = C ^ 2 ;
183
174
@test D1 ≈ D2
184
175
@turbo view (C,1 : 100 ,1 : 10 ,1 : 10 ) .= 0 ;
185
176
@test all (== (0 ), C)
0 commit comments