Skip to content

[UR][CUDA][HIP] Add UR_{CUDA,HIP}_STACK_SIZE env var for per-thread s… - #22763

Open
zjin-lcf wants to merge 4 commits into
intel:syclfrom
zjin-lcf:ur-device-stack-size
Open

zjin-lcf wants to merge 4 commits into
intel:syclfrom
zjin-lcf:ur-device-stack-size

Conversation

@zjin-lcf

@zjin-lcf zjin-lcf commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Add support for configuring the per-thread device stack size limit at device initialization via the UR_CUDA_STACK_SIZE and UR_HIP_STACK_SIZE environment variables. These map to cuCtxSetLimit(CU_LIMIT_STACK_SIZE) and hipDeviceSetLimit(hipLimitStackSize) respectively (the driver-level equivalent of cudaDeviceSetLimit(cudaLimitStackSize)), which is useful for kernels with deep recursion or large per-thread private data that would otherwise overflow the small default stack.

An invalid value (non-positive or non-numeric) is rejected with a diagnostic at device initialization. Documentation and an E2E test covering the invalid/valid cases are included.

Addresses #12271

@zjin-lcf
zjin-lcf requested review from a team as code owners July 24, 2026 20:31
@zjin-lcf
zjin-lcf requested a review from pbalcer July 24, 2026 20:31
@bratpiorka

Copy link
Copy Markdown
Contributor

@zjin-lcf problems with SuccessFanSpeed test are resolved in latest main, see: #22837

@ldorau

ldorau commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

@zjin-lcf problems with SuccessFanSpeed test are resolved in latest main, see: #22837

It has been fixed by #22733

@ldorau

ldorau commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@zjin-lcf please rebase on the current sycl branch

Comment thread unified-runtime/source/adapters/cuda/device.hpp Outdated
Comment thread unified-runtime/source/adapters/hip/device.hpp Outdated
zjin-lcf and others added 3 commits September 18, 2026 06:25
…tack size

Add support for configuring the per-thread device stack size limit at
device initialization via the UR_CUDA_STACK_SIZE and UR_HIP_STACK_SIZE
environment variables. These map to cuCtxSetLimit(CU_LIMIT_STACK_SIZE)
and hipDeviceSetLimit(hipLimitStackSize) respectively (the driver-level
equivalent of cudaDeviceSetLimit(cudaLimitStackSize)), which is useful
for kernels with deep recursion or large per-thread private data that
would otherwise overflow the small default stack.

An invalid value (non-positive or non-numeric) is rejected with a
diagnostic at device initialization. Documentation and an E2E test
covering the invalid/valid cases are included.

Addresses intel#12271

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The stack size env vars only need to call cuCtxSetLimit/hipDeviceSetLimit
at device init; there is no UR device info or enqueue check that would
consume a stored value.

Co-authored-by: Cursor <cursoragent@cursor.com>
@zjin-lcf
zjin-lcf force-pushed the ur-device-stack-size branch from 331c7f8 to c159f8f Compare September 18, 2026 14:06
@zjin-lcf

Copy link
Copy Markdown
Contributor Author

Rebased onto current sycl and pushed. Also dropped the unused MaxChosenStackSize / getMaxChosenStackSize() storage on CUDA and HIP.

@bratpiorka bratpiorka 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.

CUDA / HIP LGTM

Comment thread unified-runtime/source/adapters/cuda/device.hpp Outdated
Comment thread unified-runtime/source/adapters/hip/device.hpp Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
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