sqrt:
sqrt is the ratio of the number of floating point square root instructions to the total number of floating point instructions.
Classifying sqrt:
sqrt can be classified into low, medium or high as follows:
Bucket | Condition |
---|---|
Low |
The region of code contains no sqrt instructions.
OR
1 or fewer operations out of every 4 floating point instructions is a sqrt instruction.
|
Medium | 1 out of every 2 floating point instructions is a sqrt instruction. |
High | 2 or more instructions out of every 3 floating point instructions is a sqrt instruction. |
Example 1:
Consider the following code:
for (i=0; i<1000; i++) result[i] = sqrtf(arrayOne[i]) * sqrtf(arrayTwo[i]);2 out of the 3 floating point instructions in this code sample are sqrt instructions. Therefore, we can estimate that sqrt will be a high value.
Example 2:
Let's look at another example:
for (i=0; i<1000; i++) x1 = arrayOne[i].x; y1 = arrayOne[i].y; z1 = arrayOne[i].z; x2 = arrayTwo[i].x; y2 = arrayTwo[i].y; z2 = arrayTwo[i].z; result[i] = sqrtf((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));This region of code contains a significantly greater number of floating point instructions (about 12) and sqrtf() is just one out of a large number. Therefore, we can estimate that sqrt will be low.