Skip to content

Commit f3a10f8

Browse files
committed
Adress Vararg warnings on master.
1 parent 438a519 commit f3a10f8

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/map.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11

2+
const DenseNativeArray = DenseArray{<:NativeTypes}
3+
24
"""
35
`vstorent!` (non-temporal store) requires data to be aligned.
46
`alignstores!` will align `y` in preparation for the non-temporal maps.
57
"""
68
function alignstores!(
79
f::F, y::DenseArray{T},
8-
args::Vararg{<:DenseArray{<:Base.HWReal},A}
10+
args::Vararg{DenseNativeArray,A}
911
) where {F, T <: Base.HWReal, A}
1012
N = length(y)
1113
ptry = VectorizationBase.zero_offsets(stridedpointer(y))
@@ -32,7 +34,7 @@ end
3234
function vmap_singlethread!(
3335
f::F, y::DenseArray{T},
3436
::Val{NonTemporal},
35-
args::Vararg{<:DenseArray{<:Base.HWReal},A}
37+
args::Vararg{DenseNativeArray,A}
3638
) where {F,T <: Base.HWReal, A, NonTemporal}
3739
if NonTemporal # if stores into `y` aren't aligned, we'll get a crash
3840
ptry, ptrargs, N = alignstores!(f, y, args...)
@@ -80,7 +82,7 @@ function vmap_multithreaded!(
8082
f::F,
8183
y::DenseArray{T},
8284
::Val{true},
83-
args::Vararg{<:DenseArray{<:Base.HWReal},A}
85+
args::Vararg{DenseNativeArray,A}
8486
) where {F,T,A}
8587
ptry, ptrargs, N = alignstores!(f, y, args...)
8688
N > 0 || return y
@@ -107,7 +109,7 @@ function vmap_multithreaded!(
107109
f::F,
108110
y::DenseArray{T},
109111
::Val{false},
110-
args::Vararg{<:DenseArray{<:Base.HWReal},A}
112+
args::Vararg{DenseNativeArray,A}
111113
) where {F,T,A}
112114
N = length(y)
113115
ptry = VectorizationBase.zero_offsets(stridedpointer(y))
@@ -142,7 +144,7 @@ Vectorized-`map!`, applying `f` to each element of `a` (or paired elements of `a
142144
and storing the result in `destination`.
143145
"""
144146
function vmap!(
145-
f::F, y::DenseArray{T}, args::Vararg{<:DenseArray{<:Base.HWReal},A}
147+
f::F, y::DenseArray{T}, args::Vararg{DenseNativeArray,A}
146148
) where {F,T<:Base.HWReal,A}
147149
vmap_singlethread!(f, y, Val{false}(), args...)
148150
end
@@ -154,7 +156,7 @@ end
154156
Like `vmap!` (see `vmap!`), but uses `Threads.@threads` for parallel execution.
155157
"""
156158
function vmapt!(
157-
f::F, y::DenseArray{T}, args::Vararg{<:DenseArray{<:Base.HWReal},A}
159+
f::F, y::DenseArray{T}, args::Vararg{DenseNativeArray,A}
158160
) where {F,T<:Base.HWReal,A}
159161
vmap_multithreaded!(f, y, Val{false}(), args...)
160162
end
@@ -216,7 +218,7 @@ BenchmarkTools.Trial:
216218
```
217219
"""
218220
function vmapnt!(
219-
f::F, y::DenseArray{T}, args::Vararg{<:DenseArray{<:Base.HWReal},A}
221+
f::F, y::DenseArray{T}, args::Vararg{DenseNativeArray,A}
220222
) where {F,T<:Base.HWReal,A}
221223
vmap_singlethread!(f, y, Val{true}(), args...)
222224
end
@@ -227,7 +229,7 @@ end
227229
Like `vmapnt!` (see `vmapnt!`), but uses `Threads.@threads` for parallel execution.
228230
"""
229231
function vmapntt!(
230-
f::F, y::DenseArray{T}, args::Vararg{<:DenseArray{<:Base.HWReal},A}
232+
f::F, y::DenseArray{T}, args::Vararg{DenseNativeArray,A}
231233
) where {F,T<:Base.HWReal,A}
232234
vmap_multithreaded!(f, y, Val{true}(), args...)
233235
end
@@ -238,7 +240,7 @@ end
238240
@inline vmapnt!(f, args...) = map!(f, args...)
239241
@inline vmapntt!(f, args...) = map!(f, args...)
240242

241-
function vmap_call(f::F, vm!::V, args::Vararg{<:Any,N}) where {V,F,N}
243+
function vmap_call(f::F, vm!::V, args::Vararg{Any,N}) where {V,F,N}
242244
T = Base._return_type(f, Base.Broadcast.eltypes(args))
243245
dest = similar(first(args), T)
244246
vm!(f, dest, args...)
@@ -251,15 +253,15 @@ end
251253
SIMD-vectorized `map`, applying `f` to each element of `a` (or paired elements of `a`, `b`, ...)
252254
and returning a new array.
253255
"""
254-
vmap(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmap!, args...)
256+
vmap(f::F, args::Vararg{Any,N}) where {F,N} = vmap_call(f, vmap!, args...)
255257

256258
"""
257259
vmapt(f, a::AbstractArray)
258260
vmapt(f, a::AbstractArray, b::AbstractArray, ...)
259261
260262
A threaded variant of [`vmap`](@ref).
261263
"""
262-
vmapt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapt!, args...)
264+
vmapt(f::F, args::Vararg{Any,N}) where {F,N} = vmap_call(f, vmapt!, args...)
263265

264266
"""
265267
vmapnt(f, a::AbstractArray)
@@ -268,15 +270,15 @@ vmapt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapt!, args...)
268270
A "non-temporal" variant of [`vmap`](@ref). This can improve performance in cases where
269271
`destination` will not be needed soon.
270272
"""
271-
vmapnt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapnt!, args...)
273+
vmapnt(f::F, args::Vararg{Any,N}) where {F,N} = vmap_call(f, vmapnt!, args...)
272274

273275
"""
274276
vmapntt(f, a::AbstractArray)
275277
vmapntt(f, a::AbstractArray, b::AbstractArray, ...)
276278
277279
A threaded variant of [`vmapnt`](@ref).
278280
"""
279-
vmapntt(f::F, args::Vararg{<:Any,N}) where {F,N} = vmap_call(f, vmapntt!, args...)
281+
vmapntt(f::F, args::Vararg{Any,N}) where {F,N} = vmap_call(f, vmapntt!, args...)
280282

281283

282284
# @inline vmap!(f, y, x...) = @avx y .= f.(x...)

src/mapreduce.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _vreduce(op, v::Vec{1}) = VectorizationBase.extractelement(v, 0)
1414
a
1515
end
1616

17-
function mapreduce_simple(f::F, op::OP, args::Vararg{DenseArray{<:NativeTypes},A}) where {F,OP,A}
17+
function mapreduce_simple(f::F, op::OP, args::Vararg{DenseArray{T},A}) where {F,OP,A,T<:NativeTypes}
1818
ptrargs = ntuple(a -> pointer(args[a]), Val(A))
1919
N = length(first(args))
2020
iszero(N) && throw("Length of vector is 0!")

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Test
22
using LoopVectorization
3+
34
using LinearAlgebra
45
import InteractiveUtils
56

@@ -80,3 +81,4 @@ end
8081

8182
const ELAPSED_MINUTES = (time() - START_TIME)/60
8283
@test ELAPSED_MINUTES < 180
84+

0 commit comments

Comments
 (0)