Monday, January 26, 2015

Optimization using __restrict keyword



well explained in this link..

http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html

SUMMARY
  • Strict aliasing means that two objects of different types cannot refer to the same location in memory. Enable this option in GCC with the -fstrict-aliasing flag. Be sure that all code can safely run with this rule enabled. Enable strict aliasing related warnings with -Wstrict-aliasing, but do not expect to be warned in all cases.
  • Compare the assembly output of the function with restricted pointers and file scope arrays to ensure that all of the possible aliasing information has been used.
  • Only use restricted leaf pointers. Use of parent pointers may break the restrict contract.
  • Publish as many assumptions as possible about aliasing information in the function declaration.
  • Memory windows may be overlapping and still be without aliases. Do not limit the data design to non-overlapping windows.
  • Begin using the restrict keyword immediately. Retrofit old code as soon as possible.
  • Keep loads and stores separated from calculations. This results in better scheduling in GCC, and makes the relationship between the output assembly and the original source clearer.

No comments:

Post a Comment