Skip to content

Commit

Permalink
initiate Dense cross-executor copy from source
Browse files Browse the repository at this point in the history
This means that padding in the target will be copied and written back
after the copy has finished.

This fixes issues in builds without OpenMP executor and
reference/test/matrix/dense_kernels
  • Loading branch information
upsj committed Mar 4, 2022
1 parent 6ecbe95 commit 2b15e8a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions core/matrix/dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,17 @@ void Dense<ValueType>::convert_to(Dense<ValueType>* result) const
if (result->get_size() != this->get_size()) {
result->resize(this->get_size());
}
// we need to create a clone of the local data, so the target executor can
// copy it.
auto result_exec = result->get_executor();
auto result_input = make_temporary_clone(result_exec, &values_);
// we need to create a temporary clone of the target data to write to
auto exec = this->get_executor();
auto result_output = make_temporary_clone(exec, &result->values_);
// create a (value, not pointer to avoid allocation overhead) view
// matrix on the array to avoid special-casing cross-executor copies
auto tmp_this = Dense{
result_exec, this->get_size(),
gko::detail::array_const_cast(gko::detail::ConstArrayView<ValueType>(
result_exec, result_input->get_num_elems(),
result_input->get_const_data())),
this->get_stride()};
result_exec->run(dense::make_copy(&tmp_this, result));
auto tmp_result =
Dense{exec, this->get_size(),
make_array_view(exec, result_output->get_num_elems(),
result_output->get_data()),
result->get_stride()};
exec->run(dense::make_copy(this, &tmp_result));
}


Expand Down

0 comments on commit 2b15e8a

Please sign in to comment.