Skip to content

Commit

Permalink
applied Mike comments about foraech (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslusarczyk authored Aug 5, 2024
1 parent 530380b commit f3a1df5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
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

0 comments on commit f3a1df5

Please sign in to comment.