Language Concepts

Conditional Statements (Predication)

Unlike traditional conditional statements where logic is executed based upon the evaluation a single boolean result, conditional statements using qVar_t are evaluated in parallel. This means all cores will evalate the statement separately and step through the logic based upon the evaluation of the boolean condition.

Note

Scalar variables inside the parallel conditional statement will evaluate if any of the cores in the parallel conditional evaluate to true.

Evaluation of a qVar_t within a parallel condition

qVar_t<std::int32_t> qA = (qRow<> * Epu::coreDim) + qCol<>;  // Sequential data
debugPrint(qA, "qA");
std::int32_t c = 44;
qVar_t<std::int32_t> qB = 20;  // Entire qVar is set to 20
if(qA > 19) {
  qB = 13;  // Only locations in qB which (qA > 19) will be set to 13.
  // All other cores will remain 20.
  c = 26; // Will be set to 26 if any core within qA > 19
}
debugPrint(qB, "qB");
debugPrint(c, "c"); // Evaluates to 26.

The output of qB in the example above is shown below. Note the cores in qB are only set to 13 where locations in qA were greater than 19

// qA
------------------------------------------------------------------------------------------------
[-4]  [-3]  [-2]  [-1]   | [ 0]  [ 1]  [ 2]  [ 3]  [ 4]  [ 5]  [ 6]  [ 7]   | [ 8]  [ 9]  [13]  [11]
[ 4]  [ 5]  [ 6]  [ 7]   | [ 8]  [ 9]  [13]  [11]  [12]  [13]  [14]  [15]   | [16]  [17]  [18]  [19]
[12]  [13]  [14]  [15]   | [16]  [17]  [18]  [19]  [20]  [21]  [22]  [23]   | [24]  [25]  [26]  [27]
[20]  [21]  [22]  [23]   | [24]  [25]  [26]  [27]  [28]  [29]  [30]  [31]   | [32]  [33]  [34]  [35]
[28]  [29]  [30]  [31]   | [32]  [33]  [34]  [35]  [36]  [37]  [38]  [39]   | [40]  [41]  [42]  [43]
[36]  [37]  [38]  [39]   | [40]  [41]  [42]  [43]  [44]  [45]  [46]  [47]   | [48]  [49]  [50]  [51]
[44]  [45]  [46]  [47]   | [48]  [49]  [50]  [51]  [52]  [53]  [54]  [55]   | [56]  [57]  [58]  [59]
[52]  [53]  [54]  [55]   | [56]  [57]  [58]  [59]  [60]  [61]  [62]  [63]   | [64]  [65]  [66]  [67]
------------------------------------------------------------------------------------------------
// qB
------------------------------------------------------------------------------------------------
[20]  [20]  [20]  [20]   | [20]  [20]  [20]  [20]  [20]  [20]  [20]  [20]   | [20]  [20]  [20]  [20]
[20]  [20]  [20]  [20]   | [20]  [20]  [20]  [20]  [20]  [20]  [20]  [20]   | [20]  [20]  [20]  [20]
[20]  [20]  [20]  [20]   | [20]  [20]  [20]  [20]  [13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]
[13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]  [13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]
[13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]  [13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]
[13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]  [13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]
[13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]  [13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]
[13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]  [13]  [13]  [13]  [13]   | [13]  [13]  [13]  [13]

Additionally c in the example above evalutes to 26 since there was more than 0 cores in the conditional statement that evaluated to true.