3 ms·
It's useful to think of GPUs as CPUs with low core frequency but incredibly wide SIMD instructions. They are very good at doing the exact same instructions in p
by wongarsu 5y ago
It's useful to think of GPUs as CPUs with low core frequency but incredibly wide SIMD instructions. They are very good at doing the exact same instructions in parallel (apply this formula to 4 million pixels), they are fairly bad at anything that includes branches or loops (doesn't fit the SIMD model), or random memory access (only so much memory bandwidth to go around between all the cores).
That makes GPUs generally good at arithmetic tasks, but horrible at control or logic tasks since those usually involve lots of branching.
- sampo 5y ago> They are very good at doing the exact same instructions in parallel (apply this formula to 4 million pixels) In numerical fluid mechanics, you rather want to apply the same formula to the nearest 27 (3x3x3) or 125 (5x5x5) pixels in the 3-dimensional array. And then store the result to another 3-dimensional array. Or maybe for calculating a value in a 3d array A, you need to apply a formula that looks at the nearest 27 values in both array A itself and also in another 3d array B. Maybe also C.
- dahart 5y agoThis is true for pixels too; think about a median or blur operation, or a 2d fluid sim, you might gather and combine the nearest NxN pixels. 2d and 3d are nearly identical, the main difference is just indexing. Parent comment was talking about the single formula that produces the output value written to the cell, which as you say might well involve reading inputs from many nearby cells. Fluid mechanics can also be thought of as a single formula per output cell. (And normally it’s most natural to organize GPU threads so that they are 1:1 with output cells.)