Automatic Vectorization of Stencil Codes with the GGDML Language Extensions

Automatic Vectorization of Stencil Codes with the GGDML Language Extensions

Automatic Vectorization of Stencil Codes with the GGDML Language Extensions Nabeeh Jumah Julian Kunkel Researcher Lecturer Informatik Department Computer Science Department Universität Hamburg University of Reading Hamburg, Germany reading, UK jumah@informatik:uni-hamburg:de j:m:kunkel@reading:ac:uk Abstract sciences that uses stencil codes extensively to simulate pro- Partial differential equation (PDE) solvers are important for cesses on the earth surface. The modern simulation appli- many applications. PDE solvers execute kernels which apply cations are highly demanding for performance. Simulation stencil operations over 2D and 3D grids. As PDE solvers codes should optimally use the features of the hardware to and stencil codes are widely used in performance critical allow the models to run under specific time constraints. applications, they must be well optimized. Among the hardware features of the modern architectures Stencil computations naturally depend on neighboring are the vector units and the single instruction multiple data grid elements. Therefore, data locality must be exploited (SIMD) operations. Such capabilities allow the machine to to optimize the code and to better use the memory band- execute a single mathematical operation on a whole vector width – at the same time, vector processing capabilities of at once. Besides to the vectorized mathematical operations, the processor must be utilized. such architectures provide data movement instructions that operate on vectors. In this work, we investigate the effectiveness of using General-purpose language compilers can generate vector high-level language extensions to exploit SIMD and vector- instructions to handle the data movement and the mathe- ization features of multi-core processors and vector engines. matical operations. However, they require that data is in a We write a prototype application using the GGDML high- suitable layout in memory, and they recognize appropriate level language extensions, and translate the high-level code patterns. To exploit the architectural capabilities of handling with different configurations to investigate the efficiency vector operations, the structure of the data in memory should of the language extensions and the source-to-source trans- be optimal to allow the vector data movement instructions lation process to exploit the vector units of the multi-core to be used. Unit stride arrays access, where data are contigu- processors and the vector engines. ously placed in memory, and accessed with the right loop The conducted experiments demonstrate the effectiveness orders are best fit for vectorization. Therefore, transforming of the language extensions and the translation tool to gen- layouts from array-of-structures (AoS) to structure-of-arrays erate vectorized codes, which makes use of the natural data (SoA) and the alignment of these arrays is essential to use locality of stencil computations. vector instructions. Stencil computations are naturally fit- Keywords HPC, Earth system modeling, Stencil computa- ting to a SoA data structure as computations are based on tion, SIMD access to neighboring grid elements. In this paper, we discuss using high-level coding and the 1 Introduction capability to automatically generate vectorized codes from a high-level source code using source-to-source translation Stencil computations are essential for many applications in- tools. We demonstrate the capabilities on a prototype appli- cluding PDE solvers. Earth system modeling is one of the cation that solves the shallow water equations [1] developed Permission to make digital or hard copies of all or part of this work for with the General Grid Definition and Manipulation Language personal or classroom use is granted without fee provided that copies are not (GGDML) set of high-level language extensions [7] according made or distributed for profit or commercial advantage and that copies bear to the source-to-source translation process suggested in [6]. this notice and the full citation on the first page. Copyrights for components A tool translates the GGDML code and applies certain opti- of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to mization procedures driven by user-provided configuration redistribute to lists, requires prior specific permission and/or a fee. Request files. permissions from [email protected]. One important feature of the mentioned translation pro- WPMVP’19 , February 16, 2019, Washington, DC, USA cess is the flexible way to configure the memory layout by © 2019 Association for Computing Machinery. expert users, which gives them full control on the place- ACM ISBN 978-1-4503-6291-7/19/02...$15.00 ment of the elements in memory. This allows the users to https://doi:org/10:1145/3303117:3306160 1 WPMVP’19 , February 16, 2019, Washington, DC, USA Nabeeh Jumah and Julian Kunkel choose the data layout that enables compilers to use vector was used within YASK [11] to improve the use of the mem- operations efficiently. ory bandwidth and the vector units of the Xeon and the The main contribution of this work is the extension of Xeon Phi processors. YASK provides a DSL to describe sten- the translation process by applying user-guided loop trans- cil computations; it then applies the vector folding technique formations that tune the access within loops to match the automatically and generates optimized codes for specific memory layout in order to achieve optimal vectorization. The processor families. idea is to use the right combinations of memory layout and Our work differs from related work. While we use DSL loop structure based on the semantics provided by GGDML concepts to describe stencil computations, we use a set of lan- from the source code and the provided user configuration. guage extensions, which represent an addition to a general- purpose language. We use the GGDML set of language exten- This paper is structured as follows: First, we discuss re- sions described in [7]. Instead of using DSL compilers, which lated work in Section 2. Next, in Section 3, we discuss the handle static grammars of DSLs, we use a flexible source- methodology that we use for this work. The experimental to-source translation technique described in [6] which can results are presented in Section 4. Finally, the work is con- be configured and extended by experts and users. An im- cluded in Section 5. portant feature of GGDML and this translation technique is the adaptability and extensibility of the language according 2 Related Work to the domain or the application needs, and the flexibility Efforts to exploit vector units and vector instructions evolved of the translation tool to handle the modifiable language from manual optimization to automatic tool-aided solutions, extensions. With the tool, we are able to generate optimized and to vectorize data with multiple dimensions. codes for different architectures and configurations. Data layout and loop transformations: A data layout 3 Methodology transformation technique to solve stream alignment con- flict in stencil computations is presented in[4]. Again data The approach pursued in this paper is as follows: Based on layout and other loop transformations were used to optimize the GGDML iterator semantics, we extend the translation a set of high order finite difference kernels in[12] to support process by transforming the internal data structure that de- vectorization. scribes the loop structure allowing to generate variants of loop structure and order with memory layout transforma- tions (see Figure 1). Autotuning and DSLs: Besides to the manual optimization of the stencil codes to exploit the vectorization capabilities This approach is then evaluated: of the underlying hardware, other techniques were explored • We develop a prototype application to solve the shal- including autotuning and domain-specific languages (DSLs). low water equations [1] using the GGDML language An autotuning technique was proposed in [3] to optimize extensions. stencil computations. In this work, the authors developed • Initial configuration files to generate codes for the a set of optimization strategies, and an autotuning environ- architectures of multi-core processors and vector en- ment to select a strategy with the right parameters to mini- gines are prepared. mize execution time. Autotuning was used in [8] to generate • We added the necessary information to the initial con- optimized codes based on sequential Fortran 95 codes. figuration files to apply the new transformations. PATUS [2] is a code generation and autotuning frame- • Clones of the configurations are created to explore work to develop stencil computations that used autotuning alternative array stride and data placement options together with a DSL. A C-like DSL is used to describe stencils, and check the impact on vectorization. We explore and the framework generates the code using optimization three different alternatives: strategies. Another DSL, the SDSL (Stencil domain-specific – Contiguous data placement and access language), was proposed in [5] to describe stencil computa- – Array data separated by a short distance (4 bytes tions. A compiler is also presented to generate code which between two consecutive array elements) goes through an optimization process that includes vector- – Scattered data elements, where loops access data in ization. a bad order • Code is translated based on the different configura- Specialized DSLs: A more complicated

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 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