liveBook · Manning

Bounds checking

Also called boundary check, bounds check

Bounds checking verifies that an index, access, or operation falls within the permitted limits of a data structure, memory region, or range.

How 4 Manning books explain it

Grokking GPU Programming

A bounds check is a conditional test that verifies an index lies within a data structure's valid range before access or computation.

How it is used
Guards CUDA array accesses when thread launches or neighbor offsets can produce indices outside valid data.
How deep it goes
Works through guards, failure symptoms, allocation sizing, and synchronization; notes boundary divergence but defers its detailed cost.
Examples
Uses a 1,000-element multi-block launch, a scan’s left-edge access, and stencil neighbor checks.
What you can do after
Apply bounds checks in CUDA kernels and diagnose crashes or incorrect results caused by missing guards.

Read how Grokking GPU Programming explains bounds checking →

Fast Python: High performance techniques for large datasets

How it is used
Uses index guards to prevent invalid memory access in CUDA kernels and discusses bounds-checking overhead in Cython.
How deep it goes
Explains the excess-thread failure case and explicit guard, while noting that disabling Cython checks removes a safety net.
Examples
Uses a one-dimensional CUDA array with excess threads and a Cython memoryview whose automatic checks can be disabled.
What you can do after
Apply an explicit CUDA index guard to prevent excess threads from accessing elements beyond an array’s size.

Read how Fast Python: High performance techniques for large datasets explains bounds checking →

CUDA for LLMs

A boundary check is a conditional test that prevents a computation from accessing data outside its valid range.

How it is used
Prevents CUDA threads from accessing data outside valid dimensions when a launch covers more positions than the workload.
How deep it goes
Implements guards for vector, matrix, and GEMV kernels without analyzing their performance cost.
Examples
Uses vector addition, 1000-by-500 matrix addition, and a GEMV row loop to illustrate guarded accesses.
What you can do after
Apply conditional guards in CUDA kernels before accessing elements indexed by thread coordinates.

Read how CUDA for LLMs explains bounds checking →

100 Java Mistakes and How to Avoid Them

A bounds check is a validation that an index or indexed range lies within the permitted limits of a data structure.

How it is used
Prevents invalid array, string, list, and indexed-range access before it causes exceptions or worse program behavior.
How deep it goes
Explains empty inputs, ordering errors, reversed comparisons, off-by-one errors, range constraints, and standard library checks.
Examples
Uses empty strings, array element access, offset-count ranges, and custom InputStream and List implementations.
What you can do after
Diagnose/debug with it by locating unsafe access order, reversed comparisons, and off-by-one conditions.

Read how 100 Java Mistakes and How to Avoid Them explains bounds checking →

Also covered in

What to know first

Related concepts

Questions about bounds checking

What is bounds checking?

Bounds checking verifies that an index, access, or operation falls within the permitted limits of a data structure, memory region, or range.

Which Manning books explain bounds checking?

Grokking GPU Programming, Fast Python: High performance techniques for large datasets, CUDA for LLMs and 100 Java Mistakes and How to Avoid Them.

What should I know before learning bounds checking?

Manning books that teach bounds checking usually introduce thread, CUDA, GPU memory and array first.

What is bounds checking also called?

Bounds checking is also called boundary check or bounds check.

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.