Control Flow Vectorization for ARM NEON

Control Flow Vectorization for ARM NEON

Control Flow Vectorization for ARM NEON Angela Pohl, Nicolas´ Morini, Biagio Cosenza and Ben Juurlink Technische Universitat¨ Berlin Berlin, Germany fangela.pohl, cosenza, [email protected] Abstract produce results that are not portable when targeting dierent In- Single Instruction Multiple Data (SIMD) extensions in processors struction Set Architectures (ISAs). at is why auto-vectorizers enable in-core parallelism for operations on vectors of data. From have been added to compilers to perform this task automatically. the compiler perspective, SIMD instructions require automatic tech- As of today, a compiler can contain multiple vectorization passes, niques to determine how and when it is possible to express com- targeting loops and straight line code. During compilation, the putations in terms of vector operations. When this is not possible vectorizer has to nd a valid code transformation which can be automatically, a user may still write code in a manner that allows mapped to the underlying ISA. In addition, the transformation has the compiler to deduce that vectorization is possible, or by explicitly to be deemed benecial, i.e. the added overhead should not eace dene how to vectorize by using intrinsics. the performance gain. is work analyzes the challenge of generating ecient vector Auto-vectorization has made tremendous improvements in the instructions by benchmarking 151 loop paerns with three com- last decades, with dierent compiler techniques addressing dif- pilers on two SIMD instruction sets. Comparing the vectorization ferent forms of parallelism (e.g. Superword-Level Parallelism for rates for the AVX2 and NEON instruction sets, we observed that straight-line code vectorization) as well as increasingly complex the presence of control ow poses a major problem for the vec- code paerns. However, the success of vectorization does not purely torization on NEON. We consequently propose a set of solutions depend on the compiler and the code to be vectorized. e target to generate ecient vector instructions in the presence of control ISA plays a key role by providing instructions that enable ecient ow. In particular, we show how to overcome the lack of masked vectorization as well. load and store instruction with dierent code generation strategies. is paper starts with a quantitative and qualitative analysis of Results show that we enable vectorization of conditional read op- state-of-the-art techniques provided by production compilers (GCC, erations with a minimal overhead, while our technique of atomic ICC, and LLVM) on two dierent SIMD ISAs, i.e. Intel’s AVX2 and select stores achieves a speedup of more than 2x over state of the ARM’s NEON. Investigating 151 loops with a broad range of code art for large vectorization factors. paerns, our numbers show that the compilers do not perform ade- quately on the processor supporting NEON, specically for loops CCS Concepts •Computer systems organization ! Single that contain control ow. It is a genuine example of a code paern instruction, multiple data; Embedded systems; •So ware and whose vectorization can be greatly enhanced by the availability of its engineering ! Compilers; specic instructions, e.g., masked load and store. Unfortunately, ACM Reference format: these instructions are missing in the NEON instruction set, there- Angela Pohl, Nicolas´ Morini, Biagio Cosenza and Ben Juurlink fore limiting the vectorization in existing production compilers. 2018. Control Flow Vectorization for ARM NEON. In Proceedings of Consequently, we propose two techniques to enable the automatic International Workshop on Soware and Compilers for Embedded Systems, vectorization of conditional load and store operations, increasing Germany, St Goar (SCOPES’18), 10 pages. the vectorization rates for NEON platforms. DOI: 10.1145/nnnnnnn.nnnnnnn e contributions of this paper are: 1 Introduction • a detailed quantitative and qualitative analysis of the vec- torization rate and quality of GCC, ICC, and LLVM on a Code vectorization is an optimization technique to exploit data test benchmark of 151 loops, targeting AVX2 and NEON level parallelism (DLP). Starting in the 1970s, vector processors platforms grouped together data independent instructions and applied vector • an automatic approach to vectorize conditional load opera- operations instead of scalar ones. Depending on the Vectorization tions where compilers currently fail due to the inability to Factor (VF), i.e. the number of data elements that can be merged assume the safety of memory accesses into one vector, vectorization can reach high speedups, especially • an automatic approach to vectorize conditional store opera- on codes exposing DLP in loops. tions, resulting in an improved code performance compared However, the task of producing ecient vectorized code is chal- to the state-of-the-art scalar predicated store currently em- lenging. Manual approaches, where the programmer directly indi- ployed in compilers. cates which vectorial instruction to use, require huge eorts and Permission to make digital or hard copies of all or part of this work for personal or Both vectorization techniques can be applied to ARM NEON plat- classroom use is granted without fee provided that copies are not made or distributed forms, as well as other ISAs that do not support masked load/store for prot or commercial advantage and that copies bear this notice and the full citation instructions natively. on the rst page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permied. To copy otherwise, or republish, e paper is organized as follows: in Section 2 we discuss cur- to post on servers or to redistribute to lists, requires prior specic permission and/or rent options to handle control ow for vectorization. In Section a fee. Request permissions from [email protected]. 3, we show the results of our analysis of the most popular C/C++ SCOPES’18, Germany © 2018 ACM. 978-x-xxxx-xxxx-x/YY/MM...$15.00 compilers’ auto-vectorizers. Aerwards, we describe the imple- DOI: 10.1145/nnnnnnn.nnnnnnn mentation of conditional load/store operations for the state of the SCOPES’18, St Goar, Germany A. Pohl et al. Table 1. Overview of compiler ags and versions gcc 7.2.0 LLVM 5.0.0 icc 18.0.1 Vectorized Setup -std=(c11|c++11) -O3 -ffast-math -march=native -std=(c11|c++11) -Ofast (-xavx|-xavx2) Added for Scalar Setup -fno-tree-vectorize -fno-tree-slp-vectorize -fno-vectorize -fno-slp-vectorize -no-vec Added for Reports -fopt-info-vec-all=report.lst -Rpass=loop-vectorize -mllvm -qopt-report=1 -qopt-report-phase=vec -debug-only=loop-vectorize,SLP art, as well as our new proposed solutions in Section 4. In Section 5, trees [10], irregular data structures [19], or irregular strides [12]. we show the performance improvements achieved by our proposed Aempts to support control-ow have been investigated also for approaches, and the paper is concluded in Section 6. SLP vectorization [20]. An alternative approach is the design of beer programming models that addresses the code generation of such paerns (an 2 Related Work overview of programming models for vectorization has been con- Manually programming SIMD units with either intrinsics or in ducted by Pohl et al. [17]). A particular interesting model is pro- assembly language is an error prone and time consuming activity, vided by the ispc compiler [16], which implements special features whose output highly depends on the target architecture. A more for control ow: masking is handled with an explicit execution productive and portable alternative is to rely on compiler-based mask and keywords (e.g., unmasked); special support for coherent automatic vectorization (auto-vectorization), which tries to replace control ow statements (e.g., the cif keyword); an ecient way scalar instructions with vectorial ones. Auto-vectorization mainly to handle data races within a gang (a group of program instances relies on two approaches: Loop-Level Vectorization (LLV) [3] and running together): any side eect from one program instance is Superword- Level Parallelization (SLP) [13]. visible to other program instances in the gang aer the next se- LLV, used since the advent of vector processors [22], is the pre- quence point in the program (for vectorization, this semantic is ferred technique in today’s compilers due to the potentially low more ecient than OpenCL’s barrier()). vector utilization in SLP [18]. In a related study from 2011, Maleki Ecient vectorization also depends on the ISA design. Intel et al. [14] analyzed the state of the art of the gcc, icc, and XLC vec- vectorial instructions [8], for instance, provide masked load and torizers with three dierent benchmarks. A second study by Mitra store [9], which drastically simplify the generation of vector code et al. from 2013 [15] performed a comparison of performance gains in control ow. e Scalable Vector Extension (SVE) [21], a novel on platforms with SSE and NEON SIMD extensions. However, the instruction set designed for HPC workloads on ARMv8-A, empha- authors did not utilize auto-vectorizers, but manually vectorized sizes the importance of predication for vectorization with dedicated the codes. predication registers to eciently handle active and inactive lanes An important aspect of LLV is the generation of ecient vector of non-xed-length vectors. Unfortunately, the current NEON in- instructions in the presence of control ow. Control ow may di- struction set [4] does not have similar features, and is lacking the verge because a condition might be true for some scalar instances masked load and store operations present in AVX2. is work starts and false for others, therefore requiring specic solutions such as from the observation that this is a major problem for vectoriza- masking. Allen et al. [2] rst worked on solving control ow vectori- tion and requires dierent code generation strategies in order to zation by converting control ow dependences to data dependences. produce ecient vectorized code.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us