Coding Practices which enable the compiler/optimizer to make a faster program

后端 未结 30 1945
一个人的身影
一个人的身影 2020-12-02 03:24

Many years ago, C compilers were not particularly smart. As a workaround K&R invented the register keyword, to hint to the compiler, that maybe it woul

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 04:20

    i use intel compiler. on both Windows and Linux.

    when more or less done i profile the code. then hang on the hotspots and trying to change the code to allow compiler make a better job.

    if a code is a computational one and contain a lot of loops - vectorization report in intel compiler is very helpful - look for 'vec-report' in help.

    so the main idea - polish the performance critical code. as for the rest - priority to be correct and maintainable - short functions, clear code that could be understood 1 year later.

提交回复
热议问题