生成最快的可执行文件 [英] Producing the fastest possible executable
问题描述
我有一个非常大的程序,我一直在视觉工作室(v6然后迁移到2008年)。我需要可执行文件尽可能快地运行。该程序大部分时间处理各种大小的整数,并且只有很少的IO。
显然我会选择最大优化,但似乎有各种各样的东西可以做的,不进行优化的标题下,仍然影响可执行的速度。例如,选择__fastcall调用约定或设置结构成员对齐到一个大数。
所以我的问题是:是否有其他编译器/链接器选项,我应该使用程序更快,而不是从属性对话框的优化页面控制。
编辑:我已经广泛使用profilers。
1)使用 __ restrict 。
2)通过使用 __ pure 。
3)可以找到SSE / SIMD的简介此处和此处。互联网并没有完全溢出与这个话题的文章,但足够了。对于宏并行化,您可以尝试使用 OpenMP 。这是一个易于任务并行化的编译器标准 - 实质上,你告诉编译器使用一些#pragmas代码的某些部分是可重入的,编译器为你自动创建线程。
5)我第二个interjay的观点,PGO可以很好地帮助。与#3和#4不同,它几乎可以轻松添加。
I have a very large program which I have been compiling under visual studio (v6 then migrated to 2008). I need the executable to run as fast as possible. The program spends most of its time processing integers of various sizes and does very little IO.
Obviously I will select maximum optimization, but it seems that there are a variety of things that can be done which don't come under the heading of optimization which do still affect the speed of the executable. For example selecting the __fastcall calling convention or setting structure member alignment to a large number.
So my question is: Are there other compiler/linker options I should be using to make the program faster which are not controlled from the "optimization" page of the "properties" dialog.
EDIT: I already make extensive use of profilers.
1) Reduce aliasing by using __restrict.
2) Help the compiler in common subexpression elimination / dead code elimination by using __pure.
3) An introduction to SSE/SIMD can be found here and here. The internet isn't exactly overflowing with articles about the topic, but there's enough. For a reference list of intrinsics, you can search MSDN for 'compiler intrinsics'.
4) For 'macro parallelization', you can try OpenMP. It's a compiler standard for easy task parallelization -- essentially, you tell the compiler using a handful of #pragmas that certain sections of the code are reentrant, and the compiler creates the threads for you automagically.
5) I second interjay's point that PGO can be pretty helpful. And unlike #3 and #4, it's almost effortless to add in.
这篇关于生成最快的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!