@@ -54,14 +54,14 @@ function vmap_singlethread!(
54
54
:: Val{NonTemporal} ,
55
55
args:: Vararg{AbstractArray,A}
56
56
) where {F,T <: Base.HWReal , A, NonTemporal}
57
- ptry, ptrargs, N = setup_vmap! (f, y, Val {NonTemporal} (), args... )
58
- vmap_singlethread ! (f, ptry, Zero (), N, Val {NonTemporal} (), ptrargs)
59
- nothing
57
+ ptry, ptrargs, N = setup_vmap! (f, y, Val {NonTemporal} (), args... )
58
+ _vmap_singlethread ! (f, ptry, Zero (), N, Val {NonTemporal} (), ptrargs)
59
+ nothing
60
60
end
61
- function vmap_singlethread ! (
62
- f:: F , ptry:: AbstractStridedPointer{T} ,
63
- start, N, :: Val{NonTemporal} ,
64
- ptrargs:: Tuple{Vararg{AbstractStridedPointer ,A}}
61
+ function _vmap_singlethread ! (
62
+ f:: F , ptry:: AbstractStridedPointer{T} ,
63
+ start, N, :: Val{NonTemporal} ,
64
+ ptrargs:: Tuple{Vararg{Any ,A}}
65
65
) where {F, T, NonTemporal, A}
66
66
i = convert (Int, start)
67
67
V = VectorizationBase. pick_vector_width (promote_type (T, reduce (promote_type, map (eltype, ptrargs))))
@@ -111,25 +111,25 @@ end
111
111
112
112
abstract type AbstractVmapClosure{NonTemporal,F,D,N,A<: Tuple{Vararg{StridedPointer,N}} } <: Function end
113
113
struct VmapClosure{NonTemporal,F,D,N,A} <: AbstractVmapClosure{NonTemporal,F,D,N,A}
114
- f:: F
115
- function VmapClosure {NonTemporal} (f:: F , :: D , :: A ) where {NonTemporal,F,D,N,A<: Tuple{Vararg{StridedPointer,N}} }
116
- new {NonTemporal,F,D,N,A} (f)
117
- end
114
+ f:: F
115
+ function VmapClosure {NonTemporal} (f:: F , :: D , :: A ) where {NonTemporal,F,D,N,A<: Tuple{Vararg{StridedPointer,N}} }
116
+ new {NonTemporal,F,D,N,A} (f)
117
+ end
118
118
end
119
119
# struct VmapKnownClosure{NonTemporal,F,D,N,A} <: AbstractVmapClosure{NonTemporal,F,D,N,A} end
120
120
121
121
# @generated function (::VmapKnownClosure{NonTemporal,F,D,N,A})(p::Ptr{UInt}) where {NonTemporal,F,D,N,A}
122
122
# :(_vmap_thread_call!($(F.instance), p, $D, $A, Val{$NonTemporal}()))
123
123
# end
124
124
function (m:: VmapClosure{NonTemporal,F,D,N,A} )(p:: Ptr{UInt} ) where {NonTemporal,F,D,N,A}
125
- (offset, dest) = ThreadingUtilities. load (p, D, 2 * sizeof (UInt))
126
- (offset, args) = ThreadingUtilities. load (p, A, offset)
127
-
128
- (offset, start) = ThreadingUtilities. load (p, Int, offset)
129
- (offset, stop ) = ThreadingUtilities. load (p, Int, offset)
130
-
131
- vmap_singlethread ! (m. f, dest, start, stop, Val {NonTemporal} (), args)
132
- nothing
125
+ (offset, dest) = ThreadingUtilities. load (p, D, 2 * sizeof (UInt))
126
+ (offset, args) = ThreadingUtilities. load (p, A, offset)
127
+
128
+ (offset, start) = ThreadingUtilities. load (p, Int, offset)
129
+ (offset, stop ) = ThreadingUtilities. load (p, Int, offset)
130
+
131
+ _vmap_singlethread ! (m. f, dest, start, stop, Val {NonTemporal} (), args)
132
+ nothing
133
133
end
134
134
135
135
@inline function _get_fptr (cfunc:: Base.CFunction )
@@ -146,23 +146,23 @@ end
146
146
@inline function setup_thread_vmap! (
147
147
p, cfunc, ptry, ptrargs, start, stop
148
148
)
149
- fptr = _get_fptr (cfunc)
150
- offset = ThreadingUtilities. store! (p, fptr, sizeof (UInt))
151
- offset = ThreadingUtilities. store! (p, ptry, offset)
152
- offset = ThreadingUtilities. store! (p, ptrargs, offset)
153
- offset = ThreadingUtilities. store! (p, start, offset)
154
- offset = ThreadingUtilities. store! (p, stop, offset)
155
- nothing
149
+ fptr = _get_fptr (cfunc)
150
+ offset = ThreadingUtilities. store! (p, fptr, sizeof (UInt))
151
+ offset = ThreadingUtilities. store! (p, ptry, offset)
152
+ offset = ThreadingUtilities. store! (p, ptrargs, offset)
153
+ offset = ThreadingUtilities. store! (p, start, offset)
154
+ offset = ThreadingUtilities. store! (p, stop, offset)
155
+ nothing
156
156
end
157
157
@inline function launch_thread_vmap! (tid, cfunc, ptry, ptrargs, start, stop)
158
- ThreadingUtilities. launch (tid, cfunc, ptry, ptrargs, start, stop) do p, cfunc, ptry, ptrargs, start, stop
159
- setup_thread_vmap! (p, cfunc, ptry, ptrargs, start, stop)
160
- end
158
+ ThreadingUtilities. launch (tid, cfunc, ptry, ptrargs, start, stop) do p, cfunc, ptry, ptrargs, start, stop
159
+ setup_thread_vmap! (p, cfunc, ptry, ptrargs, start, stop)
160
+ end
161
161
end
162
162
163
163
@inline function vmap_closure (f:: F , ptry:: D , ptrargs:: A , :: Val{NonTemporal} ) where {F,D<: StridedPointer ,N,A<: Tuple{Vararg{StridedPointer,N}} ,NonTemporal}
164
- vmc = VmapClosure {NonTemporal} (f, ptry, ptrargs)
165
- @cfunction ($ vmc, Cvoid, (Ptr{UInt},))
164
+ vmc = VmapClosure {NonTemporal} (f, ptry, ptrargs)
165
+ @cfunction ($ vmc, Cvoid, (Ptr{UInt},))
166
166
end
167
167
# @inline function _cfunc_closure(f, ptry, ptrargs, ::Val{NonTemporal}) where {NonTemporal}
168
168
# vmc = VmapClosure{NonTemporal}(f, ptry, ptrargs)
@@ -197,7 +197,7 @@ function vmap_multithread!(
197
197
198
198
# if !((nt > 1) && iszero(ccall(:jl_in_threaded_region, Cint, ())))
199
199
if nt < 2
200
- vmap_singlethread ! (f, ptry, Zero (), N, Val {NonTemporal} (), ptrargs)
200
+ _vmap_singlethread ! (f, ptry, Zero (), N, Val {NonTemporal} (), ptrargs)
201
201
return
202
202
end
203
203
@@ -214,7 +214,7 @@ function vmap_multithread!(
214
214
launch_thread_vmap! (tid, cfunc, ptry, ptrargs, start, stop)
215
215
start = stop
216
216
end
217
- vmap_singlethread ! (f, ptry, start, N, Val {NonTemporal} (), ptrargs)
217
+ _vmap_singlethread ! (f, ptry, start, N, Val {NonTemporal} (), ptrargs)
218
218
for tid ∈ 1 : nt- 1
219
219
ThreadingUtilities. wait (tid)
220
220
end
0 commit comments