作者tinlans ( )
看板Programming
标题Re: [问题] 追求效能下,在Do Loop下用IF叙述?
时间Wed Mar 12 12:34:40 2008
※ 引述《noguest (guest)》之铭言:
: 如果演算法方面已经优化的差不多的话,可以从 compiler 的参数下手。假如
: 你的程式还没有使用 profiling 来最佳化,一定要先试这部份。根据经验,
: 最好的情况是可以让执行速度快 30%,当然 profiling 对不同的程式和不同的
: 平台的帮助不一定,但一般对越复杂且计算越多的程式帮助比较大。用 profiling
: 可以明显看到对 branch prediction 和 CPI 有帮助。
: icc 的话,profiling 的 flag 是 -prof_gen, -prof_use, 和 -prof_dir,其
: 他的 compiler 大多也有类似的 flag。要注意一点就是用来产生 feedback
: 的 workload,越接近实际要跑的计算对效率帮助越大,跑个半小时到一小时就
: 够了,收集到的资料已够让 compiler 做很多的最佳化。
没错,还是跑 profiling 最实际,
不过我的建议是先看看 profiling 的资讯,
如果你的架构是 intel 的那可以想办法去弄到 vTune,
只要你对 architecture (不一定要修过课) 够了解的话,
它可以提供你相当多的资讯,
当然也包括 branch prediction 的准确度等等,
这样也能顺便测试一下你的 compiler 水准到哪里。
最内层 loop 要是有 call function 的话,
那个 function 内容最好也能同时被 compiler 看到,
这样才有机会完成 inline;
另外有 if else 并不一定代表一定有 branch instruction 被产生,
因为有可能被 if-conversion 这项最佳化处理掉,
所以做 profiling feedback optimization 可能收到的效果还是有限。
--
Ling-hua Tseng (
[email protected])
Department of Computer Science, National Tsing-Hua University
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage:
https://it.muds.net/~uranus
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.230.224.95
※ 编辑: tinlans 来自: 61.230.224.95 (03/12 12:37)