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

Allowing remote direct actions to be executed without spawning a task #2336

Merged
merged 1 commit into from Oct 5, 2016

Conversation

sithhell
Copy link
Member

With this patch, direct actions are now always executed directly on the
receiving side. This means that they might get executed in a non-HPX thread.

This is a breaking change in behavior as it doesn't require direct_actions to run on HPX threads.

@biddisco
Copy link
Contributor

Note : This partially addresses #2284

// non HPX thread.
bool recurse_asynchronously = hpx::threads::get_self_ptr() == nullptr;
#if defined(HPX_HAVE_THREADS_GET_STACK_POINTER)
recurse_asynchronously =
!this_thread::has_sufficient_stack_space();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this_thread::has_sufficient_stack_space() fail if not executed on a HPX thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. If not executed on an HPX thread, this_thread::has_sufficient_stack_space() returns false.

@@ -82,6 +82,8 @@ namespace hpx { namespace lcos { namespace server
}
}

HPX_DEFINE_COMPONENT_ACTION(barrier, set_event, set_event_non_direct_action);

Copy link
Member

@hkaiser hkaiser Sep 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to move this new action to the base_lco base class as other LCO's might require this functionality as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking, will fix that.

// Direct actions should be able to be executed from a non-HPX thread
// as well
if (this_thread::has_sufficient_stack_space() ||
hpx::threads::get_self_ptr() == nullptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you check both, the stack space and whether its running on an HPX thread. You might want to revisit my comment above related to this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this when introducing the semantics of this_thread::has_sufficient_stack_space(), which returns false when not in an HPX thread. I never liked this since a regular OS thread should have sufficient stack space in any case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way is fine, let's make it consistent, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we have now is consistent, I guess. It is just the special case of when we try to run a direct action inside of one of the parcel pool threads where I want it to be run directly as well (as in not on a HPX thread, but still execute it directly if it is a direct action).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see it now. Thanks for the explanations.

{};
}}

#define HPX_TRAITS_ACTION_DIRECT_EXECUTION(Action, DirectExecution) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this new traits class used anywhere? Shouldn't all existing direct actions now use this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trait class doesn't have any specialization so far. It is used where we check for direct actions, which returns std::true_type when we have a nested direct_execution typedef.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that. But the trait not only has no specializations, it is not used anywhere. Do we need it at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea for that was to add a kind of tag type to base_lco and base_lco_with_value to allow direct or non direct action execution based on the actual implementation of the LCO. Implementing that turned out to be a little challenging, so I decided to drop that for now. I am fine with removing this trait.

With this patch, direct actions are now always executed directly on the
receiving side. This means that they might get executed in a non-HPX thread.
@sithhell
Copy link
Member Author

sithhell commented Oct 5, 2016

The review comments have been addressed.

@sithhell sithhell merged commit 94582f5 into master Oct 5, 2016
@sithhell sithhell deleted the direct_actions branch October 5, 2016 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants