From f3a1df595a5282a5b54f22fb390bad1ca737c9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=C5=9Alusarczyk?= <112692748+lslusarczyk@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:15:20 +0200 Subject: [PATCH] applied Mike comments about foraech (#1758) --- .../distributed_ranges_impl/sp/algorithms/for_each.hpp | 4 ++-- .../internal/distributed_ranges_impl/sp/algorithms/iota.hpp | 1 + .../distributed_ranges_impl/sp/distributed_vector.hpp | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/for_each.hpp b/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/for_each.hpp index fd345f8b08a..c82938dc7c0 100644 --- a/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/for_each.hpp +++ b/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/for_each.hpp @@ -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 @@ -35,6 +34,7 @@ for_each(ExecutionPolicy&& policy, R&& r, Fn fn) std::is_same_v, sycl_device_collection>); std::vector events; + events.reserve(stdrng::size(ranges::segments(r))); for (auto&& segment : ranges::segments(r)) { @@ -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); diff --git a/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/iota.hpp b/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/iota.hpp index 6151a58e3a8..aa308cd2855 100644 --- a/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/iota.hpp +++ b/include/oneapi/dpl/internal/distributed_ranges_impl/sp/algorithms/iota.hpp @@ -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 diff --git a/include/oneapi/dpl/internal/distributed_ranges_impl/sp/distributed_vector.hpp b/include/oneapi/dpl/internal/distributed_ranges_impl/sp/distributed_vector.hpp index d1abfc414b7..7673ee81f9c 100644 --- a/include/oneapi/dpl/internal/distributed_ranges_impl/sp/distributed_vector.hpp +++ b/include/oneapi/dpl/internal/distributed_ranges_impl/sp/distributed_vector.hpp @@ -191,7 +191,7 @@ 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 @@ -199,7 +199,7 @@ 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]; } size_type