Bitcointalk · Auto-detect for 128-bit 4-way SSE2

中本聪,2010 年 9 月 9 日

SN-2719 已核对来源,附原文与上下文。

阅读语言
中文译文

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

它用 CPUID 指令获取 CPU 品牌、family、型号和 stepping。这是容易的部分。难的是知道拿型号怎么办。我并未找到任何按 family、model、stepping 排列的 CPU 对照表,仅仅能依据看到的零散报告。

这是我最终的结果:

// 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。

倘若判断错了,你仍然能够用 -4way 或 -4way=0 覆盖。

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

仅仅 GCC 构建时才启用。

ORIGINAL · 英文原文
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.

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:
Code:
 // 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));

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

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

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

This is only enabled if built with GCC.
上下文
← 上一条 SN-2719 · 当前 下一条 → 在档案中查看完整主题串 →
来源
Bitcointalk 原始链接 ↗ 记录编号 SN-2719