Skip to content

Commit

Permalink
Added vmapnt and vmapntt
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Mar 3, 2020
1 parent 0b7aaa5 commit 7f9123f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <[email protected]>"]
version = "0.6.19"
version = "0.6.20"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/LoopVectorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!


Expand Down
15 changes: 10 additions & 5 deletions src/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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...)

Expand Down
4 changes: 2 additions & 2 deletions test/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -32,10 +36,6 @@ end

@time include("broadcast.jl")

@time include("map.jl")

@time include("filter.jl")

@time include("gemm.jl")

end

2 comments on commit 7f9123f

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/10449

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.20 -m "<description of version>" 7f9123f4e4eaec0814c78b586700fbb20fec662c
git push origin v0.6.20

Please sign in to comment.