pub unsafe trait PartitioningStrategy {
type View<'a, T: 'a>;
type ViewMut<'a, T: 'a>;
// Required methods
fn index() -> usize;
unsafe fn get<'a, T>(
ptr: NonNull<T>,
len: usize,
) -> Option<Self::View<'a, T>>;
unsafe fn get_mut<'a, T>(
ptr: NonNull<T>,
len: usize,
) -> Option<Self::ViewMut<'a, T>>;
fn check_launch(
len: usize,
grid: [u32; 3],
block: [u32; 3],
) -> Result<(), LaunchError>;
}gpu_offload #131513)Expand description
Defines how execution units access memory regions.
§Safety
Implementations must guarantee that generated views are disjoint.
Implementations must also implement check_launch correctly since it is soundness-critical.
Required Associated Types§
Required Methods§
Sourcefn index() -> usize
🔬This is a nightly-only experimental API. (gpu_offload #131513)
fn index() -> usize
gpu_offload #131513)Returns the execution index of the current unit.
Sourceunsafe fn get<'a, T>(ptr: NonNull<T>, len: usize) -> Option<Self::View<'a, T>>
🔬This is a nightly-only experimental API. (gpu_offload #131513)
unsafe fn get<'a, T>(ptr: NonNull<T>, len: usize) -> Option<Self::View<'a, T>>
gpu_offload #131513)Returns a read-only view of the region for the current execution context.
§Safety
ptr must point to len valid, initialized elements of type T.
The memory must stay valid for lifetime 'a.
Sourceunsafe fn get_mut<'a, T>(
ptr: NonNull<T>,
len: usize,
) -> Option<Self::ViewMut<'a, T>>
🔬This is a nightly-only experimental API. (gpu_offload #131513)
unsafe fn get_mut<'a, T>( ptr: NonNull<T>, len: usize, ) -> Option<Self::ViewMut<'a, T>>
gpu_offload #131513)Returns a mutable view of the region for the current execution context.
§Safety
ptr must point to len valid, initialized elements of type T.
The memory must stay valid for lifetime 'a.
The returned view must be disjoint from all other active views.
Sourcefn check_launch(
len: usize,
grid: [u32; 3],
block: [u32; 3],
) -> Result<(), LaunchError>
🔬This is a nightly-only experimental API. (gpu_offload #131513)
fn check_launch( len: usize, grid: [u32; 3], block: [u32; 3], ) -> Result<(), LaunchError>
gpu_offload #131513)Checks that a kernel using this strategy can be launched with len
elements on a grid by block launch configuration.
This is called automatically before the kernel is launched.
§Soundness
This check is soundness-critical. It may only return Ok unconditionally
if and only if a launch is valid for arbitrary len, grid and block values.
If there is any configuration for which this strategy would produce incorrect
results or cause undefined behavior, it must return a LaunchError instead.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".