Also, I don't see the point of saving keys that have some 0-bits prefix. It saves some kernel instructions to simply skip that check, and use the hash target itself as PoW evidence.
I don't see how checking against 0 gives anything better/worse than checking against target ?
Which kernel instructions do you skip checking against the target ? You would still have to do the CMP. Sure you can mutualize the first 32 bits to check, but then you need to check a subset of the next 32 bits and you're introducing complexity, branching, etc...
If anything checking against zero frees the compiler from the dependency to the target registers on this instruction.
Because you're doing two checks (target and zero). There's also no need to check more than a single register in the kernel itself or complicate things.
lets imagine I want all 5 zero bytes leading prefixes. I can do :
const int32 candidate[5];
const bool check = !candidate[0] && !(candidate[1] & 0xFF000000)
// Then check against the target
if I want to mutualize the target check I need something like this :
const int32 candidate[5];
if (target[0] != candidate[0]){
return; // We dont go any further
}
// Here, we mutualized the pattern check for the first int
// You still need to check the extra byte here
if (candidate[1] & 0xFF000000 == target[1] & 0xFF000000){
// handle prefix found
}
if (target[1] != candidate[1]){
return; // We dont go any further
}
Well, since your code is secret and if this snippet is part of your code, my questions are simple:
1. Do you have a GPU that produces more than 2**32 candidates (PoW or target) per launch, to make it worth complicating things like above?
2. What's the difference between proving you found 48 zeros or the first 48 bits of the target hash?
Maybe it doesn't even matter in practice, but the GPU will still execute something that I don't see the need for. In my kernel I simply check a single 32-bit limb. If it matches - handle prefix found, and let the host bother about this and that about the other bits. The hashes produced per second can be counted on one hand's fingers.