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

hpx::make_continuation requires input and output to be the same #1615

Closed
TheConstructor opened this issue Jun 18, 2015 · 5 comments
Closed

Comments

@TheConstructor
Copy link

Today we encountered conversion-errors when trying to chain actions with different input and output types. Let me illustrate the issue with a short example:

boost::int32_t times2(boost::int32_t i) { return i * 2; }
HPX_PLAIN_ACTION(times2);    // defines times2_action

std::string my_to_string(boost::int32_t i) { return std::to_string(i); }
HPX_PLAIN_ACTION(my_to_string);    // defines to_string_action

boost::int32_t result = hpx::async_continue(
        times2_action(), 
        hpx::make_continuation(my_to_string_action()), 
        hpx::find_here(), 
        42).get();
hpx::cout << result << std::endl;   // will print: 3422212

Clearly the actions can be called in the given sequence, but the result should be std::string and not boost::int32_t and it should print 84.

Please provide a way to chain actions where input and output have different types.

@TheConstructor
Copy link
Author

Mitigation requires an action that consumes hpx::future, as it seems that then requires the next action to consume futures while hpx::make_continuation does not.

boost::int32_t times2(boost::int32_t i) { return i * 2; }
HPX_PLAIN_ACTION(times2);    // defines times2_action

std::string my_to_string(hpx::future<boost::int32_t> i) { return std::to_string(i); }
HPX_PLAIN_ACTION(my_to_string);    // defines to_string_action

std::string result = hpx::async(times2_action(), hpx::find_here(), 42).then(
        hpx::util::bind(my_to_string_action(), 
                        hpx::find_here(), 
                        hpx::util::placeholders::_1)).get();
hpx::cout << result << std::endl;   // will print: 84

@hkaiser
Copy link
Member

hkaiser commented Jun 18, 2015

My first investigation shows that this is a bug in the return type calculation performed by make_continuation. This should be easily fixable.

@hkaiser
Copy link
Member

hkaiser commented Jun 18, 2015

@TheConstructor Please see branch 'fixing_1615' which should fix this issue. Please report back whether it solves your problem.

@hkaiser hkaiser added this to the 0.9.11 milestone Jun 18, 2015
@TheConstructor
Copy link
Author

I can confirm that this solves our problem with make_continuation.

@hkaiser
Copy link
Member

hkaiser commented Jun 19, 2015

This will be fixed by merging #1619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants