Skip to content

COPY OF #22641 [SYCL][UR][OpenCL] Fix profiling tag ordering on OpenCL GPU - #23153

Open
crystarm wants to merge 3 commits into
intel:syclfrom
crystarm:profiling-tag-opencl-timestamp-recording-v2
Open

crystarm wants to merge 3 commits into
intel:syclfrom
crystarm:profiling-tag-opencl-timestamp-recording-v2

Conversation

@crystarm

@crystarm crystarm commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Supersedes #22641.
Resolves #22229.

This PR reapplies the two previously reviewed OpenCL profiling tag changes on top of the current sycl branch and adds a separate fix for profiling tag fallback timestamps.

#22810 changed profiling tag timestamp handling so that MSubmitTime is no longer initialized for profiling tag events. The previous Native CPU fallback fix relied on that field, causing command_submit to remain zero when CI tested the change together with the current sycl branch.

The new fix follows the timestamp model introduced by #22810: profiling tag events remain marked as tags and use their device-recorded completion timestamp for command_submit, command_start, and command_end.

Validation:

  • ExtensionsTests: 259/259 passed.
  • Native CPU E2E: passed 100/100 consecutive local runs.

The Native CPU E2E was built locally with the existing diagnostic libspirv stub and -O0; CI remains the authoritative full-toolchain validation.

For the background on why this PR replaces #22641, see #22641 (comment).

@crystarm

Copy link
Copy Markdown
Contributor Author

@KornevNikita
Could you please run the native CPU E2E workflow?

@crystarm
crystarm force-pushed the profiling-tag-opencl-timestamp-recording-v2 branch from e514e9c to cdbb9d7 Compare September 13, 2026 09:44
@bratpiorka
bratpiorka requested a lite review from Copilot September 15, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved event contract, argument-validation, and regression-test issues remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes OpenCL GPU profiling-tag ordering and fallback timestamp handling.

Changes:

  • Adds OpenCL timestamp recording via profiled buffer fills.
  • Updates SYCL profiling and scheduler fallback behavior.
  • Expands unit and end-to-end test coverage.
File summaries
File Summary
unified-runtime/source/adapters/opencl/event.cpp Implements timestamp recording; event-type and argument-validation issues remain.
unified-runtime/source/adapters/opencl/context.hpp Manages the internal timestamp buffer.
sycl/unittests/Extensions/ProfilingTag.cpp Adds profiling timestamp and fallback coverage.
sycl/test-e2e/ProfilingTag/profiling_queue.cpp Exercises OpenCL profiling queues.
sycl/test-e2e/ProfilingTag/in_order_profiling_queue.cpp Exercises OpenCL in-order profiling queues.
sycl/test-e2e/ProfilingTag/common.hpp Validates timestamp ordering; the original submit-time assertion should be retained.
sycl/source/event.cpp Waits before profiling-tag submit-time queries.
sycl/source/detail/scheduler/commands.cpp Adds timestamp-recording fallback behavior.
sycl/source/detail/event_impl.cpp Uses completion timestamps for profiling tags.
sycl/include/sycl/ext/oneapi/experimental/profiling_tag.hpp Routes supported fallback queues through the scheduler.
Review details

Suppressed comments (2)

sycl/test-e2e/ProfilingTag/common.hpp:66

  • The test no longer checks that StartTagSubmit is non-zero: this line replaced the original assertion instead of adding the new EndTagEnd check. A regression that returns zero for the first tag's submit timestamp would now pass the non-zero checks, so keep both assertions.
  CHECK(Failures, EndTagEnd != 0)

unified-runtime/source/adapters/opencl/event.cpp:314

  • The UR contract for urEnqueueTimestampRecordingExp requires a non-null phEvent and specifies UR_RESULT_ERROR_INVALID_NULL_POINTER otherwise (unified-runtime/include/unified-runtime/ur_api.h:11205). Because ifUrEvent treats this pointer as optional, this implementation returns success without an event for that invalid call; validate phEvent before querying the queue or enqueueing the fill.
    const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) {
  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

cl_mem Buffer = nullptr;
UR_RETURN_ON_FAILURE(Queue->Context->getTimestampRecordingBuffer(&Buffer));

std::vector<cl_event> CLWaitEvents(numEventsInWaitList);
Comment on lines +348 to +351
CL_RETURN_ON_FAILURE(clEnqueueFillBuffer(
Queue->CLQueue, Buffer, &Pattern, sizeof(Pattern), /*offset=*/0,
/*size=*/sizeof(Pattern), numEventsInWaitList, CLWaitList,
ifUrEvent(phEvent, Event)));
@KornevNikita

Copy link
Copy Markdown
Contributor

@crystarm looks like the pre-commit finally passes

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.

test-e2e/ProfilingTag/in_order_profiling_queue.cpp fails on opencl:gpu

3 participants