[SPIR/PTX] Divergence analysis for BasicBlocks

Hello,

It seems to me that our current DivergenceAnalysis does not save which BasicBlocks may suffer from divergent control. Am I correct?

I want to modify our DivergenceAnalysis to add a “bool isControlDivergent(BasicBlock*) const” method and save in the divergence propagator the basicblock that are divergent. I am not sure that is entirely correct, if you have input on that please let me know.

That being said, to ease my debugging process I want to introduce a -dot-divergence pass that dump the cfg with divergent basicblocks in red. I was wondering if our dot printer is flexible enough to allow me to also print in color the SSA variables that are divergent.

Thanks.

What would be the definition of “isControlDivergent(BasicBlock*)”; the complementary of “allActive(BasicBlock*)” – blocks known to execute all lanes, whenever reached? Note the (distinct) term “rewire targets” that Ralf Karrenberg used in his thesis.

Hello,

Yes? Where is allActive defined, I couldn’t find it.

Basically, a BB is control divergent if it’s execution depends on a branch that itself depends on a divergent ssa value.

My current strategy is to store all the BB in the InfluenceRegion (see the DivergencePropagator) of a divergent branch.

Basically, I want an over-approximation of isControlDivergent (or an under approximation of allActive) so that I can introduce barriers, there, safely.

Understood; barriers can only be introduced in places where whenever one lane arrives all are sure to follow.

Yes? Where is allActive defined, I couldn’t find it.

See “Definition 12 (Static All-Active Program Point)” in subsection 5.6.11; which also provides one way of computing it, based on knowing which branches are divergent.

This btw is analogous to LoopAccessInfo::blockNeedsPredication(); which is admittedly overly conservative due to the (current) nature of its clients.