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
{{ message }}
Repository navigation
Add #[derive(DeviceCopy)] for CUDA transfer-safe data types #192
cuda_core::DeviceCopy is the safety marker used for values that may be copied to and from device memory. Today users must write unsafe impl DeviceCopy by hand for their own plain-data structs, even when every field already implements DeviceCopy.
That is both noisy and easy to get wrong: a manual impl can accidentally skip the field-by-field safety check that the marker trait relies on.
Why this matters
DeviceCopy is an unsafe marker trait, so the ergonomic path should make the safe case easy while still enforcing the same rule: a composite type can be DeviceCopy only if every stored field is also DeviceCopy. A derive macro can encode that rule mechanically and reduce hand-written unsafe impls.
Users should be able to write #[derive(DeviceCopy)] for transfer-safe structs, enums, and unions. The derive should be available through use cuda_core::DeviceCopy;, matching the usual trait-plus-derive ergonomics pattern, and invalid field types should fail at compile time.
Acceptance criteria
cuda-macros provides a DeviceCopy derive macro.
cuda-core re-exports the derive next to the DeviceCopy trait.
The generated impl requires all field types to implement DeviceCopy.
Generic type parameters receive the required DeviceCopy bounds.
#[derive(DeviceCopy)] works for named structs, tuple structs, enums, unions, and generic structs whose fields are DeviceCopy.
The derive is available through use cuda_core::DeviceCopy;, matching the common trait-plus-derive ergonomics pattern.
Compile-pass coverage exercises representative struct, enum, union, and generic forms.
Compile-fail coverage proves that a host reference field is rejected because it is not DeviceCopy.
Activity
docs: link TileGym cutile-rs kernels from README (NVIDIA#192)