asc.experimental.asctile.ceildiv

asc.experimental.asctile.ceildiv(x: int, y: int) → int
asc.experimental.asctile.ceildiv(x: PlainValue | int, y: PlainValue | int) → PlainValue

Compute ceiling division of two integers.

Returns the smallest integer greater than or equal to x / y. This is commonly used to compute the number of tiles or iterations needed to cover a given data size.

Can be used both on the host (outside a kernel) and inside a kernel. When used inside a kernel, the operation follows C semantics (signed integer ceiling division).

Parameters:
  • x – The dividend (numerator). Must be a non-negative integer.

  • y – The divisor (denominator). Must be a positive integer.

Returns:

The ceiling of x / y, computed as (x + y - 1) // y.

Return type:

int

Examples

Compute the number of tiles needed to cover the input data:

num_tiles = asctile.ceildiv(size, tile_size)
tiles_per_core = asctile.ceildiv(num_tiles, asctile.block_num())