numba/numba — pull request #444 by seibert (2014-05-21 22:47:57+00:00)
Title: Add a "gridsize" CUDA function to compute blockDim*gridDim in kernels

Similar to the `grid()` convenience function that computes `threadIdx + blockIdx * blockDim` (for 1D or 2D), this patch creates a `gridsize()` convenience function that computes `blockDim * gridDim`, also for 1D or 2D. This supports a common kernel pattern which allows any grid configuration to loop over an arbitrary amount of input data:

def example_kernel(input, output):
n = input.shape[0]
offset = grid(1)
stride = gridsize(1)
for i in range(offset, n, stride):
output[i] = do_something(input[i])