6.2.1 About analyzing
code for parallelization
When you have identified the most compute intensive parts of your application, analyze the code to see if you can run it in parallel.
Parallelizing code can present the following degrees of difficulty:
- Parallelizing the code requires small modifications.
- Parallelizing the code requires complex modifications. If you are using work-items in
place of loop iterations, compute variables based on the value of the global ID
rather than using a loop counter.
- Difficult and includes dependencies
Parallelizing the code requires complex modifications and the use of techniques to avoid
dependencies. You can compute values per frame, perform computations in multiple stages,
or pre-compute values to remove dependencies.
- Appears to be impossible
If parallelizing the code appears to be impossible,
this only means that a particular code implementation cannot be
The purpose of code is to perform a function. There might
be different algorithms that perform the same function but work
in different ways. Some of these might be parallelizable.
Investigate different alternatives to the algorithms and data
structures that the code uses. These might make parallelization