Skip to content

[STF] Name green context data places by handle and support VMM mem_create#9706

Open
caugonnet wants to merge 4 commits into
NVIDIA:mainfrom
caugonnet:green-ctx-name-and-vmm-mem-create
Open

[STF] Name green context data places by handle and support VMM mem_create#9706
caugonnet wants to merge 4 commits into
NVIDIA:mainfrom
caugonnet:green-ctx-name-and-vmm-mem-create

Conversation

@caugonnet

Copy link
Copy Markdown
Contributor

Summary

  • green_ctx_data_place_impl::to_string() now includes the green context handle in addition to the device id, so two green contexts on the same device produce distinct names (previously they were indistinguishable).
  • Override green_ctx_data_place_impl::mem_create() to allocate device-pinned physical memory bound to the green context's device, enabling green context data places to back VMM (localized array) allocations.

Tests

  • New co-located unittest in green_context.cuh (green context data_place to_string distinguishes contexts on the same device) asserting the name embeds dev=/ctx= and differs between two green contexts on the same device, while being stable for the same context.
  • Extended cudax/test/places/data_place_vmm.cu with test_green_ctx_vmm_allocation() which exercises the green context mem_create() override end-to-end: create physical memory, reserve/map VA, set device access, run init/check kernels, and verify.

Test plan

  • ninja cudax.test.places.data_place_vmm builds and runs green (CTK 13.0, local GPU).
  • ninja cudax.test.places.unittest_headers.__places.exec.green_context builds and runs green.
  • pre-commit (clang-format, codespell, ...) passes on both files.

Green context data places on the same device were previously
indistinguishable by name and could not back VMM (localized array)
allocations. Include the green context handle in
green_ctx_data_place_impl::to_string() and override mem_create() to
allocate device-pinned physical memory bound to the green context's
device.

Add a co-located unittest verifying to_string() distinguishes different
green contexts on the same device, and extend data_place_vmm.cu to
exercise the green_ctx mem_create() override through the full VMM
map/access/kernel path.
@caugonnet caugonnet requested a review from a team as a code owner July 4, 2026 09:58
@caugonnet caugonnet requested a review from andralex July 4, 2026 09:58
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 4, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 4, 2026
@caugonnet caugonnet changed the title Name green context data places by handle and support VMM mem_create [STF] Name green context data places by handle and support VMM mem_create Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 05578a40-d6a7-4034-b9b7-c6df5da001d3

📥 Commits

Reviewing files that changed from the base of the PR and between f07a610 and 0f1e695.

📒 Files selected for processing (1)
  • cudax/include/cuda/experimental/__places/exec/green_context.cuh
🚧 Files skipped from review as they are similar to previous changes (1)
  • cudax/include/cuda/experimental/__places/exec/green_context.cuh

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added green-context–aware mem_create support for CUDA VMM workflows.
    • Introduced a CUDA VMM test that allocates, reserves/maps virtual memory, sets device access, and validates mapped memory using green contexts.
  • Bug Fixes
    • Improved green-context string representation to include both device ordinal and the specific context identifier, avoiding collisions when multiple contexts share a device.
    • Ensured the same green context produces consistent, repeatable to_string() output.

Walkthrough

Adds green-context-aware pinned memory creation, updates place naming to include the green context handle, and extends VMM coverage with a green-context allocation path.

Changes

Green Context mem_create Support

Layer / File(s) Summary
Context id, naming, and allocation
cudax/include/cuda/experimental/__places/exec/green_context.cuh
Adds a CUgreenCtx ID helper, updates to_string() to include dev= and ctx=, adds mem_create() for pinned device allocation, and removes the earlier in-file ID helper definitions.
to_string unit test
cudax/include/cuda/experimental/__places/exec/green_context.cuh
A unit test verifies that green-context places on the same device differ by context, include dev=0 and ctx=, and reproduce for the same context.
Green context VMM allocation test
cudax/test/places/data_place_vmm.cu
Adds a CTK-gated green-context VMM test that uses mem_create, VMM reserve/map/access, kernel launches, host validation, and cleanup; also adds launch error checks, conditional includes, and wires the test into main().

Related PRs: None specified.
Suggested labels: review_needed_senior_swe, review_depth_deep
Suggested reviewers: None specified.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5916dbe3-1c2e-485a-b50c-dc2a1b9237b5

📥 Commits

Reviewing files that changed from the base of the PR and between 3bf2e5f and 66250f5.

📒 Files selected for processing (2)
  • cudax/include/cuda/experimental/__places/exec/green_context.cuh
  • cudax/test/places/data_place_vmm.cu

Comment thread cudax/test/places/data_place_vmm.cu
Comment thread cudax/test/places/data_place_vmm.cu
@caugonnet

Copy link
Copy Markdown
Contributor Author

/ok to test c331ae8

Add cuda_try(cudaGetLastError()) after each init/check kernel launch so a
non-sticky launch failure cannot silently leave the result flag at zero
and mask a failing EXPECT. Applied consistently across the device,
multi-segment, and green context VMM tests.
@caugonnet

Copy link
Copy Markdown
Contributor Author

/ok to test f07a610

@caugonnet caugonnet self-assigned this Jul 4, 2026
@caugonnet caugonnet added the stf Sequential Task Flow programming model label Jul 4, 2026
@github-actions

This comment has been minimized.

{
return "green_ctx(dev=" + ::std::to_string(view_.devid) + ")";
return "green_ctx(dev=" + ::std::to_string(view_.devid)
+ ", ctx=" + ::std::to_string(reinterpret_cast<::std::uintptr_t>(view_.g_ctx)) + ")";

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.

Wouldn't make sense to return ctx=/*green-context-id*/ that can be queried by cuGreenCtxGetId?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that's better — done in 0f1e695. to_string() now emits ctx=<green-context-id> using the queryable unique id (via the existing get_cuda_context_id helper, i.e. cuCtxFromGreenCtx + cuCtxGetId) instead of the raw handle pointer. This also matches the naming already used by the green-context exec_place. I reused that helper rather than calling cuGreenCtxGetId directly to stay compatible across the CTK >= 12.4 range the header supports; I hoisted the helper overloads above the class so the inline to_string() can see them.

Use the green context's queryable unique id (via cuCtxFromGreenCtx +
cuCtxGetId, exposed by the existing get_cuda_context_id helper) in
green_ctx_data_place_impl::to_string() instead of the raw handle pointer.
This mirrors the exec_place green context naming and gives a stable,
meaningful identifier. The helper overloads are hoisted above the class
so the inline to_string() can see them.
@caugonnet

Copy link
Copy Markdown
Contributor Author

/ok to test 0f1e695

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 06m: Pass: 100%/55 | Total: 1d 01h | Max: 1h 06m | Hits: 16%/163654

See results here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stf Sequential Task Flow programming model

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants