85
edits
Changes
GPU
,→Grids and NDRange
A typical midrange GPU will "only" be able to process tens-of-thousands of threads at a time. In practice, the device driver will cut up a Grid or NDRange (usually consisting of millions of items) into Blocks or Workgroups. These blocks and workgroups will execute with as much parallel processing as the underlying hardware can support (maybe 10,000 at a time on a midrange GPU). The device driver will implicitly iterate these blocks over the entire Grid or NDRange to complete the task the programmer has specified, similar to a for-loop.
The most important note is that Grids and NDRanges can be 1-dimensional, 2-dimensionalmay not execute concurrently with each other. Some degree of sequential processing may happen. As such, communication across a Grid or 3-dimensional. 2-dimensional grids are common for screen-space operation such as pixel shaders. While 3-dimensional grids are useful for specifying many operations per pixel NDRange is difficult to achieve (such as If thread #0 creates a raytracerSpinlock waiting for thread #1000000 to communicate with it, which may launch 5000 rays per pixelmodern hardware will probably never have the two threads executing concurrently with each other and the code would deadlock). In practice, the easiest mechanism for Grid or NDRange sized synchronization is to wait for the kernel to finish executing: to have the CPU wait and process the results in between Grid or NDRanges.
= Architectures and Physical Hardware =