Skip to content

Commit 7059d62

Browse files
committed
vmap for bool
1 parent 22944bf commit 7059d62

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/simdfunctionals/map.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function vmap_singlethread!(
5353
f::F, y::AbstractArray{T},
5454
::Val{NonTemporal},
5555
args::Vararg{AbstractArray,A}
56-
) where {F,T <: Base.HWReal, A, NonTemporal}
56+
) where {F,T <: NativeTypes, A, NonTemporal}
5757
ptry, ptrargs, N = setup_vmap!(f, y, Val{NonTemporal}(), args...)
5858
_vmap_singlethread!(f, ptry, Zero(), N, Val{NonTemporal}(), ptrargs)
5959
nothing
@@ -97,7 +97,7 @@ function _vmap_singlethread!(
9797
i = vadd_nw(i, W)
9898
end
9999
if i < N
100-
m = mask(T, N & (W - 1))
100+
m = mask(StaticInt(W), N & (W - 1))
101101
vfinal = f(map1(vload, ptrargs, (MM{W}(i),), m)...)
102102
if NonTemporal
103103
_vstore!(ptry, vfinal, (MM{W}(i,),), m, True(), True(), False(), register_size())
@@ -383,9 +383,13 @@ end
383383
@inline vmapnt!(f, args...) = map!(f, args...)
384384
@inline vmapntt!(f, args...) = map!(f, args...)
385385

386+
# similar_bit(x, ::Type{T}) where {T} = similar(x, T)
387+
# similar_bit(x, ::Type{Bool}) = BitArray(undef, size(x))
388+
386389
function vmap_call(f::F, vm!::V, args::Vararg{Any,N}) where {V,F,N}
387390
T = Base._return_type(f, Base.Broadcast.eltypes(args))
388391
dest = similar(first(args), T)
392+
# dest = similar_bit(first(args), T)
389393
vm!(f, dest, args...)
390394
end
391395

test/map.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
map!(xᵢ -> clenshaw(xᵢ, c), y1, x)
2727
vmap!(xᵢ -> clenshaw(xᵢ, c), y2, x)
2828
@test y1 y2
29+
@test vmap(>(T(0.5)), c) == map(>(T(0.5)), c)
2930
end
3031
@test vmap(abs2, 1:100) == map(abs2, 1:100)
3132
@test vmapt(abs2, 1:3:10000) == map(abs2, 1:3:10000)

0 commit comments

Comments
 (0)