-
gpus are only good at workloads that can be parallelized (hundreds of parallel threads). if there is a sequential execution flow, gpus can't show their performance and will be slower than cpus
quick example .. imagine a large excel sheet with a number of rows (the money you spent on drinking, partying and getting laid) that you want to sum up.
one way is to go through the rows one by one and add each row to the previous result -> sequential, like it would run on any CPU today, this will take you N steps for N rows (actually N-1 but lets keep it simple).
on a GPU you could parallelize this and launch a large number of threads that add up groups of two rows each first, like (1+2=a, 3+4=b, 5+6=c..), all of those additions are done at the same time in parallel on the gpu in a single step. once that is done you sum up a+b=a1, c+d=a2 etc... repeat until you have only two numbers left to add together and you get the final result. in total this will take you log2(N) steps. (e.g. for 256 rows -> log2(256) = 8 steps only)
for a small number of rows there won't be much difference and the higher clock speed of the CPU will still outweigh small gains. but once you increase the number of rows you can clearly see what a huge difference this make. (yes this is simplified, you do not have an infinite amount of execution units)
however, note how much more complex the second example is. most programmers today have coded for their whole life like example 1. now they are supposed to switch to example 2...
Last edited by W1zzard; 05-27-2008 at 03:18 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks