Terra: A Multi-Stage Language for Portable High-Performance Heterogeneous Computing

Authors

  • Sayed Md Asif Same Masters of IT, Sydney Institute of Higher Education, Sydney, Australia
    Author

DOI:

https://doi.org/10.71366/ijwos03062639263

Keywords:

Multi-stage programming, code generation, domain specific languages, heterogeneous computing, just-in-time compilation, meta-object protocols

Abstract

Modern high-performance computers are heterogeneous machines containing multi-core CPUs, GPUs, and specialized accelerators. While domain-specific languages (DSLs) and active libraries can provide portability across these diverse
architectures, their implementation remains challenging due to the ntension between high-level meta-programming facilities and low-level performance control. This paper presents Terra, a novel two-language design that separates these concerns: Lua serves as a high-level meta-programming language for generating and optimizing code, while Terra provides a low-level systems language with Clike performance. We adapt multi-stage programming techniques to work across this two-language boundary, introducing shared lexical scoping for intuitive code generation, hygienic variable capture, and separate evaluation for predictable performance. We further contribute exotypes, a mechanism combining meta-object protocols with staged programming to enable runtime generation of high-performance types. Through case studies in linear algebra, image processing, physical simulation, probabilistic programming, serialization, and dynamic assembly, we demonstrate that Terra achieves performance within 20% of ATLAS for matrix multiplication 2.3x faster than hand-written C for image processing, and 11x faster than Kryo for serialization, while reducing implementation complexity by eliminating separate compiler toolchains.

Downloads

Published

2026-06-02

How to Cite

[1]
Sayed Md Asif Same , “Terra: A Multi-Stage Language for Portable High-Performance Heterogeneous Computing”, Int. J. Web Multidiscip. Stud. pp. 1-11, 2026-06-02 doi: https://doi.org/10.71366/ijwos03062639263 .