Partitioning is another important concept in data parallelism. To achieve parallelism in the source collection, it needs to be partitioned into smaller sections called ranges or chunks, which can be concurrently accessed by various threads. Without partitioning, the loop will execute serially. Partitioners can be classified into two categories and we can create custom partitioners as well. These categories are as follows:
- Range partitioning
- Chunk partitioning
Let's discuss these in detail.