> > Suppose we have a vector of futures of type T and we want to reduce the
> > values contained in the futures using T op(T, T), with initial value of
> > init. What is the HPX recommended way of doing this? What should the
> > implementation of "future<T> myreduce(vector<future<T> > fs, T init, Op
> > op)" be?
> > 
> > hpx::parallel::reduce can't be used with a vector of futures.
> > hpx::lcos::reduce isn't what we're looking for as this isn't a distributed
> > operation. One option is to use hpx::when_any and accumulate the values as
> > they are ready. But this serializes the accumulation of the futures, which
> > may not be desirable.
> 
> How about:
> 
>     vector<future<T>> v = ...;
>     future<T> f = 
>         dataflow(unwrapped(
>             [](vector<T> && data) -> T
>             {
>                 return parallel::reduce(
>                     par, data.begin(), data.end(), op);
>             }),
>             std::move(v)
>         );

This would work but wouldn't parallel::reduce  not start until all 
of the futures in v are ready? I'd be concerned that waiting on all of v
 could take too long. Especially if this were the last task in an 
application (no other asynchrony is available) and some elements in v 
may be ready much later than other elements in v. 

Thanks,
Daniel


                                          
_______________________________________________
hpx-users mailing list
[email protected]
https://mail.cct.lsu.edu/mailman/listinfo/hpx-users

Reply via email to