Skip to content

[NFCI][SYCL] Refactor event_impl creation #18907

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 3 commits into from
Jun 13, 2025

Conversation

aelovikov-intel
Copy link
Contributor

  • Inherit from std::enable_shared_for_this as part of a bigger scope ongoing refactoring
  • Unlike other *_impl classes, event_impl ctors before this change weren't immediately obvious for an unfamiliar reader. Because of that, instead of a single variaded event_impl::create(Ts&&...) I opted to have multiple named versions of it, each delegating to its own ctor. Also, some ctor code was reshuffled between different overloads.

* Inherit from `std::enable_shared_for_this` as part of a bigger scope
  ongoing refactoring
* Unlike other `*_impl` classes, `event_impl` ctors before this change
  weren't immediately obvious for an unfamiliar reader. Because of that,
  instead of a single variaded `event_impl::create(Ts&&...)` I opted to
  have multiple named version of it, each delegating to its own ctor.
  Also, some ctor code was reshuffled between different overloads.
break;
}
case HES_NotComplete: {
MIsProfilingEnabled = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like MIsHostEvent wasn't set for this scenario before, but this is weird to me. If anyone has any idea, I'd like to hear it.

Copy link
Contributor

@cperkinsintel cperkinsintel Jun 12, 2025

Choose a reason for hiding this comment

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

I'm not sure if it is relevant to this, but maybe @steffenlarsen will help me remember the details.

The default event() gets created in lots of places in our codebase but then is promptly thrown away. Because it is often occurring on the critical path, its default construction needs to be super fast and cannot waste time. One of the issues we dealt with was the context, deferring its assignment unless and until needed. But that introduced a complication with the "is this a host event" question, which before our change, simply checked the context. We resolved it, but there was a bit of legerdemain where we had to avoid prematurely setting the MIsHostEvent flag. I'm probably misremembering. Also, I don't think we touched this routine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sadly I don't remember the details either, but it smells like events are due for some refactoring in general. The idea of "host" seems very overloaded.

: MQueue{Queue.weak_from_this()},
MIsProfilingEnabled{Queue.MIsProfilingEnabled} {
this->setContextImpl(Queue.getContextImplPtr());
MState.store(HES_Complete);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how it was before my changes, but I have no idea why. If anyone has any idea, I'd like to hear it.

Copy link
Contributor

@konradkusiak97 konradkusiak97 left a comment

Choose a reason for hiding this comment

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

Graph changes LGTM

@aelovikov-intel
Copy link
Contributor Author

@slawekptak , @sergey-semenov , ping.

}

static std::shared_ptr<event_impl>
create_from_underlying(ur_event_handle_t Event, const context &SyclContext) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "create_from_handle" would be more aligned with the current naming? We have getHandleRef() functions returning the UR handles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@aelovikov-intel aelovikov-intel merged commit a4c5ace into intel:sycl Jun 13, 2025
43 of 49 checks passed
@aelovikov-intel aelovikov-intel deleted the event_impl branch June 13, 2025 19:08
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 16, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 16, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 16, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 16, 2025
aelovikov-intel added a commit that referenced this pull request Jun 17, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 17, 2025
aelovikov-intel added a commit that referenced this pull request Jun 17, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 24, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 24, 2025
aelovikov-intel added a commit that referenced this pull request Jun 25, 2025
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.

5 participants