pub struct Block {
pub x: u32,
pub y: u32,
pub z: u32,
}
Expand description
Size of Block (thread block) 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 block1d = Block::x(64);
assert_eq!(block1d.x, 64);
let block2d = Block::xy(64, 128);
assert_eq!(block2d.x, 64);
assert_eq!(block2d.y, 128);
let block3d = Block::xyz(64, 128, 256);
assert_eq!(block3d.x, 64);
assert_eq!(block3d.y, 128);
assert_eq!(block3d.z, 256);
- From single integer (unsigned and signed)
let block1d: Block = 64_usize.into();
assert_eq!(block1d.x, 64);
let block1d: Block = 64_i32.into();
assert_eq!(block1d.x, 64);
- From tuple
let block1d: Block = (64,).into();
assert_eq!(block1d.x, 64);
let block2d: Block = (64, 128).into();
assert_eq!(block2d.x, 64);
assert_eq!(block2d.y, 128);
let block3d: Block = (64, 128, 256).into();
assert_eq!(block3d.x, 64);
assert_eq!(block3d.y, 128);
assert_eq!(block3d.z, 256);
Fields§
§x: u32
§y: u32
§z: u32
Implementations§
Source§impl Block
impl Block
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<Block> for (I1, I2)
impl<I1: ToPrimitive, I2: ToPrimitive> Into<Block> for (I1, I2)
Source§impl<I1: ToPrimitive, I2: ToPrimitive, I3: ToPrimitive> Into<Block> for (I1, I2, I3)
impl<I1: ToPrimitive, I2: ToPrimitive, I3: ToPrimitive> Into<Block> for (I1, I2, I3)
Source§impl PartialOrd for Block
impl PartialOrd for Block
impl Copy for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
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