CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules

summary

Video file (mp4)

The gist

The gist The CrossTL system presents a universal programming language translator that enables bidirectional translation between multiple high-level programming languages through a unified

In short

CrossTL is a system that translates GPU programs between multiple high-level languages using a universal intermediate representation called CrossGL. It achieves bidirectional translation by employing modular frontends and backends for various platforms like CUDA, HIP, and Metal. This enables developers to write code once and deploy it across diverse hardware, ensuring semantic preservation during the translation process.

Key concepts

CrossGL
This is a universal intermediate representation that captures the core meaning of all supported programming languages without focusing on their specific syntax. It includes features like a unified type system for arithmetic and logical operations, statements for control flow, and data structures, acting as a common language bridge.
Three-Stage Translation Pipeline
The translation process is structured in three distinct stages: first, language-specific frontends convert the source code into an abstract syntax tree (AST); second, this AST is translated into the universal CrossGL representation; and finally, target-specific backends generate the final executable code for a specific platform.
Bidirectional Translation Modules
The system uses dedicated modules for both importing existing code (ToCrossGLConverter) and generating new target code from the intermediate representation (CodeGen). These modules are implemented separately for each language pair and platform, ensuring that translation flows correctly in both directions.

Terminology used across episodes

This episode discusses

The paper

CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules · Read on arXiv

Nripesh Niketan, Vaatsalya Shrivastva

GPU programs are written in vendor languages that disagree about integer overflow, division by zero, NaN handling, floating-point contraction, data layout and dispatch, so a translated program can compile and still compute something else. We describe CrossTL, an open-source translator that routes ten GPU source languages to eleven targets through CrossGL, a textual hub language, with repository-scale porting, contracts that loaders check, and native parity tests. We define faithful translation as refinement up to rejection under a compile configuration, and test whether a hub that records each source rule and lowers it through one per-target table keeps rules that a syntax-only hub loses. On an internally pre-registered suite of 66 hazard kernels in six languages, run on an Apple GPU through Metal, MoltenVK and WebGPU and on CPU implementations of Vulkan, OpenGL and an emulated Direct3D 12, SPIRV-Cross, naga, Tint, Slang and CrossTL each lose some source rule, and outcomes change with Metal's math mode and between two Vulkan implementations. A rule-carrying prototype of the hub removes 34 of 39 divergences on the rules it carries, against 14 for local fixes to four SPIR-V defects, and refuses where WGSL cannot express a rule. The registered hypothesis that it keeps every rule fails: MoltenVK, a non-conformant Vulkan layer, drops a rule that correct SPIR-V carries natively. On 2,585 programs written by third parties, 31% of CrossTL's translations are usable, established translators produce valid output significantly more often in 31 of 39 comparisons, and carrying the rules changes no target's accepted share by more than 0.2 points. Recording each operation's source rule suffices for the rules tested but is not necessary: one strongest rule would keep them too, at about nine times as many rewrites and 58 more refusals on the corpus.

DOI: 10.5281/zenodo.15826975

Transcript

Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.

Tom: Hi, I'm Tom.

Jane: And I'm Jane, here with Lu, Meng and our in-house large language model, Lalam.

Tom: We're looking at the paper: "CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules".

Jane: Here's the gist of the paper. The gist The CrossTL system presents a universal programming language translator that enables bidirectional translation between multiple high-level programming languages through a unified intermediate representation called CrossGL.

Tom: Architecture and Components The system consists of three main components: "language-specific lexers and parsers that convert source code to abstract syntax trees (ASTs), bidirectional CrossGL translation modules that implement both ToCrossGLConverter classes for importing existing code and dedicated CodeGen classes for generating target code from CrossGL, and comprehensive backend implementations that handle the full translation pipeline for each supported platform".

Jane: The overall architecture is guided by design principles including "Modularity: Each language frontend and backend is implemented as an independent module, enabling parallel development and easy maintenance".

Tom: The system employs a "three-stage translation pipeline consisting of languagespecific frontends, a universal intermediate representation, and target-specific backends".

Title and authors: Tom: So, let's talk about the title and who wrote this paper, "CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules". It points out that they are focusing specifically on GPU programs right now.

Jane: They are also emphasizing that the key is preserving those original rules from the source code while translating it to another language. That means when you translate, you don't accidentally change how the program actually behaves at a fundamental level.

Lu: That preservation aspect is really important because if you just convert syntax, things break in complex GPU tasks or simulations.

Meng: I mean, if you're running production code and it suddenly starts doing something weird on a new platform because of a translation hiccup, that's a nightmare for deployment.

Lalam: The paper is really about creating this hub—this central representation—that acts as the translator between all those different GPU languages.

The paper's summary: Tom: So, looking at the summary of "CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules", they lay out their entire system structure pretty clearly. It uses this three-stage pipeline.

Jane: It starts with language-specific frontends that turn your source code into something common, then it goes through that universal intermediate representation, CrossGL, and finally a target-specific backend generates the actual machine code you need.

Lu: The summary highlights that CrossGL has a unified type system and includes things like expression trees and control flow graphs, which captures the essential semantics of different programming paradigms.

Meng: It’s not just about syntax; it’s about capturing the meaning of what you're trying to do with your GPU kernels or shaders.

Lalam: They explicitly mention that this approach aims to reduce the translation problem from something exponential, which they say is O(n2), down to linear complexity, O(n).

The paper's improvements: Tom: Now, the authors point out what they actually improved over previous methods. They are showing how their hub-based approach handles the translation problem more efficiently.

Jane: They argue that existing solutions either sacrifice performance for abstraction or they become unmanageable when you add more languages because you end up with those O(n2) translators we talked about before.

Lu: The main improvement is definitely the introduction of CrossGL, which acts as this single intermediate language that captures the essential semantics across all these different programming languages.

Meng: So, if I'm looking at deployment, this means you don't have to maintain a separate CUDA translator and a separate Vulkan translator; it’s one system handling the conversion.

Lalam: And they suggest that because of this universal IR, you get target-agnostic optimizations. You can analyze the program across all target language semantics at once to find better ways to run it.

Conclusion: Tom: So, wrapping up this discussion on "CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules", the paper shows that a unified intermediate representation can make cross-language translation practical for many languages.

Jane: It sets up a foundation where developers can write code once and deploy it across multiple GPU platforms, which is really helpful for complex graphics or compute tasks.

Lu: The implication is that adding new languages to this system becomes much simpler because you only need to implement the language-specific parts and map them into CrossGL.

Meng: From a deployment standpoint, this means less maintenance overhead across the board when you are targeting different GPU architectures.

Lalam: And they confirm that they have achieved linear complexity scaling, which means it can handle more languages efficiently than the previous exponential growth we saw.

More episodes

← Home