Sign in to follow this  
Vortez

Hash on gpu?

Recommended Posts


Hi, i just wanted to know if it's possible to compute a hash on the gpu ... in an efficient manner?
Nope. Hashes are mostly sequential in nature. Fetching the result of stage N as input to stage N+1 is common. In some cases, steps might have side-effects which might force you to run them fully sequentially.

This implies hashing generic data blobs cannot saturate the GPU ALUs.

 

What you can do however is to use a merkle tree - an array of hashes of partitions - and them somehow combine them.  Here are some pictures.

 


If so, how, how would i retreive the result?
You just read a buffer as usual.

Note however for game related purposes (of identifying resources or similar) there's likely not much of a point in transferring the data over PCIex. For some small data the latency involved can probably negate the benefits. On iGPU we might talk but in general I would second NightCreature' suggestion.

 


Take a look at some of the bitcoin mining software out there, you might find some that can still hash on GPU. There should be some on github and the like

FYI, GPU mining is still very much around albeit not in BTC specifically. They're not generic hashers anyway as they hash 80-byte blocks which change value according to a set of rules. Furthermore, it is very common to confuse the property of the hash itself with the properties of the (parallel) scanHash operation. In short, I wouldn't suggest to take a look at them, the host code is particularly ugly.

 

Note: I am the author and maintainer of one of such apps. Of course mine is... fairly different.

Share this post


Link to post
Share on other sites

The question I am asking myself is why do you want to do this on the GPU. If its just to have a resource name changed in a hash the CPU will do fine for that.

 

Hashes aren't used exclusively for mapping resource names to numeric identifiers...

Share this post


Link to post
Share on other sites

 

The question I am asking myself is why do you want to do this on the GPU. If its just to have a resource name changed in a hash the CPU will do fine for that.

 

Hashes aren't used exclusively for mapping resource names to numeric identifiers...

 

In the context of gaming however that is the most common use, I know that hashes are used for other things too.

Share this post


Link to post
Share on other sites

Maybe I'm mistaken, but isn't it actually the case that GPUs aren't particularly good for calculating the hash, they are serial after all? GPUs are great for crypto-currency mining and password cracking because those things involve computing (possibly) the entire set of all hashes and looking for one among them that satisfies given properties (e.g. in bitcoin, a hash which has the correct number of leading zero bits for the current difficulty). You might want to calculate a hash of data already on the GPU, in which case its probably faster to do it there, but its probably not a win to shuffle data to the GPU just to take any old hash (but probably if you want to generate one with special properties).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this