Thread Divergence

I have a question regarding thread divergence: According to the documentation, every time a thread diverges, it has to be run separately from other threads. I get that and it makes sense. My question is, let’s say half of my threads diverge together down the same execution path.

Does that mean that the threads will now run as two groups or will it be what’s left of the individual group, plus a bunch of individual threads, each executed separately, that diverged?

The latter makes no sense to me, but the documentation is unclear and I’m just curious.

I guess my question is, do divergent threads get grouped to run together if they diverge together.



Don’t think threads, think warps. If your first 32 threads take one code path, and the next 32 threads another, you have no divergence.

Thread (0 - 31)+N*32 are always in the same warp.

If you have divergence within a warp, that warp runs both code paths, with the appropriate threads set inactive.

Ok, I get it. Thanks.