Replace some instances of blockIdx.x with ctx.block_index().