@@ -58,9 +58,10 @@ function Base.getindex(a::DebugArray,i::Int)
58
58
a. items[i]
59
59
end
60
60
function Base. setindex! (a:: DebugArray ,v,i:: Int )
61
- scalar_indexing_action (a)
62
- a. items[i] = v
63
- v
61
+ error (" DebugArray is inmutable for performance reasons" )
62
+ # scalar_indexing_action(a)
63
+ # a.items[i] = v
64
+ # v
64
65
end
65
66
linear_indices (a:: DebugArray ) = DebugArray (collect (LinearIndices (a)))
66
67
cartesian_indices (a:: DebugArray ) = DebugArray (collect (CartesianIndices (a)))
96
97
getany (a:: DebugArray ) = getany (a. items)
97
98
98
99
function Base. similar (a:: DebugArray ,:: Type{T} ,dims:: Dims ) where T
99
- DebugArray (similar (a. items,T,dims))
100
+ error (" DebugArray is inmutable for performance reasons" )
101
+ # DebugArray(similar(a.items,T,dims))
100
102
end
101
103
102
104
function Base. copyto! (b:: DebugArray ,a:: DebugArray )
103
- copyto! (b. items,a. items)
104
- b
105
+ error (" DebugArray is inmutable for performance reasons" )
106
+ # copyto!(b.items,a.items)
107
+ # b
105
108
end
106
109
107
110
function Base. map (f,args:: DebugArray... )
108
111
DebugArray (map (f,map (i-> i. items,args)... ))
109
112
end
110
113
114
+ function Base. foreach (f,args:: DebugArray... )
115
+ foreach (f,map (i-> i. items,args)... )
116
+ nothing
117
+ end
118
+
111
119
function Base. map! (f,r:: DebugArray ,args:: DebugArray... )
112
- map! (f,r. items,map (i-> i. items,args)... )
113
- r
120
+ error (" DebugArray is inmutable for performance reasons" )
121
+ # map!(f,r.items,map(i->i.items,args)...)
122
+ # r
114
123
end
115
124
116
125
function Base. all (a:: DebugArray )
@@ -121,42 +130,101 @@ function Base.all(p::Function,a::DebugArray)
121
130
all (b)
122
131
end
123
132
133
+ # function allocate_gather_impl(snd::DebugArray,destination)
134
+ # rcv = allocate_gather_impl(snd.items,destination)
135
+ # DebugArray(rcv)
136
+ # end
137
+
124
138
function gather_impl! (
125
139
rcv:: DebugArray , snd:: DebugArray ,
126
- destination, :: Type{T} ) where T
127
- gather_impl! (rcv. items,snd. items,destination,T )
140
+ destination)
141
+ gather_impl! (rcv. items,snd. items,destination)
128
142
end
129
143
130
- function gather_impl! (
131
- rcv:: DebugArray , snd:: DebugArray ,
132
- destination, :: Type{T} ) where T <: AbstractVector
133
- gather_impl! (rcv. items,snd. items,destination,T)
144
+ # function setup_scatter_impl(snd::DebugArray,source)
145
+ # setup_scatter_impl(snd.items,source)
146
+ # end
147
+
148
+ function scatter_impl (snd:: DebugArray ,source)
149
+ rcv = scatter_impl (snd. items,source)
150
+ DebugArray (rcv)
151
+ end
152
+
153
+ function scatter_impl! (rcv:: DebugArray ,snd:: DebugArray ,source,:: Type{T} ) where T
154
+ error (" In place scatter only for vectors" )
155
+ end
156
+
157
+ function scatter_impl! (rcv:: DebugArray ,snd:: DebugArray ,source,:: Type{T} ) where T<: AbstractVector
158
+ scatter_impl! (rcv. items,snd. items,source)
159
+ rcv
160
+ end
161
+
162
+ # function setup_multicast_impl(snd::DebugArray,source)
163
+ # setup_multicast_impl(snd.items,source)
164
+ # end
165
+
166
+ function multicast_impl (snd:: DebugArray ,source)
167
+ rcv = multicast_impl (snd. items,source)
168
+ DebugArray (rcv)
134
169
end
135
170
136
- function scatter_impl! (
137
- rcv:: DebugArray ,snd:: DebugArray ,
138
- source,:: Type{T} ) where T
139
- scatter_impl! (rcv. items,snd. items,source,T)
171
+ function multicast_impl! (rcv:: DebugArray ,snd:: DebugArray ,source,:: Type{T} ) where T
172
+ error (" In place multicast only for vectors" )
140
173
end
141
174
142
- function scatter_impl! (
143
- rcv:: DebugArray ,snd:: DebugArray ,
144
- source,:: Type{T} ) where T<: AbstractVector
145
- scatter_impl! (rcv. items,snd. items,source,T)
175
+ function multicast_impl! (rcv:: DebugArray ,snd:: DebugArray ,source,:: Type{T} ) where T<: AbstractVector
176
+ multicast_impl! (rcv. items,snd. items,source)
177
+ rcv
146
178
end
147
179
148
- function multicast_impl! (
149
- rcv:: DebugArray ,snd:: DebugArray ,
150
- source,:: Type{T} ) where T
151
- multicast_impl! (rcv. items,snd. items,source,T)
180
+ # function setup_scatter_impl(op,a::DebugArray,init,type)
181
+ # setup_scatter_impl(op,a.items,init,type)
182
+ # end
183
+
184
+ function scan_impl (op,a:: DebugArray ,init,type)
185
+ b = scan_impl (op,a. items,init,type)
186
+ DebugArray (b)
152
187
end
153
188
154
- function multicast_impl! (
155
- rcv:: DebugArray ,snd:: DebugArray ,
156
- source,:: Type{T} ) where T<: AbstractVector
157
- multicast_impl! (rcv. items,snd. items,source,T)
189
+ # function setup_reduction_impl(op,a::DebugArray,destination)
190
+ # setup_reduction_impl(op,a.items,destination)
191
+ # end
192
+
193
+ function reduction_impl (op,a:: DebugArray ,destination;kwargs... )
194
+ b = reduction_impl (op,a. items,destination;kwargs... )
195
+ DebugArray (b)
158
196
end
159
197
198
+ # function gather_impl!(
199
+ # rcv::DebugArray, snd::DebugArray,
200
+ # destination, ::Type{T}) where T <: AbstractVector
201
+ # gather_impl!(rcv.items,snd.items,destination,T)
202
+ # end
203
+
204
+ # function scatter_impl!(
205
+ # rcv::DebugArray,snd::DebugArray,
206
+ # source,::Type{T}) where T
207
+ # scatter_impl!(rcv.items,snd.items,source,T)
208
+ # end
209
+ #
210
+ # function scatter_impl!(
211
+ # rcv::DebugArray,snd::DebugArray,
212
+ # source,::Type{T}) where T<:AbstractVector
213
+ # scatter_impl!(rcv.items,snd.items,source,T)
214
+ # end
215
+ #
216
+ # function multicast_impl!(
217
+ # rcv::DebugArray,snd::DebugArray,
218
+ # source,::Type{T}) where T
219
+ # multicast_impl!(rcv.items,snd.items,source,T)
220
+ # end
221
+ #
222
+ # function multicast_impl!(
223
+ # rcv::DebugArray,snd::DebugArray,
224
+ # source,::Type{T}) where T<:AbstractVector
225
+ # multicast_impl!(rcv.items,snd.items,source,T)
226
+ # end
227
+
160
228
Base. reduce (op,a:: DebugArray ;kwargs... ) = reduce (op,a. items;kwargs... )
161
229
Base. sum (a:: DebugArray ) = reduce (+ ,a)
162
230
Base. collect (a:: DebugArray ) = collect (a. items)
@@ -166,29 +234,51 @@ function is_consistent(graph::ExchangeGraph{<:DebugArray})
166
234
is_consistent (g)
167
235
end
168
236
169
- function exchange_impl! (
170
- rcv :: DebugArray ,
171
- snd:: DebugArray ,
172
- graph :: ExchangeGraph{<:DebugArray} ,
173
- :: Type{T} ) where T
174
- g = ExchangeGraph (graph . snd . items,graph . rcv . items)
175
- @async begin
176
- yield () # This is to make more likely to have errors if we don't wait
177
- exchange_impl! ( rcv. items ,snd. items,g,T) |> wait
178
- rcv
179
- end
237
+ function allocate_exchange_impl (
238
+ snd :: DebugArray ,graph :: ExchangeGraph{<:DebugArray} )
239
+ graph2 = ExchangeGraph (graph . snd. items,graph . rcv . items)
240
+ rcv = allocate_exchange_impl (snd . items,graph2)
241
+ DebugArray (rcv)
242
+ end
243
+
244
+ function setup_exchange_impl (
245
+ rcv:: DebugArray ,snd:: DebugArray ,graph :: ExchangeGraph{<:DebugArray} )
246
+ graph2 = ExchangeGraph (graph . snd . items,graph . rcv. items)
247
+ setup_exchange_impl (rcv . items,snd . items,graph2)
180
248
end
181
249
182
250
function exchange_impl! (
183
- rcv:: DebugArray ,
184
- snd:: DebugArray ,
185
- graph:: ExchangeGraph{<:DebugArray} ,
186
- :: Type{T} ) where T <: AbstractVector
187
- g = ExchangeGraph (graph. snd. items,graph. rcv. items)
188
- @async begin
189
- yield () # This is to make more likely to have errors if we don't wait
190
- exchange_impl! (rcv. items,snd. items,g,T) |> wait
191
- rcv
192
- end
251
+ rcv:: DebugArray ,snd:: DebugArray ,graph:: ExchangeGraph{<:DebugArray} ,setup)
252
+ graph2 = ExchangeGraph (graph. snd. items,graph. rcv. items)
253
+ exchange_impl! (rcv. items,snd. items,graph2,setup)
254
+ @fake_async rcv
193
255
end
194
256
257
+ # function exchange_impl!(
258
+ # rcv::DebugArray,
259
+ # snd::DebugArray,
260
+ # graph::ExchangeGraph{<:DebugArray},
261
+ # setup,
262
+ # ::Type{T}) where T
263
+ # g = ExchangeGraph(graph.snd.items,graph.rcv.items)
264
+ # @fake_async begin
265
+ # yield() # This is to make more likely to have errors if we don't wait
266
+ # exchange_impl!(rcv.items,snd.items,g,setup,T) |> wait
267
+ # rcv
268
+ # end
269
+ # end
270
+ #
271
+ # function exchange_impl!(
272
+ # rcv::DebugArray,
273
+ # snd::DebugArray,
274
+ # graph::ExchangeGraph{<:DebugArray},
275
+ # setup,
276
+ # ::Type{T}) where T <: AbstractVector
277
+ # g = ExchangeGraph(graph.snd.items,graph.rcv.items)
278
+ # @fake_async begin
279
+ # yield() # This is to make more likely to have errors if we don't wait
280
+ # exchange_impl!(rcv.items,snd.items,g,setup,T) |> wait
281
+ # rcv
282
+ # end
283
+ # end
284
+
0 commit comments