CrossTL: Hub-Based Translation of GPU Programs and the Preservation of Source Rules
This paper introduces CrossTL, an open-source hub-based translator that routes ten GPU languages to eleven targets via a rule-carrying intermediate language (CrossGL), demonstrating that explicitly preserving source-specific semantic rules significantly reduces translation divergences compared to syntax-only approaches, though it cannot fully guarantee correctness due to underlying implementation non-conformities and offers only marginal usability gains on large-scale third-party code.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Modern video games, scientific simulations, and artificial intelligence all rely on a special kind of computer program that runs on graphics processors. These chips are incredibly fast at doing many calculations at once, but they are picky about how they handle numbers. Different companies that make these chips—such as Apple, NVIDIA, and AMD—use different languages to write these programs. While the languages look similar on the surface, they often disagree on the most basic rules of arithmetic. For instance, one language might say that adding a number to itself when the result is too large should wrap around to a small negative number, while another language might say that same action is undefined and could result in anything. If a developer writes a program for one type of chip and tries to move it to another, the translation tools must decide which rule to follow. If they get this wrong, the program might compile and run, but it will produce the wrong answer, potentially crashing a game or corrupting scientific data.
A team of researchers set out to solve this problem by building a universal translator for these graphics programs. They created a system called CrossTL, which acts as a central hub. Instead of building a separate translator for every possible pair of languages, their system takes code from ten different source languages and converts it into a single, neutral format before sending it out to eleven different target languages. The core challenge they faced was that this neutral format, by itself, does not remember which specific rule a piece of code was supposed to follow. It sees a simple addition sign, but it cannot tell if that sign means "wrap around" or "stop and error." Without this memory, the translator might accidentally change the meaning of the program, leading to silent failures where the code runs but computes the wrong result.
To fix this, the researchers developed a method called "rule carrying." They modified their translator to attach a specific note to every mathematical operation it encounters. This note records exactly which rule the original language used for that operation. When the code moves through the hub and heads toward a new target language, the translator checks this note. If the target language follows the same rule, it passes the operation through. If the target language follows a different rule, the translator replaces the operation with a custom-built piece of code that forces the target to behave exactly like the source. This ensures that the program computes the same result on the new hardware as it did on the old one, regardless of the differences in the underlying languages.
The team tested this system rigorously using a suite of sixty-six carefully designed test programs, known as hazard kernels. These tests were designed to trigger the specific rules where languages disagree, such as what happens when you divide by zero or add numbers that are too large. They ran these tests on a variety of real-world hardware and software environments, including Apple's graphics processors and several open-source drivers. The results showed that without their new method, existing translation tools lost the correct rules in many cases, leading to incorrect outputs. When the researchers enabled the rule-carrying feature, the system successfully preserved the correct behavior in almost every instance. Out of hundreds of test runs, the number of errors dropped dramatically, with the remaining few failures traced to specific quirks in how certain drivers handled the code, rather than flaws in the translation logic itself.
The study also looked at how this new method performed on thousands of real-world programs written by third parties, ranging from machine learning libraries to graphics engines. The researchers found that while the new system was slightly less likely to produce code that a compiler would accept compared to some established tools, it was far more reliable at ensuring that the code that did compile actually worked correctly. In fact, the new method changed the success rate of the code by less than one percentage point, proving that it could be adopted without breaking existing workflows. The researchers concluded that for a translator to be truly faithful, it cannot just move syntax from one language to another; it must carry the semantic rules of the source language along for the ride, ensuring that the meaning of the program survives the journey intact.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.