Map2D

Struct Map2D 

Source
pub struct Map2D {
    pub x_size: usize,
}
Expand description

This mapping strategy is useful when we want to reshape a 1D array into a 2D array and then distribute one element to a thread one by one until consuming all. It creates a new non-continuous partition for each thread.

  • IndexType is (usize, usize)

Example: Example:

  • array: [T; 20]
  • x_size = 5 => y_size = 4
  • dim: x=2, y=2, z=1
0   1   2   3   4   5
┌───┬───┬───┬───┬───┐
│0,0│1,0│0,0│1,0│0,0│
├───┼───┼───┼───┼───┤
│0,1│1,1│0,1│1,1│0,1│
├───┼───┼───┼───┼───┤
│0,0│1,0│0,0│1,0│0,0│
├───┼───┼───┼───┼───┤
│0,1│1,1│0,1│1,1│0,1│
└───┴───┴───┴───┴───┘

In this case,

  • thread(1,0) and (1,1) should only have access to a shape of 2*2 = 4 elements.
  • thread (0,0) and (0,1) have access to a shape of 3*2 = 6 elements.

Fields§

§x_size: usize

Implementations§

Source§

impl Map2D

Source

pub fn new(x_size: usize) -> Self

Trait Implementations§

Source§

impl Clone for Map2D

Source§

fn clone(&self) -> Map2D

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

type IndexType = (usize, usize)

Source§

type GlobalIndexType = usize

Source§

fn precondition(&self) -> bool

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.
Source§

impl Copy for Map2D

Auto Trait Implementations§

§

impl Freeze for Map2D

§

impl RefUnwindSafe for Map2D

§

impl Send for Map2D

§

impl Sync for Map2D

§

impl Unpin for Map2D

§

impl UnwindSafe for Map2D

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HostToDev<T> for T

Source§

fn convert(self) -> T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.