Skip to content

[UR][L0] Correctly wait on barrier on urEnqueueEventsWaitWithBarrier #962

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 2 commits into from
Dec 8, 2023

Conversation

jandres742
Copy link

@jandres742 jandres742 commented Oct 13, 2023

When event list is null, a barrier is still needed for all previous commands if profiling is enabled, so fix it.

LLVM testing: intel/llvm#11541

@jandres742 jandres742 force-pushed the fixwaitbarrierwithevent branch 5 times, most recently from b0e0a75 to 7368013 Compare November 3, 2023 01:55
@jandres742
Copy link
Author

@smaslov-intel : please take a look.

@@ -964,8 +966,7 @@ ur_result_t CleanupCompletedEvent(ur_event_handle_t Event, bool QueueLocked,
ur_result_t EventCreate(ur_context_handle_t Context, ur_queue_handle_t Queue,
bool HostVisible, ur_event_handle_t *RetEvent) {

bool ProfilingEnabled =
!Queue || (Queue->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0;
bool ProfilingEnabled = !Queue || Queue->isProfilingEnabled();
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you did not change this, but it looks weird that when Queue == null then we create an event from a profiled pool

Copy link
Author

Choose a reason for hiding this comment

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

@smaslov-intel : I know, I saw that and it looks weird. Maybe that was added as a WA, or a better logic could be used. i'm planning on addressing that in another patch.

@@ -168,7 +168,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
// TODO: this and other special handling of in-order queues to be
// updated when/if Level Zero adds native support for in-order queues.
//
if (Queue->isInOrderQueue() && InOrderBarrierBySignal) {
if (Queue->isInOrderQueue() && InOrderBarrierBySignal &&
!Queue->isProfilingEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me how profiling affects synchronization.

Copy link
Author

Choose a reason for hiding this comment

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

@smaslov-intel : please see here

https://spec.oneapi.io/level-zero/latest/core/api.html?highlight=appendsignalevent#_CPPv430zeCommandListAppendSignalEvent24ze_command_list_handle_t17ze_event_handle_t

zeCommandListAppendSignalEvent

The duration of an event created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined

Therefore,, when profiling is used, we cannot just used signalEvent if EventWaitList.Lenght == 0. We need to fallback directly to barrier to have correct timestamps.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, but please add source code comment explaining this.

Copy link
Author

Choose a reason for hiding this comment

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

thanks @smaslov-intel. I have added comment.

@jandres742 jandres742 force-pushed the fixwaitbarrierwithevent branch 3 times, most recently from ba1a51d to 7fd9daf Compare November 12, 2023 00:43
Jaime Arteaga added 2 commits November 11, 2023 16:53
When event list is null, a barrier is still needed for all
previous commands if profiling is enabled, so fix it.

Signed-off-by: Jaime Arteaga <[email protected]>
Signed-off-by: Jaime Arteaga <[email protected]>
@jandres742
Copy link
Author

@kbenzie : please merge when possible

@kbenzie kbenzie added the ready to merge Added to PR's which are ready to merge label Nov 13, 2023
@kbenzie kbenzie added the v0.8.x Include in the v0.8.x release label Nov 28, 2023
@fabiomestre fabiomestre changed the base branch from adapters to main December 5, 2023 16:53
@fabiomestre
Copy link
Contributor

I have updated the target branch of this PR from the adapters branch to the main branch.
Development in UR is moving back to main. The adapters branch will soon be deleted.

@kbenzie kbenzie mentioned this pull request Dec 6, 2023
13 tasks
@kbenzie kbenzie merged commit e69ed21 into oneapi-src:main Dec 8, 2023
kbenzie added a commit to kbenzie/unified-runtime that referenced this pull request Dec 8, 2023
…vent

[UR][L0] Correctly wait on barrier on urEnqueueEventsWaitWithBarrier
kbenzie added a commit to kbenzie/unified-runtime that referenced this pull request Dec 15, 2023
…vent

[UR][L0] Correctly wait on barrier on urEnqueueEventsWaitWithBarrier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Added to PR's which are ready to merge v0.8.x Include in the v0.8.x release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants