Skip to content

Commit e20f0ae

Browse files
author
Michael Abbott
committed
fix Tullio.onlyone(Mask, ...)
1 parent a448c71 commit e20f0ae

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

src/eval.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ using Requires
7070
@inline allzero(seen::Int) = iszero(seen)
7171
@inline allzero(seen::SVec{N,Int}) where {N} = iszero((!iszero(seen)).u)
7272

73-
@inline Tullio.anyone(cond::Mask) = cond != zero(cond)
73+
# @inline Tullio.anyone(cond::Mask) = cond != zero(cond)
74+
@inline Tullio.anyone(cond::Mask) = cond.u != zero(cond).u # for v0.9
7475

7576
@require ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" begin
7677
# Dual numbers + svec, should live in PaddedMatricesForwardDiff?

test/runtests.jl

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,38 @@ _gradient(x...) = Yota.grad(x...)[2]
206206
t8 = time()
207207
using LoopVectorization
208208

209-
if false # isdefined(LoopVectorization, :Vec)
210-
@testset "LoopVectorization onlyone" begin
211-
using LoopVectorization: Mask, Vec
212-
ms = Mask{UInt8}(0x03) # Mask{8,Bool}<1, 1, 0, 0, 0, 0, 0, 0>
213-
sv = Vec{4,Int}(1,2,3,4) # SVec{4,Int64}<1, 2, 3, 4>
214-
215-
@test Tullio.onlyone(ms, 0) == Mask{UInt8}(0x02)
216-
@test Tullio.onlyone(ms, sv) == Mask{UInt8}(0x00)
217-
@test Tullio.onlyone(ms, zero(sv)) == Mask{UInt8}(0x02)
218-
end
209+
if isdefined(LoopVectorization, :SVec) # version 0.8, for Julia ⩽1.5
210+
using LoopVectorization.VectorizationBase: SVec, Mask
211+
else # version 0.9, supports Julia 1.6
212+
using LoopVectorization.VectorizationBase: Vec, Mask
213+
SVec{N,T} = Vec{N,T}
219214
end
220215

216+
@testset "LoopVectorization onlyone" begin
217+
ms = Mask{UInt8}(0x03); # Mask{8,Bool}<1, 1, 0, 0, 0, 0, 0, 0>
218+
sv = SVec{4,Int}(1,2,3,4) # SVec{4,Int64}<1, 2, 3, 4>
219+
220+
# preliminaries:
221+
@test Tullio.allzero(sv) === false
222+
@test Tullio.allzero(zero(sv)) === true
223+
224+
@test Tullio.anyone(ms) === true
225+
226+
# the main function:
227+
@test Tullio.onlyone(false, 0) === false
228+
@test Tullio.onlyone(true, 0) === true
229+
@test Tullio.onlyone(true, 1) === false
230+
231+
# @test Tullio.onlyone(ms, 0) === Mask{UInt8}(0x02)
232+
@test Tullio.onlyone(ms, 0).u == 0x02
233+
# @test Tullio.onlyone(ms, sv) === Mask{UInt8}(0x00)
234+
@test Tullio.onlyone(ms, sv).u == 0x00
235+
# @test Tullio.onlyone(ms, zero(sv)) === Mask{UInt8}(0x02)
236+
@test Tullio.onlyone(ms, zero(sv)).u == 0x02
237+
end
238+
239+
@testset "parsing + LoopVectorization" begin include("parsing.jl") end
240+
221241
using Tracker
222242
GRAD = :Tracker
223243
_gradient(x...) = Tracker.gradient(x...)
@@ -228,8 +248,6 @@ _gradient(x...) = Tracker.gradient(x...)
228248
@tullio grad=Dual
229249
@testset "gradients: Tracker + ForwardDiff + LoopVectorization" begin include("gradients.jl") end
230250

231-
@testset "parsing + LoopVectorization" begin include("parsing.jl") end
232-
233251
@info @sprintf("LoopVectorization tests took %.1f seconds", time()-t8)
234252

235253
@tullio avx=false

0 commit comments

Comments
 (0)