pub struct Dim3 {
pub x: u32,
pub y: u32,
pub z: u32,
}Expand description
3-dimensional size specification for grids and blocks.
Used to specify the number of thread blocks in a grid and the number of threads in a block. Dimensions default to 1 when not explicitly provided.
§Examples
use oxicuda_launch::Dim3;
// 1D: 256 threads
let block = Dim3::x(256);
assert_eq!(block.x, 256);
assert_eq!(block.y, 1);
assert_eq!(block.z, 1);
// 2D: 16x16 threads
let block = Dim3::xy(16, 16);
assert_eq!(block.total(), 256);
// 3D
let block = Dim3::new(8, 8, 4);
assert_eq!(block.total(), 256);
// From conversions
let block: Dim3 = 256u32.into();
assert_eq!(block, Dim3::x(256));
let block: Dim3 = (16u32, 16u32).into();
assert_eq!(block, Dim3::xy(16, 16));
let block: Dim3 = (8u32, 8u32, 4u32).into();
assert_eq!(block, Dim3::new(8, 8, 4));Fields§
§x: u32X dimension.
y: u32Y dimension (default 1).
z: u32Z dimension (default 1).
Implementations§
Source§impl Dim3
impl Dim3
Sourcepub fn new(x: u32, y: u32, z: u32) -> Self
pub fn new(x: u32, y: u32, z: u32) -> Self
Creates a new Dim3 with explicit values for all three dimensions.
Sourcepub fn x(x: u32) -> Self
pub fn x(x: u32) -> Self
Creates a 1-dimensional Dim3 with the given X value.
Y and Z are set to 1.
Trait Implementations§
impl Copy for Dim3
impl Eq for Dim3
impl StructuralPartialEq for Dim3
Auto Trait Implementations§
impl Freeze for Dim3
impl RefUnwindSafe for Dim3
impl Send for Dim3
impl Sync for Dim3
impl Unpin for Dim3
impl UnsafeUnpin for Dim3
impl UnwindSafe for Dim3
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