@@ -141,10 +141,13 @@ template <
141
141
typename ValueType,
142
142
typename GlobInputIt >
143
143
ValueType * copy_impl (
144
- GlobInputIt begin,
145
- GlobInputIt end,
146
- ValueType * out_first,
147
- std::vector<dart_handle_t > * handles)
144
+ GlobInputIt begin,
145
+ GlobInputIt end,
146
+ ValueType * out_first,
147
+ std::vector<dart_handle_t > * handles,
148
+ local_copy_chunks<
149
+ typename GlobInputIt::value_type,
150
+ ValueType> & local_chunks)
148
151
{
149
152
DASH_LOG_TRACE (" dash::internal::copy_impl() global -> local" ,
150
153
" in_first:" , begin.pos (),
@@ -171,8 +174,6 @@ ValueType * copy_impl(
171
174
172
175
ContiguousRangeSet<GlobInputIt> range_set{begin, end};
173
176
174
- local_copy_chunks<input_value_type, output_value_type> local_chunks;
175
-
176
177
//
177
178
// Copy elements from every unit:
178
179
//
@@ -216,8 +217,6 @@ ValueType * copy_impl(
216
217
num_elem_copied += num_copy_elem;
217
218
}
218
219
219
- do_local_copies (local_chunks);
220
-
221
220
DASH_ASSERT_EQ (num_elem_copied, num_elem_total,
222
221
" Failed to find all contiguous subranges in range" );
223
222
@@ -238,10 +237,13 @@ template <
238
237
typename ValueType,
239
238
typename GlobOutputIt >
240
239
GlobOutputIt copy_impl (
241
- ValueType * begin,
242
- ValueType * end,
243
- GlobOutputIt out_first,
244
- std::vector<dart_handle_t > * handles)
240
+ ValueType * begin,
241
+ ValueType * end,
242
+ GlobOutputIt out_first,
243
+ std::vector<dart_handle_t > * handles,
244
+ local_copy_chunks<
245
+ ValueType,
246
+ typename GlobOutputIt::value_type> & local_chunks)
245
247
{
246
248
DASH_LOG_TRACE (" dash::copy_impl() local -> global" ,
247
249
" in_first:" , begin,
@@ -271,8 +273,6 @@ GlobOutputIt copy_impl(
271
273
272
274
ContiguousRangeSet<GlobOutputIt> range_set{out_first, out_last};
273
275
274
- local_copy_chunks<input_value_type, output_value_type> local_chunks;
275
-
276
276
auto in_first = begin;
277
277
278
278
//
@@ -317,8 +317,6 @@ GlobOutputIt copy_impl(
317
317
num_elem_copied += num_copy_elem;
318
318
}
319
319
320
- do_local_copies (local_chunks);
321
-
322
320
DASH_ASSERT_EQ (num_elem_copied, num_elem_total,
323
321
" Failed to find all contiguous subranges in range" );
324
322
@@ -355,9 +353,10 @@ dash::Future<ValueType *> copy_async(
355
353
}
356
354
357
355
auto handles = std::make_shared<std::vector<dart_handle_t >>();
358
-
359
- auto out_last = dash::internal::copy_impl (in_first, in_last,
360
- out_first, handles.get ());
356
+ dash::internal::local_copy_chunks<typename GlobInputIt::value_type, ValueType> local_chunks;
357
+ auto out_last = dash::internal::copy_impl (in_first, in_last, out_first,
358
+ handles.get (), local_chunks);
359
+ dash::internal::do_local_copies (local_chunks);
361
360
362
361
if (handles->empty ()) {
363
362
DASH_LOG_TRACE (" dash::copy_async" , " all transfers completed" );
@@ -439,24 +438,29 @@ ValueType * copy(
439
438
}
440
439
441
440
ValueType *out_last;
441
+ dash::internal::local_copy_chunks<typename GlobInputIt::value_type, ValueType> local_chunks;
442
442
if (UseHandles) {
443
443
std::vector<dart_handle_t > handles;
444
444
out_last = dash::internal::copy_impl (in_first,
445
445
in_last,
446
446
out_first,
447
- &handles);
447
+ &handles,
448
+ local_chunks);
448
449
if (!handles.empty ()) {
449
450
DASH_LOG_TRACE (" dash::copy" , " Waiting for remote transfers to complete," ,
450
451
" num_handles: " , handles.size ());
451
452
dart_waitall_local (handles.data (), handles.size ());
452
453
}
454
+ dash::internal::do_local_copies (local_chunks);
453
455
454
456
} else {
455
457
out_last = dash::internal::copy_impl (in_first,
456
458
in_last,
457
459
out_first,
458
- nullptr );
460
+ nullptr ,
461
+ local_chunks);
459
462
DASH_LOG_TRACE (" dash::copy" , " Waiting for remote transfers to complete" );
463
+ dash::internal::do_local_copies (local_chunks);
460
464
dart_flush_local_all (in_first.dart_gptr ());
461
465
}
462
466
@@ -489,10 +493,13 @@ dash::Future<GlobOutputIt> copy_async(
489
493
}
490
494
491
495
auto handles = std::make_shared<std::vector<dart_handle_t >>();
496
+ dash::internal::local_copy_chunks<ValueType, typename GlobOutputIt::value_type> local_chunks;
492
497
auto out_last = dash::internal::copy_impl (in_first,
493
498
in_last,
494
499
out_first,
495
- handles.get ());
500
+ handles.get (),
501
+ local_chunks);
502
+ dash::internal::do_local_copies (local_chunks);
496
503
497
504
if (handles->empty ()) {
498
505
return dash::Future<GlobOutputIt>(out_last);
@@ -561,12 +568,15 @@ GlobOutputIt copy(
561
568
DASH_LOG_TRACE (" dash::copy()" , " blocking, local to global" );
562
569
// handles to wait on at the end
563
570
GlobOutputIt out_last;
571
+ dash::internal::local_copy_chunks<ValueType, typename GlobOutputIt::value_type> local_chunks;
564
572
if (UseHandles) {
565
573
std::vector<dart_handle_t > handles;
566
574
out_last = dash::internal::copy_impl (in_first,
567
575
in_last,
568
576
out_first,
569
- &handles);
577
+ &handles,
578
+ local_chunks);
579
+ dash::internal::do_local_copies (local_chunks);
570
580
571
581
if (!handles.empty ()) {
572
582
DASH_LOG_TRACE (" dash::copy" , " Waiting for remote transfers to complete," ,
@@ -577,8 +587,10 @@ GlobOutputIt copy(
577
587
out_last = dash::internal::copy_impl (in_first,
578
588
in_last,
579
589
out_first,
580
- nullptr );
590
+ nullptr ,
591
+ local_chunks);
581
592
DASH_LOG_TRACE (" dash::copy" , " Waiting for remote transfers to complete" );
593
+ dash::internal::do_local_copies (local_chunks);
582
594
dart_flush_all (out_first.dart_gptr ());
583
595
}
584
596
return out_last;
0 commit comments