如何强制GCC或ICC“内联” [英] How to force 'inline' with GCC or ICC

查看:86
本文介绍了如何强制GCC或ICC“内联”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好


我有一个包含许多内联模板函数的程序

这对每个(或几乎每个)
函数标记为内联,由编译器真正内联。


我已在Visual C ++上使用英特尔编译器(ICL)编译程序,并且

它工作得很好而且速度很快。我确认这些功能都是内联的。


但是使用GCC 3.4(Linux + Cygwin)或ICC(Linux),同样的程序约为5

比Windows慢一些。

GCC的''-Winline'选项告诉我许多函数没有内联

就像他们应该的那样。编译器将''inline''关键字视为建议,

但不遵循它。

我尝试设置GCC的各种选项,但没有什么是令人满意的远:

-finline-limie 100000000

- param大功能增长

--param max-inline-insns-single

....


有一些建议如何强制GCC / ICC服从,或增加

限制这些编译器内部有哪些?

Hello

I have a program with many many inlined template functions
It is essential for the execution speed that every (or almost every)
function marked as inlined, becomes really inlined by the compiler.

I already compiled the program with Intel Compiler (ICL) on Visual C++, and
it works fine and fast. I verified that the functions are really inlined.

But with GCC 3.4 (Linux+Cygwin) or ICC (Linux), The same program is about 5
times slower than under Windows.
The ''-Winline'' option of GCC shows me that many functions are not inlined
like they should. The compiler consider the ''inline'' keyword as an advice,
but does not follow it.
I try to set various options of GCC, but nothing is satisfactory as far:
-finline-limie 100000000
--param large-function-growth
--param max-inline-insns-single
....

Has some-one suggestions how to force GCC/ICC to obey, or to increase the
limits that these compilers internaly have?


推荐答案



15.05.2005 16:25回答to:

" Patrick Laurent" < LA ***** @ ient.rwth-aachen.de>写道:

15.05.2005 16:25 answer to:
"Patrick Laurent" <la*****@ient.rwth-aachen.de> wrote:
你好

我有一个包含许多内联模板功能的程序
每个(或几乎每个)标记为内联的函数,由编译器真正内联。

我已经在Visual C ++上使用英特尔编译器(ICL)编译了程序,并且它的工作正常且速度很快。我确认这些功能都是内联的。

但是使用GCC 3.4(Linux + Cygwin)或ICC(Linux),相同的程序比Windows下慢5/5倍。 GCC的''-Winline'选项告诉我许多功能都没有内嵌
。编译器将''inline''关键字视为建议,
但不遵循它。
我尝试设置GCC的各种选项,但到目前为止没有任何令人满意的结果:
-finline -limie 100000000
- param large-function-growth
--param max-inline-insns-single
....

有一个建议如何强制GCC / ICC服从,或者增加这些编译器内部的限制?
Hello

I have a program with many many inlined template functions
It is essential for the execution speed that every (or almost every)
function marked as inlined, becomes really inlined by the compiler.

I already compiled the program with Intel Compiler (ICL) on Visual C++, and
it works fine and fast. I verified that the functions are really inlined.

But with GCC 3.4 (Linux+Cygwin) or ICC (Linux), The same program is about 5
times slower than under Windows.
The ''-Winline'' option of GCC shows me that many functions are not inlined
like they should. The compiler consider the ''inline'' keyword as an advice,
but does not follow it.
I try to set various options of GCC, but nothing is satisfactory as far:
-finline-limie 100000000
--param large-function-growth
--param max-inline-insns-single
....

Has some-one suggestions how to force GCC/ICC to obey, or to increase the
limits that these compilers internaly have?



内联通常是一项相当棘手的工作。该关键字只是一个

提示而非强制性。它不仅取决于您发出的编译器开关,还取决于代码本身是否编译器决定是否内联代码。例如,虚函数可能是也可能不是内联的b $ b,取决于编译器是否可以明确地识别

real。对象类型。一般规则是多态必须起作用,并且所有优化必须保持优势。关于内联代码的决定还有更多问题(例如递归,

等......)。可能你可以给

一些示例代码?


BTW,检查调试&您的代码的发布版本显示相同的

内联行为。


干杯

Chris


Patrick Laurent写道:
Patrick Laurent wrote:
你好

我有一个包含许多内联模板功能的程序
这是必不可少的对于执行速度,标记为内联的每个(或几乎每个)函数都被编译器真正内联。

我已经在Visual C ++上用Intel Compiler(ICL)编译了程序,并且它工作得很好而且速度很快。我确认这些功能都是内联的。

但是使用GCC 3.4(Linux + Cygwin)或ICC(Linux),相同的程序比Windows下慢5/5倍。 GCC的''-Winline'选项告诉我许多功能都没有内嵌
。编译器将''inline''关键字视为建议,
但不遵循它。
我尝试设置GCC的各种选项,但到目前为止没有任何令人满意的结果:
-finline -limie 100000000
- param large-function-growth
--param max-inline-insns-single
...
Hello

I have a program with many many inlined template functions
It is essential for the execution speed that every (or almost every)
function marked as inlined, becomes really inlined by the compiler.

I already compiled the program with Intel Compiler (ICL) on Visual C++, and
it works fine and fast. I verified that the functions are really inlined.

But with GCC 3.4 (Linux+Cygwin) or ICC (Linux), The same program is about 5
times slower than under Windows.
The ''-Winline'' option of GCC shows me that many functions are not inlined
like they should. The compiler consider the ''inline'' keyword as an advice,
but does not follow it.
I try to set various options of GCC, but nothing is satisfactory as far:
-finline-limie 100000000
--param large-function-growth
--param max-inline-insns-single
...



你有没有实际上为--param参数提供了一个值?否则你

可能会将它们设置为零。使用-Winline g ++ 3.4可以准确地告诉我哪个

参数超出了。


p


Did you actually supply a value to the --param arguments? Otherwise you
probably set them to zero. With -Winline g++ 3.4 tells me exactly which
parameter is exceeded.

p


>
>
你真的为--param参数提供了一个值吗?否则
你可能将它们设置为零。使用-Winline g ++ 3.4可以准确地告诉我
超出了哪个参数。
Did you actually supply a value to the --param arguments? Otherwise you probably set them to zero. With -Winline g++ 3.4 tells me exactly which parameter is exceeded.




我只写了参数名称。


是的,我确实提供了一个值(事实上我尝试了很多价值观,大部分时间都很重要。


但GCC仍然没有列出许多重要的功能,比较ICL on the br />
windows确实。


你是对的,GCC告诉你超出了哪个参数,所以我总是给每个对应的值增加一个

参数(达到天文数值)。但是它不起作用:内联了一些函数,但执行速度

仍比Windows快得多。


有没有办法强制内联?


Pat



I only wrote the parameters names.

Yes,I did supply a value (in fact I tried many values, most of the time big
values).

But GCC still doesn''t inline many important functions, in comparison ICL on
windows does.

You are right, GCC tells which parameter is exceeded, so I always supplied a
bigger value to every corresponding parameter (up to astronomic values). But
it did not work: a few more functions were inlined, but the execution speed
is still very much slower than on Windows.

Is there no way to force inlining?

Pat


这篇关于如何强制GCC或ICC“内联”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆