Skip to main content

min_task_len

Function min_task_len 

Source
pub fn min_task_len(len: usize, item_bytes: usize) -> usize
Expand description

Minimum items one task must hold, for a loop of the given shape.

Use this where a call site picks its own chunk length, and pass the result as that length.

§Arguments

  • len - total items the loop covers
  • item_bytes - bytes one item moves: every element read, plus every element written

§Returns

A count in 1..=max(len, 1), never zero, so it is always a usable chunk length. Equal to the total when the loop should not split at all.

Zeroing both budget overrides pins the answer at one, which a chunked caller must expect.