cheatah
Module

gpu::dispatch

cheatah-gpu v0.5.1-alpha — Biome Standard 0.6.3-alpha

Classes

Functions

fn std::uint32_t ceil_div(std::uint32_t numerator, std::uint32_t denom) #

Number of workgroups needed to cover numerator items at denom items per group (ceiling division).

Computed overflow-safe — without the usual (n + d - 1) / d, which overflows for numerator near UINT32_MAX.

Parameters
numerator

total items to process (e.g. elements in a buffer).

denom

items handled per workgroup — the shader's local size on this axis.

Returns

ceil(numerator / denom); 0 when denom is 0 (an empty/invalid dispatch).

Complexity

O(1).

Host allocation

none.

Unit testDispatch.CeilDiv
Compile-run testsystests/test_dispatch_cr_ceil_div.purr
System testsystests/test_dispatch.purr
fn std::uint32_t group_count_1d(std::uint32_t items, std::uint32_t local_size) #

One-dimensional workgroup count for a 1-D compute dispatch: the groupCountX you pass to vkCmdDispatch so items invocations are covered at local_size threads per group.

Parameters
items

total invocations the shader must cover.

local_size

the shader's local_size_x (threads per workgroup).

Returns

the number of workgroups to dispatch on X; 0 when local_size is 0.

Complexity

O(1).

Host allocation

none.

Unit testDispatch.GroupCount1d
Compile-run testsystests/test_dispatch_cr_group_count_1d.purr
System testsystests/test_dispatch.purr systests/test_dispatch_limits.purr
fn clamp_group_count · 2 overloads
std::uint32_t clamp_group_count(std::uint32_t want, std::uint32_t device_max)#
Dim3 clamp_group_count(Dim3 want, Dim3 device_max)#

Clamp a desired workgroup count for one axis to the device's limit, so a dispatch never exceeds VkPhysicalDeviceLimits::maxComputeWorkGroupCount[axis].

Parameters
want

the workgroup count the problem size asks for.

device_max

the device's maximum workgroup count on this axis.

Returns

want when it fits, otherwise device_max.

Complexity

O(1).

Host allocation

none.

Unit testDispatch.ClampGroupCount
Compile-run testsystests/test_dispatch_cr_clamp_group_count.purr
System testsystests/test_dispatch_limits.purr
fn bool operator==(Dim3 a, Dim3 b) #

Per-axis equality of two extents (all of x, y, and z match).

Parameters
a, b

the extents to compare.

Returns

true when every axis is equal.

Complexity

O(1).

Host allocation

none.

Unit testDispatch.Dim3Equality
Compile-run testsystests/test_dispatch_cr_dim3.purr
fn Dim3 group_count_3d(Dim3 items, Dim3 local_size) #

Three-dimensional workgroup count for a compute dispatch: the (groupCountX, groupCountY, groupCountZ) you pass to vkCmdDispatch so an items volume is covered at local_size threads per group on each axis — ceil_div applied per axis, with its overflow safety and 0-on-zero-denominator semantics.

Parameters
items

total invocations to cover on each axis (e.g. an image's width × height).

local_size

the shader's (local_size_x, local_size_y, local_size_z).

Returns

the per-axis workgroup counts; an axis is 0 when its local_size axis is 0.

Complexity

O(1).

Host allocation

none.

Unit testDispatch.GroupCount3d
Compile-run testsystests/test_dispatch_cr_group_count_3d.purr
System testsystests/test_dispatch.purr