pub struct Grid {
pub x: u32,
pub y: u32,
pub z: u32,
}
Expand description
Size of Grid (grid of blocks) in CUDA thread hierarchy
Every input integer and float convert into u32
using ToPrimitive.
If the conversion is impossible, e.g. negative or too large integers, the conversion will panics.
§Examples
- Explicit creation
let grid1d = Grid::x(64);
assert_eq!(grid1d.x, 64);
let grid2d = Grid::xy(64, 128);
assert_eq!(grid2d.x, 64);
assert_eq!(grid2d.y, 128);
let grid3d = Grid::xyz(64, 128, 256);
assert_eq!(grid3d.x, 64);
assert_eq!(grid3d.y, 128);
assert_eq!(grid3d.z, 256);
- From single integer (unsigned and signed)
let grid1d: Grid = 64_usize.into();
assert_eq!(grid1d.x, 64);
let grid1d: Grid = 64_i32.into();
assert_eq!(grid1d.x, 64);
- From tuple
let grid1d: Grid = (64,).into();
assert_eq!(grid1d.x, 64);
let grid2d: Grid = (64, 128).into();
assert_eq!(grid2d.x, 64);
assert_eq!(grid2d.y, 128);
let grid3d: Grid = (64, 128, 256).into();
assert_eq!(grid3d.x, 64);
assert_eq!(grid3d.y, 128);
assert_eq!(grid3d.z, 256);
Fields§
§x: u32
§y: u32
§z: u32
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn x<I: ToPrimitive>(x: I) -> Self
pub fn x<I: ToPrimitive>(x: I) -> Self
Sourcepub fn xy<I1: ToPrimitive, I2: ToPrimitive>(x: I1, y: I2) -> Self
pub fn xy<I1: ToPrimitive, I2: ToPrimitive>(x: I1, y: I2) -> Self
Sourcepub fn xyz<I1: ToPrimitive, I2: ToPrimitive, I3: ToPrimitive>(
x: I1,
y: I2,
z: I3,
) -> Self
pub fn xyz<I1: ToPrimitive, I2: ToPrimitive, I3: ToPrimitive>( x: I1, y: I2, z: I3, ) -> Self
Trait Implementations§
Source§impl<I1: ToPrimitive, I2: ToPrimitive> Into<Grid> for (I1, I2)
impl<I1: ToPrimitive, I2: ToPrimitive> Into<Grid> for (I1, I2)
Source§impl<I1: ToPrimitive, I2: ToPrimitive, I3: ToPrimitive> Into<Grid> for (I1, I2, I3)
impl<I1: ToPrimitive, I2: ToPrimitive, I3: ToPrimitive> Into<Grid> for (I1, I2, I3)
Source§impl PartialOrd for Grid
impl PartialOrd for Grid
impl Copy for Grid
impl StructuralPartialEq for Grid
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnwindSafe for Grid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more