自动检测 128 位 4 路 SSE2

中本聪SN-2719

SVN rev 150 加了一些代码,尝试自动检测是否使用 4 路 SSE2。我们需要它,因它只在拥有 128 位 SSE2 的某些较新 CPU 上更快,而在 64 位 SSE2 的 CPU 上无法提速。

SVN rev 150 has some code to try to auto-detect whether to use 4-way SSE2. We need this because it's only faster on certain newer CPUs that have 128-bit SSE2 and not ones with 64-bit SSE2.

它用 CPUID 指令获取 CPU 品牌、family、型号和 stepping。这是容易的部分。难的是知道该如何根据型号作出判断。我并未找到任何按 family、model、stepping 排列的 CPU 对照表,只能依据看到的零散报告。

It uses the CPUID instruction to get the CPU brand, family, model number and stepping. That's the easy part. Knowing what to do with the model number is the hard part. I was not able to find any table of family, model and stepping numbers for CPUs. I had to go by various random reports I saw.

这是我最终的结果:

Here's what I ended up with:

// We need Intel Nehalem or AMD K10 or better for 128bit SSE2
  // Nehalem = i3/i5/i7 and some Xeon
  // K10 = Opterons with 4 or more cores, Phenom, Phenom II, Athlon II
  //  Intel Core i5  family 6, model 26 or 30
  //  Intel Core i7  family 6, model 26 or 30
  //  Intel Core i3  family 6, model 37
  //  AMD Phenom    family 16, model 10
  bool fUseSSE2 = ((fIntel && nFamily * 10000 + nModel >=  60026) ||
                   (fAMD   && nFamily * 10000 + nModel >= 160010));

我零星看到过一些互不一致的 AMD CPU 型号编号,因此不确定这能否识别出所有具备相应能力的 AMD 处理器。

I saw some sporadic inconsistent model numbers for AMD CPUs, so I'm not sure if this will catch all capable AMDs.

如果判断错了,你仍然能用 -4way 或 -4way=0 覆盖。

If it's wrong, you can still override it with -4way or -4way=0.

它会把检测结果打进 debug.log。搜 CPUID。

It prints what it finds in debug.log. Search on CPUID.

只有使用 GCC 构建时才启用。

This is only enabled if built with GCC.

上下文
译文校对、修订与纠错

当前版本尚未建立逐条校对状态记录。来源核验、历史审校与当前译文校对是不同事项。

查看历史审校与代表修订 →

译文内容版本:0ed8df55375e。用于比对文本,不代表校对等级或更新时间。

准备纠错说明

请填写对应原文、现译文、建议译法和理由。复制后通过你联系本站作者的渠道提交;此处不会自动发送。

来源
英文原标题

Auto-detect for 128-bit 4-way SSE2

Bitcointalk · 原始链接 ↗ 记录编号 SN-2719

阅读字号

选择适合你的字号,之后阅读会继续使用。