I'm processing items in a grid, depending on the item's type a different type of computation/function needs to be performed. But I've read branching is a very bad thing to do between workitems doing the same thing. To circumvent this I could split the grid into a grid per type (I would only need two in this particular case)...
What would be better in this case; Leave the branching in there, or making two grids one for each type? I understand this depends on what happens inside the branch (computational bound) vs how big the grids will be (memory/latency bound).
Are there some ground rules to follow for these kinds of decisions or is there consensus which one is better in general?
Edit: The (spatial) grid is not sparse as is usual with spatial grids, but a dense array (no empty elements) of structs (~200 bytes per struct) which will hold up to about 500.000 elements.
I fill this array from another source, using that source I put either triangles or linesegments in there.
Then using this grid, i'll need to do either linesegment/linesegment or linesegment/triangle collision detection. So the question is whether it will be more efficient to fill two seperate arrays (for sake of argument lets say 250.000 elements x 200 bytes) in this case and have workitems do batch computations for only line/line or line/triangle.. or have one big one of 500.000x200 bytes and have each workitem figure out what computation to perform given a type.