ScopeUniqueMap

Trait ScopeUniqueMap 

Source
pub unsafe trait ScopeUniqueMap<CS: ChunkScope>: Clone {
    type IndexType: Copy + 'static;
    type GlobalIndexType: AsPrimitive<usize>;

    // Required method
    fn map(
        &self,
        idx: Self::IndexType,
        thread_ids: [u32; 6],
    ) -> (bool, Self::GlobalIndexType);

    // Provided method
    fn precondition(&self) -> bool { ... }
}
Expand description

Thread unique mapping trait

This trait guarantees that each thread produces a unique index mapping, so no two distinct threads map to the same global index.

§Type Parameters

  • CS: The memory space: GlobalMemScope or SharedMemScope

§Safety

Implementors must ensure:

forall |idx1, idx2, thread_ids1, thread_ids2|
    thread_ids1 != thread_ids2 ==>
        map(idx1, thread_ids1) !=  map(idx2, thread_ids2)

Required Associated Types§

Required Methods§

Source

fn map( &self, idx: Self::IndexType, thread_ids: [u32; 6], ) -> (bool, Self::GlobalIndexType)

Returns the extra precondition of indexing operation and the global index. Without providing extra precondition, index will always check the OOB error with global idx.

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<CS1: ChunkScope, CS2, Map1, Map2> ScopeUniqueMap<ChainedScope<CS1, CS2>> for ChainedMap<CS1, CS2, Map1, Map2>
where CS2: ChunkScope<FromScope = CS1::ToScope> + ChunkScope, Map1: ScopeUniqueMap<CS1>, Map2: ScopeUniqueMap<CS2>, Map2::GlobalIndexType: AsPrimitive<Map1::IndexType>,

Chain two mapping strategies. For example, block_size = (32 * 4, 1, 1), MapLinear(64) + MapLinear(2) = MapLinear idx -> map2(idx) -> map1(map2(idx)) 0 -> 0 -> 0 1 -> 1 -> 1 2 -> 64 -> 4 * 64 3 -> 65 -> 4 * 64 + 1

Source§

impl<CS: ChunkScope> ScopeUniqueMap<CS> for Map2D

Source§

impl<CS: ChunkScope> ScopeUniqueMap<CS> for MapContinuousLinear

Source§

impl<CS: ChunkScope> ScopeUniqueMap<CS> for MapLinearWithDim<1>

§Safety

It is safe to use this mapping as long as the thread dimensions are properly configured.

Source§

impl<CS: ChunkScope> ScopeUniqueMap<CS> for MapLinearWithDim<2>

Source§

impl<CS: ChunkScope> ScopeUniqueMap<CS> for MapLinearWithDim<3>