• No se han encontrado resultados

Es necesario ampliar el mercado regional

The vectorization of statements mainly affects the generation of vector masks that turns simple vectorization into predicated vectorization (see Section 3.4.2). Vec- tor masks are synthesized attributes generated by statements that may change the control flow of the execution of each vector lane within the same vector reg- ister. Some of these nodes are nested loops, if-then-else statements, continue and break statements, goto statements and return statements. Consequently, this vec- tor mask attribute is used in the vectorization of expressions nested in this kind of statements (see Section 3.5.6). The generation of masks is inspired in the work of Shin Jaewook [140], later extended by Karrenberg and Hack [80, 79].

Currently, our algorithm only supports the generation of predicated execution triggered by for-loop, while-loop, if-then-else, break and return statements. The al- gorithm uses a stack to store the vector mask used for the vectorization of each basic block in the code [50]. This stack is initialized with a mask that has all the vector lanes enabled. Therefore, when one of the previous statements may produce a di- vergence within the vector lanes of a vector register, the top of the stack is updated with a new mask. This mask is the result of merging the current mask in the top of the stack and the new mask generated by the statement that causes the divergence. This new mask in the top of the stack is then used to vectorize the statements and expressions nested in the statement causing the divergence. If there are multiple independent branches of execution, such as in an if-then-else statement, the top of the stack is updated with the corresponding mask for each particular branch. Once all the branches have been executed, their associated masks are popped from the top of the stack, recovering the previous mask before the branching statement. It is possible that some masks affect the execution of code outside of their initial scope. For example, this is the case of break or return statements as they disable those vector lanes that reach them for the remaining execution of the loop body and the function body, respectively. In these cases, the mask of the previous scope is merged with the mask generated by these statements to propagate their effect.

Nested Loop Statement

In outer loop vectorization scenarios [111], variables that are part of the loop con- trol of inner loops may not be uniform in the context of the iterations of the outer loop. If this happens, each vector lane could have different values for the induction variable of the inner loop and different stop conditions. This requires that the code of the control of the inner loop has to be specially vectorized, including the induction variable and the condition of that loop. Vectorizing the condition of the loop results in a vector mask that enables and disables those vector lanes that have not already reached their stop condition and those which have already done it, respectively. This mask will be used for the vectorization of the statements and expressions of the loop body of that loop.

3.5. Vectorization Algorithm 43

If-then-else Statement

If-then-else statements may need from predicated vectorization when the condition of the statement is not stated as uniform, i.e., vector lanes may have different re- sult values in the evaluation of the condition. For these cases, the vectorization algorithm will generate two vector masks: one for the execution of the if branch and another one for the else branch if this branch exists. The mask of the if branch will have enabled those vector lanes that evaluate the if-then-else statement con- dition to true. The mask of the else branch will have the complementary value of the mask used for the execution of the if branch. If the mask that arrives to the if-then-else statement had vector lanes disabled, the lanes would be also disabled in both masks of the if-then-else branches.

Break Statement

Vectorization of loops that contain break statements is only supported when the break statement does not introduce a control flow dependence across vector lanes but the it affects the control flow of each vector lane independently. The latter scenario normally happens in outer loop vectorization where the break statement is within the inner loop. Listing A.8 in Appendix A can illustrate both scenarios. Vectorizing the inner loop (line 5) would be an example of the first scenario not supported by our infrastructure. Vectorizing the outer loop (line 33) would be an example of the second scenario that can be vectorized with our tool.

Focusing on the supported case, the vectorization algorithm generates a vector mask that disables all the vector lanes that execute that break statement. This mask is used to execute the vector instructions that precede the break statement and to update successor masks.

Return Statement

Return statements are exit points of a function code. Function codes may have multiple return statements. These exit points mean the end of the execution for those vector lanes that reach them.

The vectorization algorithm generates a mask for return statements that are guarded by non-uniform conditions. These masks are aimed at disabling vector lanes that reach these return statements. This mask is propagated throughout the subsequent code, even outside of the scope of the return statement, as those vector lanes will not execute any other vector instructions in that function.

For those functions that return a vector return value, the vectorization algo- rithm declares an auxiliary vector value to store the returning value of those vector lanes that are disabled by a return statement at any point of the function code. At the end of the function code, this auxiliary vector value is returned with the corresponding return value of each vector lane.

1: functionVECTORIZE ASSIGNMENT(assig)

2: if IS NOT UNIFORM(assig.lhs) orIS NOT UNIFORM(assig.rhs) then

3: ifIS LINEAR(assig.lhs) then

4: returnVECTORIZE LINEAR UPDATE(assig.lhs) 5: else ifIS ARRAY(assig.lhs) then

6: returnVECTORIZE MEMORY WRITE(assig.lhs) 7: else ifIS VARIABLE REFERENCE(assig.lhs) then

8: returnVECTORIZE VEC REG ASSIGNMENT(assig.lhs)

9: end if

10: else

11: return assig . Kept Scalar

12: end if

13: end function

Figure 3.7: Some of the rules for the vectorization of an Assignment node

Documento similar