Note on operations:
This feature characterizes the proportion of certain operation types in a code region. We define operations to be the binary instructions that make up a high-level instruction. For instance, consider an array access: array[i]
This instruction consists of two operations:
ctrl:
This feature is a measure of the number of control flow operations (conditional expressions like an if..else or the condition expression in a for loop).
Similar to mul, this is also measured as the ratio of the number of control flow operations to the total number of operations.
Classifying ctrl:
ctrl can be classified into low, medium or high as follows:
Bucket | Condition |
---|---|
Low |
The region of code contains no branch instructions.
OR
1 or fewer of every 8 operations are control operations.
|
Medium | 1 out of every 6 operations is a control operation. |
High | 1 or more out of every 4 operations are control operations. |
Example 1:
Consider the following code:
for (i=0; i<1000; i++) result[i] = arrayOne[i] + arrayTwo[i];This region consists of one conditional operation, the expression evaluated for the loop, i.e. i < 1000. Considering that each array operation (read or write) consists of two operations (calculating address + load/store), the control expression is executed once every 8th operation. Therefore, we can estimate ctrl to be low.
Example 2:
Let's look at another example:
for (i=0; i<1000; i++){ if(touched[i] == false) result[i] = arrayOne[i] + arrayTwo[i]; }In this example, 1 out of every 6 operations is a control flow operation and therefore ctrl can be estimated to be mid.