Skip to main content

dispatch_count_for

Function dispatch_count_for 

Source
pub fn dispatch_count_for(n_items: usize, workgroup_size: u32) -> [u32; 3]
Expand description

Compute the number of workgroups needed to cover n_items in the X dimension.

Returns [0, 1, 1] when n_items is zero to produce a no-op dispatch without panicking.

This is a pure helper used by both the feature-gated real backend and any CPU-side utilities that need to replicate the same dispatch sizing logic.

ยงExamples

use oxiphysics_gpu::compute::timestamp::dispatch_count_for;

assert_eq!(dispatch_count_for(0, 64), [0, 1, 1]);
assert_eq!(dispatch_count_for(64, 64), [1, 1, 1]);
assert_eq!(dispatch_count_for(65, 64), [2, 1, 1]);