5 ms·
Not a computer engineer either, but I did do some GPGPU in college (~6 years ago). Notably, branching on a flag f on the GPU was so slow that most of the time
by ThePadawan 7y ago
Not a computer engineer either, but I did do some GPGPU in college (~6 years ago).
Notably, branching on a flag f on the GPU was so slow that most of the time it was faster to (manually) compute both branches b1 and b2 and then calculate the result as r = f * b1 + (1-f) * b2 (where f is either 0 or 1).
- hellofunk 7y agoThis is pretty awesome.
- sv_h1b 7y agoGPUs are designed to do massive parallel computations which all branch one way and don't have much (any?) branch prediction logic. You trade it off with increased code size which might spill the cache but for small tight loops not exceeding the cache line/ size it would still be a good win.
- ScottFree 7y agoWould there be any benefit to adding branch prediction logic to a GPU?
- rdc12 7y agoYou would probably get some benefit on a per CUDA core basis, but the extra space required would mean less CUDA cores, overall it would probably be a net loss on problems well suited to GPU acceleration
- vardump 7y agoJust like you can do on x86/ARM SIMD. It often pays to compute both sides and mask out the undesired results.