Skip to content

Commit 7f9123f

Browse files
committed
Added vmapnt and vmapntt
1 parent 0b7aaa5 commit 7f9123f

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.6.19"
4+
version = "0.6.20"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/LoopVectorization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const SUPPORTED_TYPES = Union{Float16,Float32,Float64,Integer}
1717

1818
export LowDimArray, stridedpointer, vectorizable,
1919
@avx, @_avx, *ˡ, _avx_!,
20-
vmap, vmap!, vmapnt!, vmapntt!,
20+
vmap, vmap!, vmapnt, vmapnt!, vmapntt, vmapntt!,
2121
vfilter, vfilter!
2222

2323

src/map.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ end
2424
@generated function vmap!(f::F, dest::AbstractArray{T}, args::Vararg{<:AbstractArray,N}) where {F,T,N}
2525
vmap_quote(N, T)
2626
end
27-
function vmap(f::F, args...) where {F}
28-
T = Base._return_type(f, Base.Broadcast.eltypes(args))
29-
dest = similar(first(args), T)
30-
vmap!(f, dest, args...)
31-
end
3227

3328
function vmapnt!(f::F, y::AbstractVector{T}, args::Vararg{<:Any,A}) where {F,T,A}
3429
ptry = pointer(y)
@@ -80,6 +75,16 @@ function vmapntt!(f::F, y::AbstractVector{T}, args::Vararg{<:Any,A}) where {F,T,
8075
y
8176
end
8277

78+
function vmap_call(f::F, vm!::V, args::Vararg{<:Any,N}) where {V,F,N}
79+
T = Base._return_type(f, Base.Broadcast.eltypes(args))
80+
dest = similar(first(args), T)
81+
vm!(f, dest, args...)
82+
end
83+
vmap(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmap!, args...)
84+
vmapnt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapnt!, args...)
85+
vmapntt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapntt!, args...)
86+
87+
8388
# @inline vmap!(f, y, x...) = @avx y .= f.(x...)
8489
# @inline vmap(f, x...) = @avx f.(x...)
8590

test/map.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
c1 = map(foo, a, b);
88
c2 = vmap(foo, a, b);
99
@test c1 c2
10-
fill!(c2, NaN); vmapnt!(foo, c2, a, b);
10+
c2 = vmapnt(foo, a, b);
1111
@test c1 c2
12-
fill!(c2, NaN); vmapntt!(foo, c2, a, b);
12+
c2 = vmapntt(foo, a, b);
1313
@test c1 c2
1414
@test_throws AssertionError @views vmapnt!(c2[2:end], a[2:end], b[2:end])
1515
@test_throws AssertionError @views vmapntt!(c2[2:end], a[2:end], b[2:end])

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ end
1818

1919
@time include("printmethods.jl")
2020

21+
@time include("map.jl")
22+
23+
@time include("filter.jl")
24+
2125
@time include("ifelsemasks.jl")
2226

2327
@time include("dot.jl")
@@ -32,10 +36,6 @@ end
3236

3337
@time include("broadcast.jl")
3438

35-
@time include("map.jl")
36-
37-
@time include("filter.jl")
38-
3939
@time include("gemm.jl")
4040

4141
end

0 commit comments

Comments
 (0)