Ceiling division
Ceiling division returns the least integer greater than or equal to the exact quotient of two numbers.
Grokking GPU Programming
Ceiling division is division rounded upward to the smallest integer greater than or equal to the exact quotient.
- How it is used
- Determines enough CUDA thread blocks to cover an array when its size is not an exact multiple of the block size.
- How deep it goes
- Derives the formula with remainder and exact-multiple examples, and notes empty-input handling and an alternative formula’s zero-case failure.
- Examples
- Works through 1,000 elements with blocks of 256, an exact multiple of 1,024, and a four-seat taxi analogy.
- What you can do after
- Apply the C/C++ formula to choose a CUDA block count that covers every array element.
Read how Grokking GPU Programming explains ceiling division →
CUDA for LLMs
Ceiling division computes the smallest integer greater than or equal to the quotient of two integers.
- How it is used
- Sizes CUDA grids to cover matrix or image dimensions when block dimensions do not divide them evenly.
- How deep it goes
- Defines the integer-rounding idiom and works through grid calculations, including the need for boundary checks.
- Examples
- Calculates grids for a 1000 × 500 matrix with 16 × 16 blocks and a 28 × 28 image with 16 × 16 blocks.
- What you can do after
- Apply it to size CUDA grids that cover dimensions not divisible by the block dimensions.
What to know first
- GPU memoryGPU memory is memory available to a graphics processing unit for storing data and state used in graphics or computation.
- matrixA matrix is a rectangular two-dimensional array of elements arranged in rows and columns.
- thread blockA thread block is a group of GPU threads organized to execute together and cooperate using shared resources.
Related concepts
- integer divisioncontrasts with · Integer division is division that produces an integer quotient by discarding the fractional part according to the applicable arithmetic convention.
- triton.cdivimplemented by · triton.cdiv is a Triton helper that computes integer ceiling division.
- kernel launch configurationused by · A kernel launch configuration specifies the execution parameters, including grid and thread-block dimensions, for launching a GPU kernel.
Questions about ceiling division
What is ceiling division?
Ceiling division returns the least integer greater than or equal to the exact quotient of two numbers.
Which Manning books explain ceiling division?
Grokking GPU Programming and CUDA for LLMs.
What should I know before learning ceiling division?
Manning books that teach ceiling division usually introduce GPU memory, matrix and thread block first.
What is the difference between ceiling division and integer division?
Ceiling division returns the least integer greater than or equal to the exact quotient of two numbers. Integer division is division that produces an integer quotient by discarding the fractional part according to the applicable arithmetic convention.
What is ceiling division a kind of?
Ceiling division is a kind of division. Division is the arithmetic operation of partitioning one quantity by another or determining how many times one quantity contains another.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

