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 Oct (GMT+03:00) Beirut change
|14:00 - 14:30|
|14:30 - 15:00|
Lucas KramerUniversity of Minnesota, Ted KaminskiUniversity of Minnesota, Eric Van WykUniversity of Minnesota, USADOI Pre-print
|15:00 - 15:20|
Amir ShaikhhaUniversity of Oxford