现代x86的成本模型 [英] Modern x86 cost model

查看:148
本文介绍了现代x86的成本模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个JIT编译器与后端的x86和学习x86汇编和机器code,我去。我大约20年前使用ARM汇编器和感到这些体系结构之间的成本模型的差异感到惊讶。

I'm writing a JIT compiler with an x86 backend and learning x86 assembler and machine code as I go. I used ARM assembler about 20 years ago and am surprised by the difference in cost models between these architectures.

具体而言,内存访问和分支机构都在ARM昂贵,但相当于堆栈操作和跳跃是在x86便宜。我相信现代的x86 CPU做的更为动态的优化比ARM内核做,我觉得很难预测它们的影响。

Specifically, memory accesses and branches are expensive on ARM but the equivalent stack operations and jumps are cheap on x86. I believe modern x86 CPUs do far more dynamic optimizations than ARM cores do and I find it difficult to anticipate their effects.

什么是良好的成本模型编写x86汇编的时候要记住?其中指令的组合很便宜,这是昂贵的?

What is a good cost model to bear in mind when writing x86 assembler? Which combinations of instructions are cheap and which are expensive?

例如,我的编译器会更简单,如果它总是产生的长格式加载整数或跳转到偏移,即使是整数或小的偏移量接近,但将这种影响的表现?

For example, my compiler would be simpler if it always generated the long form for loading integers or jumping to offsets even if the integers were small or the offsets close but would this impact performance?

我没有做过任何浮点,但是我想尽快得到它。有什么关于正常和浮code?

I haven't done any floating point yet but I'd like to get on to it soon. Is there anything not obvious about the interaction between normal and float code?

我知道有很多在x86优化引用(例如迈克尔·亚伯拉什),但我有一种预感比什么比几年的老不适用于现代的x86 CPU,因为他们已经改变了很多最近。我是不是正确的?

I know there are lots of references (e.g. Michael Abrash) on x86 optimization but I have a hunch than anything more than a few years old will not apply to modern x86 CPUs because they have changed so much lately. Am I correct?

推荐答案

最好的参考就是<一个href=\"http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html\">Intel优化手册,其中提供了关于建筑的危害和指令延迟所有最近的酷睿相当详细的信息,还有一个很好的一些优化的例子。

The best reference is the Intel Optimization Manual, which provides fairly detailed information on architectural hazards and instruction latencies for all recent Intel cores, as well as a good number of optimization examples.

另一个优秀的参考资料是瓦格纳雾的优化资源,其中有美德的也包括AMD内核。

Another excellent reference is Agner Fog's optimization resources, which have the virtue of also covering AMD cores.

需要注意的是具体的成本模型,通过具体性质,微架构。有作为具有任何一种真正有效的86成本模式没有这样的事。在指令级,ATOM的性能特点,从酷睿i7很大的不同。

Note that specific cost models are, by nature, micro-architecture specific. There's no such thing as an "x86 cost model" that has any kind of real validity. At the instruction level, the performance characteristics of Atom are wildly different from i7.

我还要指出,内存访问和分支机构实际上不是便宜的x86核心 - 它只是在乱序执行模式已经变得如此复杂,它可以成功地隐藏它们的成本在很多​​简单场景。

I would also note that memory accesses and branches are not actually "cheap" on x86 cores -- it's just that the out-of-order execution model has become so sophisticated that it can successfully hide the cost of them in many simple scenarios.

这篇关于现代x86的成本模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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