免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: weishigoname
打印 上一主题 下一主题

字节对齐问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2012-05-15 20:12 |只看该作者
回复 9# bruceteen


    16字节对齐居多。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
12 [报告]
发表于 2012-05-16 09:43 |只看该作者
[quote][size=2][color=#000]walleeee 发表于 2012-05-15 20:12[/color] [url=forum.php?mod=redirect&goto=findpost&pid=22101886&ptid=3743667][img]static/image/common/back.gif[/img][/url][/size]
回复 9# bruceteen


[/quote]

昨天看Intel的一篇程序开发优化手册,多次提到16字节对齐,这是其中一段
...
Assembly/Compiler Coding Rule 45. (H impact, H generality) Align data on
natural operand size address boundaries. If the data will be accessed with vector
instruction loads and stores, align the data on 16-byte boundaries.
...

文中还多次强调要时刻记住cache line的大小是64字节(当前主流Intel x86/x64),尽量不要跨64字节边界访问以提高CACHE的效率
....
Misaligned data access can incur significant performance penalties. This is particu-
larly true for cache line splits. The size of a cache line is 64 bytes in the Pentium 4 and
other recent Intel processors, including processors based on Intel Core microarchi-
tecture.

....

On Intel Core 2 Duo, Intel Core Duo, Intel Core Solo, Pentium 4, Intel Xeon and
Pentium M processors, memory coherence is maintained on 64-byte cache lines
(rather than 32-byte cache lines. as in earlier processors). This can increase the
opportunity for false sharing.


这里我有个疑问,那就是针对64字节cache line大小而产生的优化手段一般是编译器干的事情吧
C程序员需要考虑吗?

论坛徽章:
59
2015年亚洲杯之约旦
日期:2015-01-27 21:27:392015年亚洲杯之日本
日期:2015-02-06 22:09:41拜羊年徽章
日期:2015-03-03 16:15:432015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015元宵节徽章
日期:2015-03-06 15:50:392015年亚洲杯之阿联酋
日期:2015-03-19 17:39:302015年亚洲杯之中国
日期:2015-03-23 18:52:23巳蛇
日期:2014-12-14 22:44:03双子座
日期:2014-12-10 21:39:16处女座
日期:2014-12-02 08:03:17天蝎座
日期:2014-07-21 19:08:47
13 [报告]
发表于 2012-05-16 10:31 |只看该作者
回复 10# bruceteen
**. Happy every day~~


   

论坛徽章:
0
14 [报告]
发表于 2012-05-16 14:34 |只看该作者
回复 12# safedead


    不要考虑
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP