Vectorization of Loops with Conditional Operations by Combining Vector Masks
Abstract
The article is devoted to the problem of increasing the efficiency of vectorization for calculations on real numbers. When performing calculations, several similar scalar operations can be combined into a single vector command, significantly increasing the speed of program execution. This optimization is crucial for computational tasks of supercomputer modeling. The main object that the vectorization of calculations is aimed at is a loop with independent iterations. With a relatively simple form of the body of the considered loop, problems with vectorization, as a rule, do not arise. When complex controls, nested loops, and function calls appear in the body of the loop, the optimizing compiler often fails to cope with vectorization. However, the features of the AVX-512 vector instruction set with support of selective processing of vector data elements make it possible to vectorize loops with a body of almost arbitrary structure. This article discusses an approach to vectorization of a loop which contains conditions. The approach is based on merging of program execution paths under the appropriate predicates. A vectorized predicate is a mask for processing vector elements. Such masks are used in AVX-512 vector instructions. When vectorizing loops whose body contains complex controls, the main problem is the low density of masks of the vectorized code, which leads to decrease in performance. The article discusses methods to increase the density of vector masks and the efficiency of vector code execution. The developed methods have been tested on the progamm context of a gas-dynamic solver. Data on vectorization efficiency were obtained in vector instruction emulation mode and on a real machine (Intel Xeon Phi Knights Landing microprocessor). After applying vector code optimizations, vectorization efficiency indicators were achieved up to 0.75 in emulation mode and up to 0.47 on a real machine.

This work is licensed under a Creative Commons Attribution 4.0 International License.
Publication policy of the journal is based on traditional ethical principles of the Russian scientific periodicals and is built in terms of ethical norms of editors and publishers work stated in Code of Conduct and Best Practice Guidelines for Journal Editors and Code of Conduct for Journal Publishers, developed by the Committee on Publication Ethics (COPE). In the course of publishing editorial board of the journal is led by international rules for copyright protection, statutory regulations of the Russian Federation as well as international standards of publishing.
Authors publishing articles in this journal agree to the following: They retain copyright and grant the journal right of first publication of the work, which is automatically licensed under the Creative Commons Attribution License (CC BY license). Users can use, reuse and build upon the material published in this journal provided that such uses are fully attributed.