Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for_each Mike comments applied #1758

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "../detail.hpp"
#include "../init.hpp"
#include "../util.hpp"
#include "../views/zip.hpp"
#include "execution_policy.hpp"

namespace oneapi::dpl::experimental::dr::sp
Expand All @@ -35,6 +34,7 @@ for_each(ExecutionPolicy&& policy, R&& r, Fn fn)
std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

std::vector<sycl::event> events;
events.reserve(stdrng::size(ranges::segments(r)));

for (auto&& segment : ranges::segments(r))
{
Expand All @@ -47,7 +47,7 @@ for_each(ExecutionPolicy&& policy, R&& r, Fn fn)
auto first = stdrng::begin(local_segment);

auto event = dr::__detail::parallel_for(q, sycl::range<>(stdrng::distance(local_segment)),
[=](auto idx) { fn(*(first + idx)); });
[=](auto idx) { fn(first[idx]); });
events.emplace_back(event);
}
__detail::wait(events);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "../../detail/std_ranges_shim.hpp"
#include "../../views/iota.hpp"
#include "../views/zip.hpp"
#include "for_each.hpp"

namespace oneapi::dpl::experimental::dr::sp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ struct distributed_vector
{
size_type segment_id = pos / segment_size_;
size_type local_id = pos % segment_size_;
return *(segments_[segment_id].begin() + local_id);
return segments_[segment_id][local_id];
}

const_reference
operator[](size_type pos) const
{
size_type segment_id = pos / segment_size_;
size_type local_id = pos % segment_size_;
return *(segments_[segment_id].begin() + local_id);
return segments_[segment_id][local_id];
}

size_type
Expand Down
Loading