ifdefelse / ProgPOW

A Programmatic Proof-of-Work for Ethash. Forked from https://github.com/ethereum-mining/ethminer
GNU General Public License v3.0
257 stars 84 forks source link

KISS99 optimization #21

Closed chfast closed 5 years ago

chfast commented 5 years ago

The KISS99 used in ProgPoW operates on 32-bit unsigned types. But in many cases we are using only 5 bits of the result. Maybe it can be implemented with lower precision (e.g. 24-bit multiplication).

ifdefelse commented 5 years ago

The low-precision usage of KISS99 is on the scalar path and always executed on the CPU. CPUs don't have 24 bit multipliers, so the choices is 16 or 32 bit. Dropping down to 16 bits is a very small value for a random period and also likely would have no performance improvement.

When KISS99 is called within fill_mix it's called per-lane on the GPU or could use SSE intrinsic on the CPU. That usage requires all 32 bits.

chfast commented 5 years ago

On the other hand, can we more bits of KISS99 output to optimize CPU performance? I can do benchmarks of this.

E.g. for PROGPOW_CNT_MATH we need only 18 (5 + 5 + 4 + 4) bits of randomness (ignoring uniform distribution of random math selection). It is enough to take single KISS99 random number.