Skip to content

[UR] Fix nd_range with zero global_size on native CPU - #23032

Open
dyniols wants to merge 3 commits into
intel:syclfrom
dyniols:fix_nd_range_with_zero_global_size_native_cpu
Open

[UR] Fix nd_range with zero global_size on native CPU#23032
dyniols wants to merge 3 commits into
intel:syclfrom
dyniols:fix_nd_range_with_zero_global_size_native_cpu

Conversation

@dyniols

@dyniols dyniols commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This PR fixes CMPLRLLVM-77780 and it's related to #22893

@dyniols
dyniols requested review from a team as code owners August 25, 2026 17:19
@dyniols
dyniols requested review from uditagarwal97 and a balanced review from Copilot August 25, 2026 17:19
@dyniols dyniols changed the title [UR] Fix nd_range with zero global_size on native_cpu [UR] Fix nd_range with zero global_size on native CPU Aug 25, 2026

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.

Pull request overview

Adds native CPU support for zero-sized kernel launches while preserving event dependencies and profiling.

Changes:

  • Returns a no-op event for zero-sized launches.
  • Relocates the timing-event helper for reuse.
  • Enables the zero-range SYCL end-to-end test on native CPU.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
unified-runtime/source/adapters/native_cpu/enqueue.cpp Handles zero-sized native CPU launches.
sycl/test-e2e/Basic/parallel_for_zero_range.cpp Removes the native CPU expected failure.
Suppressed comments (1)

unified-runtime/source/adapters/native_cpu/enqueue.cpp:164

  • This early return bypasses the only _localArgInfo.clear() in the launch path. urEnqueueKernelLaunchWithArgsExp has already appended each local argument before calling here, so every empty launch leaves stale entries on the kernel; later launches duplicate those entries and make updateMemPool() allocate progressively more local memory. Clear this per-launch state before returning the no-op event.
    return withTimingEvent(UR_COMMAND_KERNEL_LAUNCH, hQueue,

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

Comment thread unified-runtime/source/adapters/native_cpu/enqueue.cpp Outdated
@dyniols

dyniols commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

https://github.com/intel/llvm/actions/runs/32877207965/job/97904975140?pr=23032

Looks like test-e2e/QueueFlushing/queue_flushing.cpp is now passing with this change for native_cpu.
There is range<1>{} which is default-constructed, and yields range<1>{0} and previously test was failing because UR_RESULT_ERROR_UNSUPPORTED_FEATURE .

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +163 to +167
if (pGlobalWorkSize[0] == 0 || (workDim > 1 && pGlobalWorkSize[1] == 0) ||
(workDim > 2 && pGlobalWorkSize[2] == 0)) {
return withTimingEvent(UR_COMMAND_KERNEL_LAUNCH, hQueue,
numEventsInWaitList, phEventWaitList, phEvent,
[]() { return UR_RESULT_SUCCESS; });
Comment thread unified-runtime/source/adapters/native_cpu/enqueue.cpp
@bratpiorka

Copy link
Copy Markdown
Contributor

@dyniols would you be applying the Copilot comments?

@dyniols

dyniols commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@dyniols would you be applying the Copilot comments?

I will take a look at them. Not sure about this one #23032 (comment)

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

unified-runtime/source/adapters/native_cpu/enqueue.cpp:164

  • This adapter path conflicts with the UR contract and is bypassed when parameter validation is enabled: scripts/core/exp-enqueue-kernel-launch-with-args.yml:153-156 defines any zero global dimension as UR_RESULT_ERROR_INVALID_WORK_DIMENSION, and source/loader/layers/validation/ur_valddi.cpp:6107-6109 enforces it before dispatch. The reported SYCL case will therefore still fail under UR validation and behavior will depend on whether that layer is enabled. Please update the UR specification/generated validation together with this adapter change, or handle the zero range above the UR API boundary.
  if (pGlobalWorkSize[0] == 0 || (workDim > 1 && pGlobalWorkSize[1] == 0) ||
      (workDim > 2 && pGlobalWorkSize[2] == 0)) {

Comment on lines +166 to +168
return withTimingEvent(UR_COMMAND_KERNEL_LAUNCH, hQueue,
numEventsInWaitList, phEventWaitList, phEvent,
[]() { return UR_RESULT_SUCCESS; });
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