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

Give inclusive_scan an overload with init #693

Closed
4 of 5 tasks
jaredhoberock opened this issue Jun 7, 2013 · 6 comments · Fixed by #1940
Closed
4 of 5 tasks

Give inclusive_scan an overload with init #693

jaredhoberock opened this issue Jun 7, 2013 · 6 comments · Fixed by #1940
Assignees
Labels
thrust For all items related to Thrust.

Comments

@jaredhoberock
Copy link

jaredhoberock commented Jun 7, 2013

It's difficult to implement scan and other sequences of scan or sums otherwise. The init parameter can accept the "carry" of the previous sum. inclusive_scan without init can easily be implemented by the more general overload by passing the initial input element as the init and having the first thread copy to the first element of the output.

Tasks

  1. gonidelis
  2. feature request
    gonidelis
@jaredhoberock
Copy link
Author

This will subtly change the semantics of inclusive_scan without init, but we should do it anyway to match N3724.

Currently in Thrust, if the intermediate_type differs from the input & output types, then the first element of the result will go through a conversion:

intermediate_type sum = *first;

*result = sum;

for(++first, ++result; first != last; ++first, ++result)
  *result = sum = binary_op(sum,*first);

After giving inclusive_scan an init parameter, the semantics of inclusive_scan would be

inclusive_scan(..., T init, ...)
{
  *result = init;

  for(++first, ++result; first != last; ++first, ++result)
    *result = init = binary_op(init,*first);
}

In other words, the intermediate_type is simply the type of init, as in exclusive_scan.

@jaredhoberock
Copy link
Author

Better wait and see what syntax shakes out of Parallelism TS

@dkolsen-pgi
Copy link
Collaborator

To fully implement stdpar, nvc++ needs the overloads of inclusive_scan and transform_inclusive_scan that take an initial value.

@brycelelbach brycelelbach changed the title give inclusive_scan an overload with init Give inclusive_scan an overload with init Mar 29, 2021
@jrhemstad jrhemstad added the thrust For all items related to Thrust. label Feb 22, 2023
@dkolsen-pgi
Copy link
Collaborator

We received our first bug report from an end user about this. The lack of this function in Thrust means one of the overloads of std::inclusive_scan cannot be parallelized by nvc++ -stdpar.

@jarmak-nv jarmak-nv transferred this issue from NVIDIA/thrust Nov 8, 2023
@brycelelbach
Copy link
Collaborator

Any updates or ETA on this?

@gonidelis
Copy link
Member

@brycelelbach incoming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
thrust For all items related to Thrust.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants