Skip to content

[SYCL] lazily set context on default constructed events #6296

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

Merged
merged 15 commits into from
Jun 28, 2022

Conversation

cperkinsintel
Copy link
Contributor

@cperkinsintel cperkinsintel commented Jun 10, 2022

According to the spec, sycl::event() constructed via empty constructor should be initialized with the default context. But simply doing so in that constructor is too expensive - many of those events are created temporarily, never needing the context. So instead, we are adding the context lazily, when it might be needed. The performance impact of both approaches has been measured, the simple direct setting of the context on all empty constructed events is deleterious whereas the method here, setting it lazily, has no appreciable degradation on performance.

There are a couple places in the existing codebase where the lack of a context was used as a proxy indicating event state. This has had to change. Also, the setContextImpl routine was not only setting the context, but setting the atomic state to incomplete. This is no longer desirable. I've moved the setting of that state to its own call on the impl, and the appropriate calls now invoke it.

…e atomic event state. This is undesirable now that we lazily set the context to be the default one (if none is provided). It is also undesirable from a one-function-does-one-thing standpoint. I am introducing a new routine on the impl to change that event state and am adding explicit calls to it where before we were only calling event->setContex I don't like leaking impl state in this way, but it's clean. Right now all the places that are calling setContextImpl are intentionally setting up the event_impl, so having them explicitly set the state is in line with the surrounding activities. Better to have this intention explicit and known rather than hidden and ill understood.

Signed-off-by: Chris Perkins <[email protected]>
@cperkinsintel cperkinsintel marked this pull request as ready for review June 11, 2022 02:32
@cperkinsintel cperkinsintel requested a review from a team as a code owner June 11, 2022 02:32
@cperkinsintel
Copy link
Contributor Author

ping to reviewers.

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

LGTM!

@pvchupin pvchupin merged commit ed92c4c into intel:sycl Jun 28, 2022
pvchupin pushed a commit that referenced this pull request Jul 6, 2022
)

making host events more explicit. simplifies the logic, makes checking for host (or not) simpler, and reduces potential contention. This is a follow up to #6296

Signed-off-by: Chris Perkins [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants