Skip to content

[STF] Revamp STF C API: opaque handles for exec_place and data_place#8266

Open
caugonnet wants to merge 11 commits intoNVIDIA:mainfrom
caugonnet:stf_c_rework_places
Open

[STF] Revamp STF C API: opaque handles for exec_place and data_place#8266
caugonnet wants to merge 11 commits intoNVIDIA:mainfrom
caugonnet:stf_c_rework_places

Conversation

@caugonnet
Copy link
Copy Markdown
Contributor

Replace tagged-union types (stf_exec_place, stf_data_place with enums and sub-structs) with opaque pointer handles (stf_exec_place_handle, stf_data_place_handle) backed by heap-allocated C++ objects.

  • Add factory functions: stf_exec_place_host(), stf_data_place_device(), etc.
  • Add lifecycle management: stf_exec_place_destroy(), stf_data_place_destroy()
  • Add property queries: stf_exec_place_is_host(), stf_data_place_to_string(), etc.
  • Add grid construction: stf_exec_place_grid_from_devices(), stf_exec_place_grid_create()
  • Add composite placement: stf_data_place_composite()
  • Update all STF functions to accept opaque handles directly
  • Update test_places.cpp and test_logical_data_with_place.cu for new API

Made-with: Cursor

Description

closes

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Replace tagged-union types (stf_exec_place, stf_data_place with enums
and sub-structs) with opaque pointer handles (stf_exec_place_handle,
stf_data_place_handle) backed by heap-allocated C++ objects.

- Add factory functions: stf_exec_place_host(), stf_data_place_device(), etc.
- Add lifecycle management: stf_exec_place_destroy(), stf_data_place_destroy()
- Add property queries: stf_exec_place_is_host(), stf_data_place_to_string(), etc.
- Add grid construction: stf_exec_place_grid_from_devices(), stf_exec_place_grid_create()
- Add composite placement: stf_data_place_composite()
- Update all STF functions to accept opaque handles directly
- Update test_places.cpp and test_logical_data_with_place.cu for new API

Made-with: Cursor
@caugonnet caugonnet self-assigned this Apr 1, 2026
@caugonnet caugonnet added the stf Sequential Task Flow programming model label Apr 1, 2026
@github-project-automation github-project-automation bot moved this to Todo in CCCL Apr 1, 2026
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Apr 1, 2026

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 Progress in CCCL Apr 1, 2026
@caugonnet
Copy link
Copy Markdown
Contributor Author

/ok to test aa65f5e

@github-actions

This comment has been minimized.

caugonnet and others added 2 commits April 1, 2026 23:23
The C header declared the host_launch API but the implementations
were missing, causing linker errors.

Made-with: Cursor
@caugonnet
Copy link
Copy Markdown
Contributor Author

/ok to test 5042e93

@github-actions

This comment has been minimized.

The static_asserts already verify layout compatibility between dim4
and stf_dim4, making the field-by-field copy unnecessary.

Made-with: Cursor
@caugonnet caugonnet marked this pull request as ready for review April 2, 2026 05:59
@caugonnet caugonnet requested a review from a team as a code owner April 2, 2026 05:59
@cccl-authenticator-app cccl-authenticator-app bot moved this from In Progress to In Review in CCCL Apr 2, 2026
@caugonnet
Copy link
Copy Markdown
Contributor Author

/ok to test ede3885

@github-actions

This comment has been minimized.

stf_task_add_dep_with_dplace(t4, lZ, STF_RW, &d_place_dev0);
stf_data_place_handle d_place_dev0 = stf_data_place_device(0);
stf_task_add_dep_with_dplace(t4, lZ, STF_RW, d_place_dev0);
stf_data_place_destroy(d_place_dev0);
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.

Suggestion: tasks t1-t4 are never destroyed. It would make sense to add stf_task_destroy. This may apply to other tests as well

andralex added 2 commits April 2, 2026 18:06
Resolve stf.cu host_launch conflicts: use host_launch_type alias and
main's host_launch_deps accessors (extent(0), fully qualified types);
keep null-safe stf_host_launch_destroy.

Made-with: Cursor
@andralex
Copy link
Copy Markdown
Contributor

andralex commented Apr 2, 2026

/ok to test 9c720d3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🥳 CI Workflow Results

🟩 Finished in 24m 12s: Pass: 100%/7 | Total: 38m 28s | Max: 24m 11s | Hits: 96%/720

See results here.

- Add to_opaque (Pointee* -> C handle) and from_opaque (handle -> Pointee*)
  with static_cast via void* and static_assert that handle pointees stay incomplete.
- Wrap cross-extern-C heap allocations in stf_try_allocate (try/catch, log, nullptr),
  matching the spirit of cccl.c parallel error containment (null handles here).
- Return data_place/exec_place by reference from deref_*; use const Pointee in from_opaque
  where read-only.
- Use double static_cast for private kernel/host_launch scope types; keep
  reinterpret_cast only for the C partition function pointer.

Build: cccl-c-stf / cccl.c.experimental.stf
Made-with: Cursor
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.

3 participants