Benefits of Using the Restrict Keyword for Read/Modify/Write Loops - 2024.2 English

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
UG1603
Release Date
2024-11-28
Version
2024.2 English

The following example works without the restrict keyword, but has poor performance.

Figure 1. Example Without Restrict Keyword

Adding the restrict keyword allows every iteration to access a different location where there is no aliasing between iterations (__restrict) and aliasing within iterations preserved by data dependency. The increased parallelization results in improved performance.

Figure 2. Add Restrict Keyword