In modern CPU the branch predictor is complicated and the deeper pipeline causing the cost of miss branch prediction higher.
How can we leveraging the modern CPU branch predictor, In [1] example code, the branch miss rate can be reduce by just sorting input data before exciting original algorithm.
Conclusion
1. Adding pattern to your algorithm(sorted data).
2. Using likely()/unlikely() marco to help branch prediction more accuracy.
Reference:
3. Linux likely() unlikely() MARCO.
沒有留言:
張貼留言