Skip to content

cuda-core: distinguish CUDA devices and contexts in the shared host API #1504

Closed

Description

@elibol

Root Device and simt::CudaContext both bundle a CUDA device handle with a context handle. The shared host API needs distinct device and context identities while preserving convenient initialization and correct resource ownership.

Requirements

Acceptance

Document the type and ownership model and provide migration examples for both programming models. Validate context identity and lifetimes across owned, borrowed, and foreign resources. Select the final type names and convenience-wrapper shape as part of the API design.

Source: root Device, SIMT CudaContext.

Public namespace design is tracked separately in #1505.

Implementation and closure (2026-10-30)

Implemented by #1603, which now explicitly closes this issue when merged into main: Device is the physical GPU; Context owns or borrows an actual CUDA context. Device::primary_context() provides the convenience constructor, and Context::device() exposes the physical identity. Handles retain their actual context; compatibility compares context handles, not ordinals. Owned, raw-borrowed and foreign-owner lifetimes and migration are documented in cuda-core/README.md and the runtime API. Shared-allocation/borrowed-handle tests cover context mismatch, thread binding and nonblocking completion retention. The async consumer migration continues in #1604.

The explicit thread-local global-context state/re-entry design is a separate unfinished follow-up in #1403; closing the device/context API distinction does not close that issue.

Activity

  1. added a commit that references this issue on Oct 30, 2026
    6a6372e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions