多少次应循环中unwinded? [英] How many times should a loop be unwinded?
问题描述
我学习循环展开,以避免因依赖摊位。我发现互联网和文学的例子很多,但我发现算法如何用于获得优化code ++工程(如果有一个这样的算法,当然)没有解释。特别是,我不知道如何来定多少次应循环中展开。能不能事先计算出来的?
I'm learning about loop unrolling to avoid stalls caused by dependencies. I found many examples on internet and in literature, but I found no explanation on how the algorithm used to obtain the optimized code works (in case there is one such algorithm, of course). In particular, I don't know how to determinate how many times should the loop be unrolled. Can it be calculated beforehand?
推荐答案
经验法则是你放松,因此:
The rule of thumb is that you unwind so that:
- 操作都在自然的边界值4,8,16,32 ..字节 完成
- 您不引入过多的寄存器pressure(即你不开始杂耍寄存器内存)
- 您不要开始一遍又一遍地重复着相同的指令序列
基本上你解开只要你可以把更多的资源来工作,你停止当你不再可以测量任何性能提升。
Basically you unroll as long as you can put more resources to work and you stop when you no longer can measure any performance gains.
这篇关于多少次应循环中unwinded?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!