You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add int64_t support to BackendOptions for pointer-sized handles
Summary:
Add `int64_t` as a new variant arm to `OptionValue` in `BackendOptions`
and extend `BackendInitContext::get_runtime_spec<T>` to support it. Lets
backends receive pointer-sized opaque handles (e.g., `cudaStream_t`,
`CUgreenCtx`) as runtime specs at delegate `init()` time.
Motivation: GPU delegates today have no public surface to receive
caller-owned device resources, so they default to allocating their own
streams from the device's primary-context stream pool. This silently
bypasses caller-set CUDA Green Contexts, which is exactly the gap MRS's
MLRT runtime hits when partitioning a Jetson Thor across concurrent
models. With this change, callers that own a GPU context can pass a
green-ctx-bound stream into a Module's load path via `BackendOptions`,
and GPU delegates that opt in (TensorRT, CUDA, future Vulkan / Metal)
honor it instead of allocating their own.
Fully additive:
- New `int64_t` variant arm + matching `set_option(int64_t)` overload.
- `get_option<int64_t>` falls through the existing `bool/int` path.
- `BackendInitContext::get_runtime_spec<int64_t>` extends the existing
`static_assert`.
- No behavior change for existing `bool` / `int` / `const char*` callers.
- No public API removal or signature change.
Documentation:
- The int64_t arm docstring spells out the canonical `uintptr_t`
round-trip pattern so callers don't bikeshed the cast — raw
`reinterpret_cast<int64_t>(ptr)` is implementation-defined per the
standard; via `uintptr_t` it is well-defined on every platform.
- Calls out the literal-overload-resolution gotcha (`42` → `int`,
`42L` → platform-dependent) and recommends `static_cast<int64_t>` at
the call site.
Defensive scaffolding:
- `static_assert(std::variant_size_v<OptionValue> == 4, ...)` in
`set_option_impl` guards against future variant arm additions silently
breaking call sites.
- Companion `static_assert` constrains the impl template `T` to the four
valid variant arms so accidental misuse fails at compile time.
Differential Revision: D103241865
0 commit comments