> > > 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.

Ahh! Yes, that would be the case. Reduce would run only once all
input-futures have become ready. 

We don't have any way to work around that at this point short of
re-implementing reduce to start working on the input elements as they become
available.

Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu



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

Reply via email to