主权项 |
1. A method for causing thread convergence in a parallel execution environment, wherein the method is implemented by a compiler executing on a processor, the method comprising:
determining, by the compiler executing on the processor, that a control flow graph representing a first section of a program includes at least two non-overlapping paths that extend from a first divergent node to a candidate node; determining, by the compiler executing on the processor, that the first divergent node is not a dominator of the candidate node or that the candidate node is not a post-dominator of the first divergent node; identifying, by the compiler executing on the processor, an external node in the control flow graph; inserting into the program, by the compiler executing on the processor, a first instruction configured to cause a predicate variable to be set to true for a first set of threads that is to execute the external node; and inserting into the program, by the compiler executing on the processor, a second divergent node that is configured to cause the first set of threads to execute a first control flow path associated with the external node and to cause a second set of threads for which the predicate variable is set to false to not execute the first control flow path. |