Integer division drops the fractional part of a quotient. When choosing CUDA blocks for an array, dividing its size by the threads per block can therefore leave elements uncovered if there is a remainder. section 3.14 section 3.9
A leftover needs another block
With 1,000 elements and 256 threads per block, plain division gives 3 blocks—only 768 threads. Ceiling division gives 4, enough to cover the array. For positive counts, use (n + threadsPerBlock - 1) / threadsPerBlock; exact multiples remain unchanged. section 3.9 section 3.14
int numBlocks = (n + threadsPerBlock - 1) / threadsPerBlock; #A
Use this C/C++ expression to round the block count up when a remainder is present. section 3.9

