Daniel,

> 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)
        );

Now you can do other things until you actually need the result of the reduce
operation, at which point you call 

    T reduce_result = f.get();

Alternatively you can attach a continuation to f to add more asynchrony.

HTH
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