1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Three-dimensional CUDA grid, block, and cluster dimensions.
use singe_cuda_sys::runtime;
/// Three unsigned 32-bit axis values for CUDA grids, blocks, or clusters.
///
/// The interpretation depends on the receiving API.
/// The default value has all axes set to zero; launch geometry constructors reject zero dimensions.
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct Dim3 {
/// Value along the x axis.
pub x: u32,
/// Value along the y axis.
pub y: u32,
/// Value along the z axis.
pub z: u32,
}
impl Dim3 {
/// Creates axis values without validating launch dimensions or device limits.
#[must_use]
pub const fn new(x: u32, y: u32, z: u32) -> Self {
Self { x, y, z }
}
}
impl From<runtime::dim3> for Dim3 {
fn from(dim: runtime::dim3) -> Self {
Self {
x: dim.x,
y: dim.y,
z: dim.z,
}
}
}
impl From<Dim3> for runtime::dim3 {
fn from(dim: Dim3) -> Self {
Self {
x: dim.x,
y: dim.y,
z: dim.z,
}
}
}