Skip to content

Commit 66bef0b

Browse files
committed
Added ifelse tests.
1 parent a92372a commit 66bef0b

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
4949

5050
[[SIMDPirates]]
5151
deps = ["VectorizationBase"]
52-
git-tree-sha1 = "16e34b8028fa9d419a0e0b7f4d702c9b590a1977"
52+
git-tree-sha1 = "6d93eddeaf847073dfa36ad339d76015c59a9adb"
5353
uuid = "21efa798-c60a-11e8-04d3-e1a92915a26a"
54-
version = "0.3.13"
54+
version = "0.3.14"
5555

5656
[[SLEEFPirates]]
5757
deps = ["Libdl", "SIMDPirates", "VectorizationBase"]

src/costs.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const COST = Dict{Instruction,InstructionCost}(
136136
Instruction(:<<) => InstructionCost(1, 0.5),
137137
Instruction(:max) => InstructionCost(4,0.5),
138138
Instruction(:min) => InstructionCost(4,0.5),
139-
Instruction(:ifelse) => InstructionCost(1, 0.5),
139+
# Instruction(:ifelse) => InstructionCost(1, 0.5),
140140
Instruction(:vifelse) => InstructionCost(1, 0.5),
141141
Instruction(:inv) => InstructionCost(13,4.0,-2.0,1),
142142
Instruction(:vinv) => InstructionCost(13,4.0,-2.0,1),
@@ -315,6 +315,8 @@ const FUNCTIONSYMBOLS = Dict{Type{<:Function},Instruction}(
315315
typeof(min) => :min,
316316
typeof(<<) => :<<,
317317
typeof(>>) => :>>,
318-
typeof(>>>) => :>>>
318+
typeof(>>>) => :>>>,
319+
typeof(ifelse) => :vifelse,
320+
typeof(vifelse) => :vifelse
319321
)
320322

test/ifelsemasks.jl

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@
2929
c[i] = 1 + (a[i] > b[i] ? a[i] + b[i] : a[i] * b[i])
3030
end
3131
end
32+
function addifelsemul_avx!(c, a, b)
33+
@_avx for i eachindex(c,a,b)
34+
c[i] = ifelse(a[i] > b[i], a[i] + b[i], a[i] * b[i])
35+
end
36+
end
37+
function addifelsemulavx!(c, a, b)
38+
@avx for i eachindex(c,a,b)
39+
c[i] = ifelse(a[i] > b[i], a[i] + b[i], a[i] * b[i])
40+
end
41+
end
42+
function addifelsemulp1_avx!(c, a, b)
43+
@_avx for i eachindex(c,a,b)
44+
c[i] = 1 + ifelse(a[i] > b[i], a[i] + b[i], a[i] * b[i])
45+
end
46+
end
47+
function addifelsemulp1avx!(c, a, b)
48+
@avx for i eachindex(c,a,b)
49+
c[i] = 1 + ifelse(a[i] > b[i], a[i] + b[i], a[i] * b[i])
50+
end
51+
end
3252

3353

3454
function maybewriteand!(c, a, b)
@@ -205,18 +225,26 @@
205225
a = rand(-T(100):T(100), N); b = rand(-T(100):T(100), N);
206226
else
207227
a = rand(T, N); b = rand(T, N);
208-
end
228+
end;
209229
c1 = similar(a); c2 = similar(a);
210230
addormul!(c1, a, b)
211231
addormul_avx!(c2, a, b)
212232
@test c1 c2
213233
fill!(c2, -999999999); addormulavx!(c2, a, b)
214234
@test c1 c2
235+
fill!(c2, -999999999); addifelsemul_avx!(c2, a, b)
236+
@test c1 c2
237+
fill!(c2, -999999999); addifelsemulavx!(c2, a, b)
238+
@test c1 c2
215239
addormulp1!(c1, a, b)
216240
addormulp1_avx!(c2, a, b)
217241
@test c1 c2
218242
fill!(c2, -999999999); addormulp1avx!(c2, a, b)
219243
@test c1 c2
244+
fill!(c2, -999999999); addifelsemulp1_avx!(c2, a, b)
245+
@test c1 c2
246+
fill!(c2, -999999999); addifelsemulp1avx!(c2, a, b)
247+
@test c1 c2
220248

221249
fill!(c1, -999999999); maybewriteand!(c1, a, b)
222250
fill!(c2, -999999999); maybewriteand_avx!(c2, a, b)

0 commit comments

Comments
 (0)