Skip to content

Commit

Permalink
dash::copy: Handle non-/const in struct local_copy_chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
bertwesarg committed Jul 16, 2019
1 parent 62b2353 commit 79b8ea0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions dash/include/dash/algorithm/Copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,18 @@ namespace internal {

template<typename ValueType>
struct local_copy_chunk {
const ValueType *src;
ValueType *dest;
const size_t size;
using nonconst_value_type = typename std::remove_const<ValueType>::type;

const nonconst_value_type *src;
nonconst_value_type *dest;
const size_t size;
};

template<typename ValueType>
void do_local_copies(std::vector<local_copy_chunk<ValueType>>& chunks)
using local_copy_chunks = std::vector<local_copy_chunk<ValueType>>;

template<typename ValueType>
void do_local_copies(local_copy_chunks<ValueType>& chunks)
{
for (auto& chunk : chunks) {
std::copy(chunk.src, chunk.src + chunk.size, chunk.dest);
Expand Down Expand Up @@ -141,7 +146,6 @@ ValueType * copy_impl(
"out_first:", out_first);
typedef typename GlobInputIt::size_type size_type;
typedef typename GlobInputIt::value_type value_type;
typedef typename std::remove_const<value_type>::type nonconst_value_type;
const size_type num_elem_total = dash::distance(begin, end);
if (num_elem_total <= 0) {
DASH_LOG_TRACE("dash::internal::copy_impl", "input range empty");
Expand All @@ -155,7 +159,7 @@ ValueType * copy_impl(

ContiguousRangeSet<GlobInputIt> range_set{begin, end};

std::vector<local_copy_chunk<nonconst_value_type>> local_chunks;
local_copy_chunks<ValueType> local_chunks;

//
// Copy elements from every unit:
Expand All @@ -179,9 +183,7 @@ ValueType * copy_impl(
std::copy(src_ptr, src_ptr + num_copy_elem, dest_ptr);
} else {
// larger chunks are handled later to allow overlap
local_copy_chunk<nonconst_value_type> chunk{src_ptr, dest_ptr,
num_copy_elem};
local_chunks.push_back(chunk);
local_chunks.push_back({src_ptr, dest_ptr, num_copy_elem});
}
} else {
auto src_gptr = cur_in.dart_gptr();
Expand Down Expand Up @@ -252,7 +254,7 @@ GlobOutputIt copy_impl(

ContiguousRangeSet<GlobOutputIt> range_set{out_first, out_last};

std::vector<local_copy_chunk<value_type>> local_chunks;
local_copy_chunks<value_type> local_chunks;

auto in_first = begin;

Expand Down

0 comments on commit 79b8ea0

Please sign in to comment.