JayDDee / cpuminer-opt

Optimized multi algo CPU miner
Other
775 stars 545 forks source link

Zen3 support #274

Closed JayDDee closed 4 years ago

JayDDee commented 4 years ago

Cpuminer-opt fails to compile for zen 3. In addition feature reporting of VAES may be incorrect.

There is no compiler support for znver3 yet so testing will be done using "-march=znver2 -mvaes".

Due to AMD's implementation of VAES in Zen3 it can no longer be assumed that a CPU with VAES also includes AVX512. Zen3 implements 256 bit AES without the need for AVX512. The Intel spec states that AVX512VL is required. This effectively splits VAES into 2 sub-features, VAES256 and VAES512 that can be implemented independantly of each other.

The Intel model assumes all new 256 bit SIMD instructions not previously available with AVX2 require AVX512VL. AMD chose not to follow that model and backported 256 bit VAES without any AVX512.

There exists some code in cpuminer-opt that assumes AVX512 is present if VAES is present. This needs to be changed to explicitly check for both. These changes are to fix compilation errors as well as feature reporting. VAES without AVX512 will be listed for Zen3 CPUs and Zen3 builds but not used by an algo unless AVX512 is also supported by the algo.

There are no plans to add and 256 bit AES support, 2 way hashing just isn't worth the effort.

There are also no plans to build a Zen3 Windows binary

JayDDee commented 4 years ago

Plans change.

It seems AMD improved AVX2 with Zen2 and VAES also benefits in Zen3.

v3.15.1 will compile on Zen3 with "-march=znver2 -mvaes" but with no actual 256 bit VAES code to compile, therefore no performance change.

The following release will implement 256 bit VAES for all algos that currently have 512 bit VAES. A Zen3 Windows binary will also be produced.

JayDDee commented 4 years ago

v3.15.2 includes AVX2+VAES optimization for x16*, x17, sonoa, xevan, x21s, x22i, x25x, allium.