BRK : Break
PBK : Pre-Break

Format:

SPA 5.0:
                   PBK   #OffsetS24              {&req_6}   {?sched}           ;   
                   PBK   c[#BankU05][#AddrU16]   {&req_6}   {?sched}           ;   // This form is not patchable and is deprecated   

        {@{!}Pg}   BRK   {CC.test}               {&req_6}   {?sched>=?WAIT5}   ;   

 .test:  { .F,      .LT,     .EQ,     .LE,      .GT,      .NE,      .GE,   .NUM,     Signed numeric tests
           .NAN,    .LTU,    .EQU,    .LEU,     .GTU,     .NEU,     .GEU,  .T,       Signed or Unordered tests 
           .OFF,    .LO,     .SFF,    .LS,      .HI,      .SFT,     .HS,   .OFT,     Unsigned integer tests
           .CSM_TA, .CSM_TR, .CSM_MX, .FCSM_TA, .FCSM_TR, .FCSM_MX, .RLE,  .RGT  }   Clip State Machine tests

Description:

Conditional break from a loop.

PBK:

Set program pre-break synchronization point.

This instruction is used before (and outside) a potentially divergent BRK (break) located inside a loop. It specifies the target address to resume execution following the BRK.

The target address is relative to the program counter of the instruction following the PBK instruction and is a signed byte address with the two lsbs being 0.

The PBK instruction results in a token being pushed onto the CallReturnStack (CRS) but does not alter the program flow, execution continues normally to the next sequential instruction.

BRK:

The break condition is based on a predicate AND condition code bits. To just break on predicate, use CC.TRUE. To just break on CC, use PT.

When all active threads have executed a BRK, the stack will be unrolled until a matching PBK token is found. The PBK stack entry will be popped from the stack, and execution will resume at the address specified by the PBK, with the active mask updated according to the mask in the PBK. Thus this is a synchronizing event eliminating the need to bracket loop bodies with SSY/.S instructions if all active threads eventually exit the loop via a BRK. Breaks can be executed within arbitrarily nested if-then-else blocks inside a loop.

A BRK without a matching PBK will result in an error.

Examples:

// pseudo-code example
while (TRUE) {
  R4 *= 2.0f;
  if (R4 >= 1024.0f)
    break;
  }

// in assembler could be:
  PBK LABEL0;

LABEL1:
  FMUL32I R4,R4,2.0f;
  FADD32I RZ.CC,R4,-1024.0f;
  BRK     CC.GE;
  BRA     LABEL1:

LABEL0:

Back to Index of Instructions