简体   繁体   English

C ++或ANSI C占用的周期数?

[英]Number of cycles taken for C++ or ANSI C?

Is there anywhere on the web where i can get an idea of what the various programming language syntax take in terms of processor (Core i7 and Core 2) cycles? Web上的任何地方都可以让我了解处理器(Core i7和Core 2)周期对各种编程语言语法的要求吗? At university i learnt the ARM assembly language and we could map the number of cycles taken to do a subtraction operator etc. I just wondered if its possible to do this with a higher level language on the Core i7 or Core 2? 在大学里,我学习了ARM汇编语言,我们可以映射执行减法运算符等所需的周期数。我只是想知道是否有可能在Core i7或Core 2上使用高级语言来实现?

No. That's completely dependent on the compiler you use, and what optimization settings you use, etc. 否。这完全取决于您使用的编译器以及您使用的优化设置等。

You can use your favorite compiler and settings to generate assembly code, and from the assembly code you can make these kinds of predictions. 您可以使用自己喜欢的编译器和设置来生成汇编代码,然后从汇编代码中进行此类预测。

However, remember that on modern architectures things like memory latency and register renaming have large effects on speed, and these effects are not obvious even from inspection of the assembly code. 但是,请记住,在现代体系结构上,诸如内存延迟和寄存器重命名之类的内容对速度有很大影响,并且即使从汇编代码的检查中来看,这些影响也不明显。

In general, in higher-level languages, individual statements don't map cleanly onto specific sequences of machine-code instructions. 通常,在高级语言中,单个语句不能清晰地映射到特定的机器代码指令序列上。 The compiler will typically optimise things, which will involve various transformations, arrangements, and even eliminations, of instructions. 编译器通常会优化内容,这将涉及各种指令的转换,安排,甚至消除。 Therefore, it's not usually meaningful to quote metrics like "a for expression takes 20 cycles". 因此,引用“ a for expression需要20个周期”之类的度量通常通常没有意义。

You have to map higher level instructions into assembly instructions manually, or look at the assembly listing. 您必须手动将更高级别的指令映射到汇编指令中,或查看汇编清单。 And then look here 然后看这里

http://gmplib.org/~tege/x86-timing.pdf http://gmplib.org/~tege/x86-timing.pdf

or here 或在这里

http://www.intel.com/Assets/PDF/manual/248966.pdf http://www.intel.com/Assets/PDF/manual/248966.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM