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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Contains GPU-accelerated methods via cubecl and burn.
use ;
use crateBixverseErrors;
////////////
// Consts //
////////////
/// Smaller work group version with 32
pub const WORKGROUP_32: u32 = 32;
/// Medium work group version with 32
pub const WORKGROUP_64: u32 = 64;
/// Larger work group version with 128
pub const WORKGROUP_128: u32 = 128;
/// Even larger work group version with 256
pub const WORKGROUP_256: u32 = 256;
/// Very large work group version with 512
pub const WORKGROUP_512: u32 = 512;
/////////////
// Helpers //
/////////////
/// Build a static cube count, checked against the device's per-dimension limit.
///
/// A dispatch that busts the limit is not a soft failure: the launch is
/// rejected on the cubecl server thread, that thread dies, and every
/// subsequent call on the client returns an unrelated `CallError` from
/// somewhere else entirely. Catching it here turns that into a typed error
/// naming the kernel.
///
/// The limit comes from `R::max_cube_count()` rather than a hardcoded
/// constant, which is 65535 per dimension on wgpu but is not a portable
/// number.
///
/// ### Params
///
/// * `kernel` - Kernel name, for the error message only
/// * `x` - Requested cubes along x
/// * `y` - Requested cubes along y
/// * `z` - Requested cubes along z
///
/// ### Returns
///
/// `CubeCount::Static(x, y, z)`, or `GpuCubeCountExceeded` if any dimension is
/// over the device limit.