JayDDee / cpuminer-opt

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

Double size of array breaks hash #221

Closed JayDDee closed 4 years ago

JayDDee commented 4 years ago

https://github.com/JayDDee/cpuminer-opt/blob/c65b0ff7a6d982b5faca465e01f27ac4af4901e2/algo/x22/x25x-4way.c#L91

In preparation for AVX512 for x25x buffers need to be expanded. Doubling the size of the array above, with no other changes, breaks the hash. 100% reproduceable.

Some things I've tried:

Local or static still fails.

Different syntax: A, A[0], &A[0]. All produce the same address but not necessarilly the same behaviour. Changing all refs to &A[0] didn't immediately break the hash but it broke after another trivial preparatory change, ie no real AVX512 code yet.

Tried on 2 systems GCC7 and GCC9.

I've never had this kind of problem before but this may be the first time with a 2D array.

Some additional things I may try.

Flattening the array to 1D and using pointer arithmetic to emulate 2D.

Breaking up the toplevel of the array into discrete buffers and referencing each buffer directly instead of through an aray index.

JayDDee commented 4 years ago

Doubling the size of the 2d array without doubling the size of the data blocks created gaps when the entire array needs to be contiguous. Expanding the size must be coordinated with doubling the usage. This will make it more difficult to do incremental testing.

JayDDee commented 4 years ago

Solved. The array size increase broke the contiguity of the bufffers for the blake2s super round.