Patent ID: 8667256

Claim:
A computer-implemented method for managing divergent threads in a thread group executing on a multi-threaded processing unit, the method of comprising: fetching a program instruction specified by an active program counter associated with the thread group; determining that the program instruction is a branch instruction; determining whether the branch instruction is a break instruction or a return instruction; and if the branch instruction is a break instruction or a return instruction, then updating an active mask associated with the thread group, or if the branch instruction is not a break instruction or a return instruction, then: determining that the branch instruction is a conditional branch instruction associated with a condition, and pushing at least one token that includes a divergence token into a token stack associated with the thread group, wherein each token pushed into the token stack includes a mask indicating the state of each thread in the thread group prior to the execution of the branch instruction, the state of each thread subsequent to the execution of the branch instruction is determined based on the type and configuration of the branch instruction, and a program counter associated with the divergence token is set to a not-taken program counter; and updating the active program counter associated with the thread group, wherein the manner in which the active program counter is updated depends on the type of the branch instruction, wherein the thread group includes a plurality of threads.