A Stage-Polymorphic IR for Compiling MATLAB-Style Dynamic Tensor Expressions
We propose a novel approach for compiling MATLAB and similar languages that are characterized by multi-dimensional arrays with dynamic shapes and element types. We stage an evaluator for a subset of the MATLAB language using the Lightweight Modular Staging (LMS) framework to produce a compiler that generates C code. But the first Futamura projection alone does not lead to efficient code: we need to refine the rigid stage distinction based on inferred type and shape information to remove costly runtime checks.
To this end, we introduce a stage-polymorphic data structure, that we refer to as metacontainer, to represent MATLAB tensors and their type and shape information. We use metacontainers to efficiently ``inject'', in a high-level intermediate representation (IR) of a MATLAB program, constructs for inferring shape and type information.
Once type and shape information are inferred, metacontainers are also used as the primary abstraction for lowering the computation, performing type, shape and ISA specialization. Our prototype MATLAB compiler MGen produces static C code that supports all primitive types, heavily overloaded operators, many other dynamic aspects of the language, and explicit vectorization for SIMD architectures.
Mon 21 OctDisplayed time zone: Beirut change
14:00 - 15:30 | MetaGPCE 2019 at Ground floor conference room Chair(s): Shigeru Chiba Graduate School of Information Science and Technology, The University of Tokyo | ||
14:00 30mTalk | A Stage-Polymorphic IR for Compiling MATLAB-Style Dynamic Tensor Expressions GPCE 2019 | ||
14:30 30mTalk | Reflection in Attribute Grammars GPCE 2019 Lucas Kramer University of Minnesota, Ted Kaminski University of Minnesota, Eric Van Wyk University of Minnesota, USA DOI Pre-print | ||
15:00 20mTalk | Polymorphic Extractors for Semantic and Portable Pattern Matching (Short Paper) GPCE 2019 Amir Shaikhha University of Oxford |