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

ProgPoW OpenCL kernel is usually built for wrong epoch #43

Closed solardiz closed 5 years ago

solardiz commented 5 years ago

As it turns out, this ProgPoW tree builds the ProgPoW OpenCL kernels using ProgPoW epoch derived back from the coarse Ethash DAG epochs. As a result, kernels are only built correctly, and the ProgPoW computation is only correct, very rarely - only when the block number is at or just after an Ethash DAG epoch. So it is correct e.g. for block 30000 and 60000, but not for 10000, 29000, 31000, nor 7000000 or 10000000. (The last two of these are block numbers I've been using for benchmarks before, thinking the computation is hopefully correct. This news partially invalidates those benchmark results on AMD cards, and CUDA vs. OpenCL comparisons on NVIDIA cards.)

The host-side code for CUDA doesn't have the same problem. I didn't check all the history, but my guess is that when ProgPoW periods lower than Ethash DAG's were introduced, only the CUDA code was updated to reflect that. OpenCL was either forgotten or left for later, without this having been documented.

I'll probably send a PR fixing this in a few days, but I thought I'd bring this up in here first in case there are any comments.

solardiz commented 5 years ago

Looks like the same problem was present for CUDA and got fixed with a51a4a5b3e325be1a24f4bccb991929d1616a666 and 8c32fa15712dbbdaa30604fb1ff5b916963751b9 on Nov 22, 2018, but no equivalent fixes were made for OpenCL.