Skip to main content

PartitioningStrategy

Trait PartitioningStrategy 

Source
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>;
}
🔬This is a nightly-only experimental API. (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§

Source

type View<'a, T: 'a>

🔬This is a nightly-only experimental API. (gpu_offload #131513)

Read-only view type for the partitioned memory region.

Source

type ViewMut<'a, T: 'a>

🔬This is a nightly-only experimental API. (gpu_offload #131513)

Mutable view type for the partitioned memory region.

Required Methods§

Source

fn index() -> usize

🔬This is a nightly-only experimental API. (gpu_offload #131513)

Returns the execution index of the current unit.

Source

unsafe fn get<'a, T>(ptr: NonNull<T>, len: usize) -> Option<Self::View<'a, T>>

🔬This is a nightly-only experimental API. (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.

Source

unsafe 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)

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.

Source

fn check_launch( len: usize, grid: [u32; 3], block: [u32; 3], ) -> Result<(), LaunchError>

🔬This is a nightly-only experimental API. (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".

Implementors§