Skip to content

Latest commit

 

History

History
3 lines (2 loc) · 855 Bytes

vi.g.1-considerations.md

File metadata and controls

3 lines (2 loc) · 855 Bytes

VI.G.1 Considerations

The programmer is responsible for ensuring that the loop iterations are independent (for sake of correctness) and have sufficient grain size (for sake of efficiency.) Loop iterations are independent if they can be carried out in arbitrary order, or concurrently and still produce the right answer. The grain size is the amount of work performed by a loop iteration. If the grain size is too small, the overhead (calling the delegate, synchronizing with other threads, etc.) may overwhelm the intended work. The ideal is to make the grain size large and uniform, but not so large as to make it difficult to distribute work evenly across physical threads. For efficiency, ParallelFor is the preferred loop class when there is a choice. It tends to be the most efficient because it has the least general iteration space.