From 7f9123f4e4eaec0814c78b586700fbb20fec662c Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Tue, 3 Mar 2020 00:56:30 -0500 Subject: [PATCH] Added vmapnt and vmapntt --- Project.toml | 2 +- src/LoopVectorization.jl | 2 +- src/map.jl | 15 ++++++++++----- test/map.jl | 4 ++-- test/runtests.jl | 8 ++++---- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Project.toml b/Project.toml index 4a8987655..e76310030 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LoopVectorization" uuid = "bdcacae8-1622-11e9-2a5c-532679323890" authors = ["Chris Elrod "] -version = "0.6.19" +version = "0.6.20" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/LoopVectorization.jl b/src/LoopVectorization.jl index 1bd429258..62d4a305a 100644 --- a/src/LoopVectorization.jl +++ b/src/LoopVectorization.jl @@ -17,7 +17,7 @@ const SUPPORTED_TYPES = Union{Float16,Float32,Float64,Integer} export LowDimArray, stridedpointer, vectorizable, @avx, @_avx, *ˡ, _avx_!, - vmap, vmap!, vmapnt!, vmapntt!, + vmap, vmap!, vmapnt, vmapnt!, vmapntt, vmapntt!, vfilter, vfilter! diff --git a/src/map.jl b/src/map.jl index 047ca366c..d09be37dc 100644 --- a/src/map.jl +++ b/src/map.jl @@ -24,11 +24,6 @@ end @generated function vmap!(f::F, dest::AbstractArray{T}, args::Vararg{<:AbstractArray,N}) where {F,T,N} vmap_quote(N, T) end -function vmap(f::F, args...) where {F} - T = Base._return_type(f, Base.Broadcast.eltypes(args)) - dest = similar(first(args), T) - vmap!(f, dest, args...) -end function vmapnt!(f::F, y::AbstractVector{T}, args::Vararg{<:Any,A}) where {F,T,A} ptry = pointer(y) @@ -80,6 +75,16 @@ function vmapntt!(f::F, y::AbstractVector{T}, args::Vararg{<:Any,A}) where {F,T, y end +function vmap_call(f::F, vm!::V, args::Vararg{<:Any,N}) where {V,F,N} + T = Base._return_type(f, Base.Broadcast.eltypes(args)) + dest = similar(first(args), T) + vm!(f, dest, args...) +end +vmap(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmap!, args...) +vmapnt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapnt!, args...) +vmapntt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapntt!, args...) + + # @inline vmap!(f, y, x...) = @avx y .= f.(x...) # @inline vmap(f, x...) = @avx f.(x...) diff --git a/test/map.jl b/test/map.jl index e6542425b..8fa475362 100644 --- a/test/map.jl +++ b/test/map.jl @@ -7,9 +7,9 @@ c1 = map(foo, a, b); c2 = vmap(foo, a, b); @test c1 ≈ c2 - fill!(c2, NaN); vmapnt!(foo, c2, a, b); + c2 = vmapnt(foo, a, b); @test c1 ≈ c2 - fill!(c2, NaN); vmapntt!(foo, c2, a, b); + c2 = vmapntt(foo, a, b); @test c1 ≈ c2 @test_throws AssertionError @views vmapnt!(c2[2:end], a[2:end], b[2:end]) @test_throws AssertionError @views vmapntt!(c2[2:end], a[2:end], b[2:end]) diff --git a/test/runtests.jl b/test/runtests.jl index eeb97cb55..6c1f971a2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,6 +18,10 @@ end @time include("printmethods.jl") + @time include("map.jl") + + @time include("filter.jl") + @time include("ifelsemasks.jl") @time include("dot.jl") @@ -32,10 +36,6 @@ end @time include("broadcast.jl") - @time include("map.jl") - - @time include("filter.jl") - @time include("gemm.jl") end