Every CUDA thread runs the same kernel code, but needs to know which piece of data is its own. threadIdx.x is the thread’s built-in x-coordinate: in a one-dimensional block, threads count from 0 upward, so each can use its index to select an array element. section 2.6 section 2.11
One block, six threads
With a one-dimensional launch such as kernel<<<1, 6>>>(), the threads see indices 0 through 5. Each can use its own index for the matching array element. Because there is only one block, threadIdx.x alone is enough. section 2.11 section 2.6
Figure 2.2 1D thread layout: one index per thread. In a 1D block, each thread gets a unique threadIdx.x starting from 0; that's all it needs to know which element to work on. (These numbers are unique within a block; with multiple blocks, each block counts from 0 again.) The six threads shown here are what a one-dimensional launch like kernel<<<1, 6>>>() creates: the launch is what brings the threads into being, and each one then reads its own threadIdx.x.

See how a one-dimensional block gives each thread its own index, starting at zero. section 2.6
Keep the block boundary in mind:
- threadIdx.x starts over at zero in each block, so it is not a grid-wide index. Using it alone with multiple blocks makes them address the same elements; combine it with blockIdx.x and blockDim.x for the global index. section 3.13
