@@ -18,43 +18,43 @@ use crate::module::Module;
1818#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
1919pub struct GridSize {
2020 /// Width of grid in blocks
21- pub x : u32 ,
21+ pub x : usize ,
2222 /// Height of grid in blocks
23- pub y : u32 ,
23+ pub y : usize ,
2424 /// Depth of grid in blocks
25- pub z : u32 ,
25+ pub z : usize ,
2626}
2727impl GridSize {
2828 /// Create a one-dimensional grid of `x` blocks
2929 #[ inline]
30- pub fn x ( x : u32 ) -> GridSize {
30+ pub fn x ( x : usize ) -> GridSize {
3131 GridSize { x, y : 1 , z : 1 }
3232 }
3333
3434 /// Create a two-dimensional grid of `x * y` blocks
3535 #[ inline]
36- pub fn xy ( x : u32 , y : u32 ) -> GridSize {
36+ pub fn xy ( x : usize , y : usize ) -> GridSize {
3737 GridSize { x, y, z : 1 }
3838 }
3939
4040 /// Create a three-dimensional grid of `x * y * z` blocks
4141 #[ inline]
42- pub fn xyz ( x : u32 , y : u32 , z : u32 ) -> GridSize {
42+ pub fn xyz ( x : usize , y : usize , z : usize ) -> GridSize {
4343 GridSize { x, y, z }
4444 }
4545}
46- impl From < u32 > for GridSize {
47- fn from ( x : u32 ) -> GridSize {
46+ impl From < usize > for GridSize {
47+ fn from ( x : usize ) -> GridSize {
4848 GridSize :: x ( x)
4949 }
5050}
51- impl From < ( u32 , u32 ) > for GridSize {
52- fn from ( ( x, y) : ( u32 , u32 ) ) -> GridSize {
51+ impl From < ( usize , usize ) > for GridSize {
52+ fn from ( ( x, y) : ( usize , usize ) ) -> GridSize {
5353 GridSize :: xy ( x, y)
5454 }
5555}
56- impl From < ( u32 , u32 , u32 ) > for GridSize {
57- fn from ( ( x, y, z) : ( u32 , u32 , u32 ) ) -> GridSize {
56+ impl From < ( usize , usize , usize ) > for GridSize {
57+ fn from ( ( x, y, z) : ( usize , usize , usize ) ) -> GridSize {
5858 GridSize :: xyz ( x, y, z)
5959 }
6060}
@@ -64,52 +64,28 @@ impl From<&GridSize> for GridSize {
6464 }
6565}
6666#[ cfg( feature = "vek" ) ]
67- impl From < vek:: Vec2 < u32 > > for GridSize {
68- fn from ( vec : vek:: Vec2 < u32 > ) -> Self {
69- GridSize :: xy ( vec. x , vec. y )
70- }
71- }
72- #[ cfg( feature = "vek" ) ]
73- impl From < vek:: Vec3 < u32 > > for GridSize {
74- fn from ( vec : vek:: Vec3 < u32 > ) -> Self {
75- GridSize :: xyz ( vec. x , vec. y , vec. z )
76- }
77- }
78- #[ cfg( feature = "vek" ) ]
7967impl From < vek:: Vec2 < usize > > for GridSize {
8068 fn from ( vec : vek:: Vec2 < usize > ) -> Self {
81- GridSize :: xy ( vec. x as u32 , vec. y as u32 )
69+ GridSize :: xy ( vec. x , vec. y )
8270 }
8371}
8472#[ cfg( feature = "vek" ) ]
8573impl From < vek:: Vec3 < usize > > for GridSize {
8674 fn from ( vec : vek:: Vec3 < usize > ) -> Self {
87- GridSize :: xyz ( vec. x as u32 , vec. y as u32 , vec. z as u32 )
88- }
89- }
90-
91- #[ cfg( feature = "glam" ) ]
92- impl From < glam:: UVec2 > for GridSize {
93- fn from ( vec : glam:: UVec2 ) -> Self {
94- GridSize :: xy ( vec. x , vec. y )
95- }
96- }
97- #[ cfg( feature = "glam" ) ]
98- impl From < glam:: UVec3 > for GridSize {
99- fn from ( vec : glam:: UVec3 ) -> Self {
10075 GridSize :: xyz ( vec. x , vec. y , vec. z )
10176 }
10277}
78+
10379#[ cfg( feature = "glam" ) ]
10480impl From < glam:: USizeVec2 > for GridSize {
10581 fn from ( vec : glam:: USizeVec2 ) -> Self {
106- GridSize :: xy ( vec. x as u32 , vec. y as u32 )
82+ GridSize :: xy ( vec. x , vec. y )
10783 }
10884}
10985#[ cfg( feature = "glam" ) ]
11086impl From < glam:: USizeVec3 > for GridSize {
11187 fn from ( vec : glam:: USizeVec3 ) -> Self {
112- GridSize :: xyz ( vec. x as u32 , vec. y as u32 , vec. z as u32 )
88+ GridSize :: xyz ( vec. x , vec. y , vec. z )
11389 }
11490}
11591
@@ -123,43 +99,43 @@ impl From<glam::USizeVec3> for GridSize {
12399#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
124100pub struct BlockSize {
125101 /// X dimension of each thread block
126- pub x : u32 ,
102+ pub x : usize ,
127103 /// Y dimension of each thread block
128- pub y : u32 ,
104+ pub y : usize ,
129105 /// Z dimension of each thread block
130- pub z : u32 ,
106+ pub z : usize ,
131107}
132108impl BlockSize {
133109 /// Create a one-dimensional block of `x` threads
134110 #[ inline]
135- pub fn x ( x : u32 ) -> BlockSize {
111+ pub fn x ( x : usize ) -> BlockSize {
136112 BlockSize { x, y : 1 , z : 1 }
137113 }
138114
139115 /// Create a two-dimensional block of `x * y` threads
140116 #[ inline]
141- pub fn xy ( x : u32 , y : u32 ) -> BlockSize {
117+ pub fn xy ( x : usize , y : usize ) -> BlockSize {
142118 BlockSize { x, y, z : 1 }
143119 }
144120
145121 /// Create a three-dimensional block of `x * y * z` threads
146122 #[ inline]
147- pub fn xyz ( x : u32 , y : u32 , z : u32 ) -> BlockSize {
123+ pub fn xyz ( x : usize , y : usize , z : usize ) -> BlockSize {
148124 BlockSize { x, y, z }
149125 }
150126}
151- impl From < u32 > for BlockSize {
152- fn from ( x : u32 ) -> BlockSize {
127+ impl From < usize > for BlockSize {
128+ fn from ( x : usize ) -> BlockSize {
153129 BlockSize :: x ( x)
154130 }
155131}
156- impl From < ( u32 , u32 ) > for BlockSize {
157- fn from ( ( x, y) : ( u32 , u32 ) ) -> BlockSize {
132+ impl From < ( usize , usize ) > for BlockSize {
133+ fn from ( ( x, y) : ( usize , usize ) ) -> BlockSize {
158134 BlockSize :: xy ( x, y)
159135 }
160136}
161- impl From < ( u32 , u32 , u32 ) > for BlockSize {
162- fn from ( ( x, y, z) : ( u32 , u32 , u32 ) ) -> BlockSize {
137+ impl From < ( usize , usize , usize ) > for BlockSize {
138+ fn from ( ( x, y, z) : ( usize , usize , usize ) ) -> BlockSize {
163139 BlockSize :: xyz ( x, y, z)
164140 }
165141}
@@ -169,52 +145,28 @@ impl From<&BlockSize> for BlockSize {
169145 }
170146}
171147#[ cfg( feature = "vek" ) ]
172- impl From < vek:: Vec2 < u32 > > for BlockSize {
173- fn from ( vec : vek:: Vec2 < u32 > ) -> Self {
174- BlockSize :: xy ( vec. x , vec. y )
175- }
176- }
177- #[ cfg( feature = "vek" ) ]
178- impl From < vek:: Vec3 < u32 > > for BlockSize {
179- fn from ( vec : vek:: Vec3 < u32 > ) -> Self {
180- BlockSize :: xyz ( vec. x , vec. y , vec. z )
181- }
182- }
183- #[ cfg( feature = "vek" ) ]
184148impl From < vek:: Vec2 < usize > > for BlockSize {
185149 fn from ( vec : vek:: Vec2 < usize > ) -> Self {
186- BlockSize :: xy ( vec. x as u32 , vec. y as u32 )
150+ BlockSize :: xy ( vec. x , vec. y )
187151 }
188152}
189153#[ cfg( feature = "vek" ) ]
190154impl From < vek:: Vec3 < usize > > for BlockSize {
191155 fn from ( vec : vek:: Vec3 < usize > ) -> Self {
192- BlockSize :: xyz ( vec. x as u32 , vec. y as u32 , vec. z as u32 )
193- }
194- }
195-
196- #[ cfg( feature = "glam" ) ]
197- impl From < glam:: UVec2 > for BlockSize {
198- fn from ( vec : glam:: UVec2 ) -> Self {
199- BlockSize :: xy ( vec. x , vec. y )
200- }
201- }
202- #[ cfg( feature = "glam" ) ]
203- impl From < glam:: UVec3 > for BlockSize {
204- fn from ( vec : glam:: UVec3 ) -> Self {
205156 BlockSize :: xyz ( vec. x , vec. y , vec. z )
206157 }
207158}
159+
208160#[ cfg( feature = "glam" ) ]
209161impl From < glam:: USizeVec2 > for BlockSize {
210162 fn from ( vec : glam:: USizeVec2 ) -> Self {
211- BlockSize :: xy ( vec. x as u32 , vec. y as u32 )
163+ BlockSize :: xy ( vec. x , vec. y )
212164 }
213165}
214166#[ cfg( feature = "glam" ) ]
215167impl From < glam:: USizeVec3 > for BlockSize {
216168 fn from ( vec : glam:: USizeVec3 ) -> Self {
217- BlockSize :: xyz ( vec. x as u32 , vec. y as u32 , vec. z as u32 )
169+ BlockSize :: xyz ( vec. x , vec. y , vec. z )
218170 }
219171}
220172
@@ -448,7 +400,7 @@ impl Function<'_> {
448400 & self ,
449401 dynamic_smem_size : usize ,
450402 block_size_limit : BlockSize ,
451- ) -> CudaResult < ( u32 , u32 ) > {
403+ ) -> CudaResult < ( usize , usize ) > {
452404 let mut min_grid_size = MaybeUninit :: uninit ( ) ;
453405 let mut block_size = MaybeUninit :: uninit ( ) ;
454406
@@ -465,8 +417,8 @@ impl Function<'_> {
465417 )
466418 . to_result ( ) ?;
467419 Ok ( (
468- min_grid_size. assume_init ( ) as u32 ,
469- block_size. assume_init ( ) as u32 ,
420+ min_grid_size. assume_init ( ) as usize ,
421+ block_size. assume_init ( ) as usize ,
470422 ) )
471423 }
472424 }
0 commit comments