Skip to content

[SYCL] extends previous Global/LocalSize 0 fix - #23065

Open
cperkinsintel wants to merge 1 commit into
intel:syclfrom
cperkinsintel:cperkins-churn-over-localsize
Open

[SYCL] extends previous Global/LocalSize 0 fix#23065
cperkinsintel wants to merge 1 commit into
intel:syclfrom
cperkinsintel:cperkins-churn-over-localsize

Conversation

@cperkinsintel

Copy link
Copy Markdown
Contributor

The SYCL spec allows 0 size global and local ranges. The kernels are not run, but any dependencies are left in place.

This was fixed in #22957 but the fix allows a nullptr to sneak through. By itself not a problem, but when the tests are run with address sanitization, we get failures. This fixes that. Existing tests cover all branches. No need for additional testing.

@cperkinsintel
cperkinsintel marked this pull request as ready for review September 1, 2026 14:51
@cperkinsintel
cperkinsintel requested a review from a team as a code owner September 1, 2026 14:51
@uditagarwal97
uditagarwal97 requested a balanced review from Copilot September 1, 2026 15:08

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Extends the SYCL “zero global/local range” handling to avoid passing nullptr-like launch parameters into downstream layers (notably DeviceASAN), while preserving SYCL 2020 semantics that kernels with empty ranges are not executed.

Changes:

  • Refines adjustNDRangePerKernel early-return logic to distinguish “global/local explicitly set” vs “both zero”.
  • Ensures a non-zero local work-group size is available for no-op launches where both global and local are zero, preventing sanitizer failures.

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

Comment on lines +2298 to +2303
if (NDR.GlobalSize[0] != 0)
return; // GlobalSize is set - no need to adjust
if (NDR.LocalSize[0] != 0)
return; // User set LocalSize but GlobalSize is zero (e.g. nd_range with
// zero global, non-zero local). Per SYCL 2020 the kernel is not
// executed; leave the range as-is.
Comment on lines +2304 to +2307
// Zero global and zero local: either parallel_for_work_group (NumWorkGroups
// is set) or plain parallel_for with an empty range. Fill in WGSize so that
// downstream layers (in particular DeviceASAN's preLaunchKernel) always see
// a non-zero local work size even when the launch is a no-op.

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.

🔵 Needs a closer look

Multi-dimensional ranges with zeroes outside dimension 0 remain unsafe.

Review details

Suppressed comments (1)

sycl/source/detail/scheduler/commands.cpp:2300

  • These checks only inspect dimension 0, so a 2D/3D empty range whose zero is in another dimension is not fixed. For example, parallel_for(range<2>{16, 0}, ...) returns here with a null local size, while nd_range<2>{{16, 0}, {4, 0}} passes a zero local component; DeviceASAN subsequently divides by every local component. Check all active dimensions so every zero-sized range gets a non-zero downstream local size.
  if (NDR.GlobalSize[0] != 0)
    return; // GlobalSize is set - no need to adjust
  if (NDR.LocalSize[0] != 0)
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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.

2 participants