Hi,
could someone explain to me/point me to some resources that explain branch prediction. What is it doing... or better how is it done in order to optimize code?
ThanX
PredeX
could someone explain to me/point me to some resources that explain branch prediction. What is it doing... or better how is it done in order to optimize code?
ThanX
PredeX
Agner Fog did an article for Dr Dobb's on branch prediction:
http://www.x86.org/articles/branch/branchprediction.htm
You should also read his optimization guide:
http://www.agner.org/assem/#optimize
:)
http://www.x86.org/articles/branch/branchprediction.htm
You should also read his optimization guide:
http://www.agner.org/assem/#optimize
:)
Agner Fog's work is very good and is the best reference work around in this area as far as I know but there is a basic rule to avoid branch prediction problems, do whatever you need to do to reduce the number of branches in your speed critical algorithms.
You cannot entirely remove jumps in most code but where you can reduce the number of conditional jumps (Jxx), you often end up with a speed increase with your algorithm.
Regards,
hutch@movsd.com
You cannot entirely remove jumps in most code but where you can reduce the number of conditional jumps (Jxx), you often end up with a speed increase with your algorithm.
Regards,
hutch@movsd.com