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

Updates from Adam's comments #1766

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 @@ -40,6 +40,12 @@ template <typename ExecutionPolicy, distributed_contiguous_range R, distributed_
void
exclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, U init, BinaryOp binary_op)
{
if (stdrng::begin(r) == stdrng::end(r))
{
*stdrng::begin(o) = init;
return;
}

using T = stdrng::range_value_t<O>;

static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);
Expand All @@ -52,6 +58,7 @@ exclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, U init, BinaryOp bi
std::vector<sycl::event> events;

std::size_t segment_id = 0;

for (auto&& segs : zipped_segments)
{
auto&& [in_segment, out_segment] = segs;
Expand All @@ -71,7 +78,7 @@ exclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, U init, BinaryOp bi

std::vector<U> inits(stdrng::size(zipped_segments));

copy(d_inits, d_inits + inits.size(), inits.data() + 1);
copy(d_inits, d_inits + (inits.size() - 1), inits.data() + 1);

sycl::free(d_inits, context());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ inclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, BinaryOp binary_op,
{
using T = stdrng::range_value_t<O>;

if (stdrng::begin(r) == stdrng::end(r))
{
return;
}

static_assert(std::is_same_v<std::remove_cvref_t<ExecutionPolicy>, sycl_device_collection>);

auto zipped_view = views::zip(r, o);
Expand Down Expand Up @@ -100,10 +105,7 @@ inclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, BinaryOp binary_op,

auto e = q.submit([&](auto&& h) {
h.depends_on(event);
h.single_task([=]() {
stdrng::range_value_t<O> value = *src_iter;
*dst_iter = value;
});
h.single_task([=]() { *dst_iter = *src_iter; });
});

events.push_back(e);
Expand All @@ -125,10 +127,9 @@ inclusive_scan_impl_(ExecutionPolicy&& policy, R&& r, O&& o, BinaryOp binary_op,
std::size_t idx = 0;
for (auto&& segs : zipped_segments)
{
auto&& [in_segment, out_segment] = segs;

if (idx > 0)
{
auto&& [in_segment, out_segment] = segs;
auto&& q = __detail::queue(ranges::rank(out_segment));

auto first = stdrng::begin(out_segment);
Expand Down
2 changes: 1 addition & 1 deletion test/distributed_ranges/sp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ endfunction()
# sort: https://github.com/oneapi-src/distributed-ranges/issues/785
# ExclusiveScan.empty: https://github.com/oneapi-src/distributed-ranges/issues/791
# IotaView.ZipWithDR: https://github.com/oneapi-src/distributed-ranges/issues/792
set(test-exclusions Sort*:SpTests.Sort*:ExclusiveScan*empty:IotaView*ZipWithDR)
set(test-exclusions Sort*:SpTests.Sort*:IotaView*ZipWithDR)

add_sp_ctest(sp_tests sp_tests --gtest_filter=-${test-exclusions})
add_sp_ctest(sp_tests_3 sp_tests --devicesCount 3 --gtest_filter=-${test-exclusions})
Expand Down
Loading