Andy,
> quick question on dataflow: I have a function with two different
> parameters and I'd to add this to my dataflow graph. How should I
> define the operation and/or the parameters in dataflow()?
>
> The attached code gives me a compile error, but it works if I modify
> it so ping() has only one type of parameter (either the vector or the
> int) and supply only that parameter in dataflow(). Am I missing
> something obvious?
This is a known issue with unwrapped (see #1126). Unwrapped does not
gracefully handle types with differently deep 'embeddedness' (if this is a
word) of futures, i.e. vector<future> and future, etc.
Simply nobody has found the energy by now to properly fix it...
As a workaround I'd suggest not to use unwrapped() on the function object,
but to invoke it yourself for all arguments inside it:
#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <iostream>
using boost::program_options::variables_map;
using boost::program_options::options_description;
class Foo
{
public:
int ping(std::vector<hpx::shared_future<double> > && dependencies,
hpx::future<int> && f)
{
// call unwrapped yourself for each argument
std::vector<double> values =
hpx::util::unwrapped(std::move(dependencies));
int a = f.get();
std::cout << "Foo::ping()\n";
return 0;
}
};
int hpx_main(variables_map & vm)
{
std::cout << "hello world!\n";
Foo foo;
std::vector<hpx::shared_future<double> > dependencies;
dependencies.push_back(hpx::make_ready_future(4.5));
// note: no unwrapped...
auto Operation = boost::bind(&Foo::ping, foo, _1, _2);
auto result = hpx::dataflow(
hpx::launch::async,
Operation,
dependencies,
hpx::make_ready_future(5));
result.get();
return hpx::finalize();
}
int main(int argc, char **argv)
{
std::vector<std::string> config(1, "hpx.run_hpx_main!=1");
options_description desc_commandline("usage: " HPX_APPLICATION_STRING "
[options]");
return hpx::init(desc_commandline, argc, argv, config);
}
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