Bitcointalk

4 hashes parallel on SSE2 CPUs for 0.3.6

中本聪 · 2010 年 8 月 14 日

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

阅读语言

MinGW GCC 4.5.0:

MinGW GCC 4.5.0:

Crypto++ 不能用,X86_SHA256_HashBlocks() 一直不返回

Crypto++ doesn't work, X86_SHA256_HashBlocks() never returns

我只有用 test.cpp 时才让 4 路并行跑起来,被 BitcoinMiner 调用时就不行

I only got 4-way working with test.cpp but not when called by BitcoinMiner

MinGW GCC 4.4.1:

MinGW GCC 4.4.1:

Crypto++ 能用

Crypto++ works

4 路并行 SIGSEGV

4-way SIGSEGV

GCC 显然没有对齐 __m128i。

GCC is definitely not aligning __m128i.

即使我们自己把 __m128i 变量对齐了,编译器也可能在后台用 __m128i 当临时变量。

Even if we align our own __m128i variables, the compiler may decide to use a __m128i behind the scenes as a temporary variable.

把我们的 __m128i 变量对齐、并把这几处 inline 改成 define 之后,我让它在 4.4.1 上用 -O0 跑通了:

By making our __m128i variables aligned and changing these inlines to defines, I was able to get it to work on 4.4.1 with -O0 only:

#define Ch(b, c, d)  ((b & c) ^ (~b & d))
#define Maj(b, c, d)  ((b & c) ^ (b & d) ^ (c & d))
#define ROTR(x, n) (_mm_srli_epi32(x, n) | _mm_slli_epi32(x, 32 - n))
#define SHR(x, n)  _mm_srli_epi32(x, n)

但那是在 -O0 下。

But that's with -O0.

来源
Bitcointalk 原始链接 ↗ 记录编号 SN-1910

阅读字号

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