Files
compiler-explorer/.github/labeler.yml
Shawn Zhong 8befc91a79 Add Triton language and compiler (#7919)
Close #5530. Infra:
https://github.com/compiler-explorer/infra/pull/1711. Previous work by
@siboehm at #5531


## Summary

This pull request introduces support for the
[Triton](https://github.com/triton-lang/triton) language, a Python-based
DSL for writing highly efficient GPU kernels.


- [x] **New Language Support**: I've added comprehensive support for the
Triton programming language, allowing users to compile and inspect
Triton kernels within Compiler Explorer. (c.f.,
`lib/compilers/triton.ts`)
- [x] **Python Wrapper for Compilation**: A new Python wrapper script
(`triton_wrapper.py`) has been introduced to manage Triton compilation,
patching its behavior to dump compiled kernels and intermediate
representations without requiring actual execution, and consolidating
the output for Compiler Explorer.
- [x] **Device Assembly View**: Enables viewing of generated device
assembly code (e.g., PTX, AMDGCN) and various intermediate
representations (MLIR, LLVM IR) produced by the Triton compiler.
- [x] **MLIR Parsing**: New parsers (`asm-parser-mlir.ts` and
`mlir-pass-dump-parser.ts`) have been added to correctly interpret and
display MLIR assembly and optimization pass dumps, including source
location information.
- [x] **Multi-Version & Multi-Backend Support**: Painstakingly includes
all 8 versions (from 2.2.0 to 3.3.1) of Triton that supports Python
3.12. Supports both CUDA and HIP backend for Triton 3.

## Screenshots

Source and assembly:
<img width="1354" height="789" alt="image"
src="https://github.com/user-attachments/assets/c29650ff-2073-40e0-a9e6-ff8377094b5e"
/>



Device view for MLIR and LLVM IR: 
<img width="1402" height="670" alt="image"
src="https://github.com/user-attachments/assets/43dd5c68-ca78-41b1-9865-e97ffe3ef73c"
/>

Opt pipeline viewer:
<img width="1408" height="668" alt="image"
src="https://github.com/user-attachments/assets/429eef8c-aaac-4781-aafa-39ef0ffc7241"
/>

Diff of TTIR in Triton 3.3.1 vs 2.3.0:
<img width="1580" height="726" alt="image"
src="https://github.com/user-attachments/assets/a928c893-dd9a-4c3a-a048-14046e56a14c"
/>

CUDA & HIP:
<img width="1596" height="800" alt="image"
src="https://github.com/user-attachments/assets/c18800c3-cfad-4e5e-96de-ba92c9f236ea"
/>

## Implementation Details (and Notes for Reviewers)

- For Device Assembly View, I Implemented `MlirAsmParser` for parsing
MLIR assembly. Technically MLIR is not an assembly language, but there
is no better choice to make the source line map work w/ device view.
- I Implemented `MlirPassDumpParser` for processing MLIR optimization
pass dumps. I tried to subclass `LlvmPassDumpParser`, but they turn out
to be too different to worth doing it.
- `LlvmPassDumpParser` made some assumptions that do not hold true for
MLIR passed. Some effort is put to make sure that the passes are
properly diff-ed, since some passes can run multiple times and also
sometimes pass can be nested (i.e., some number of `before`s followed by
some number of `after`s)
- A lot of effort is put into `patch_triton` to make sure that the we
only compile the kernel without actually running it, and that needs to
work across all the versions we support.

## Steps to Run Locally

1. Clone https://github.com/ShawnZhong/compiler-explorer-infra.git
2. Install Triton to `/opt/compiler-explorer/triton`:
```sh
$ cd compiler-explorer-infra
$ ./bin/ce_install install triton
$ ls /opt/compiler-explorer/triton
# v2.2.0  v2.3.0  v2.3.1  v3.0.0  v3.1.0  v3.2.0  v3.3.0  v3.3.1
```
3. Clone https://github.com/ShawnZhong/compiler-explorer.git and
checkout branch `triton`
4. Run Compiler Explorer
```sh
make EXTRA_ARGS='--language triton' dev
```
5. Enjoy

---------

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2025-07-30 10:15:28 -05:00

464 lines
12 KiB
YAML

'ui':
- changed-files:
- any-glob-to-any-file:
- 'static/**/*'
- 'views/**/*'
'lang-ada':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/ada.ts'
- 'etc/config/ada.*.properties'
- 'static/modes/ada-mode.ts'
'lang-algol68':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/gac.ts'
- 'etc/config/algol68.*.properties'
'lang-android-java':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/d8.ts'
- 'etc/config/android-java.*.properties'
'lang-android-kotlin':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/d8.ts'
- 'etc/config/android-kotlin.*.properties'
'lang-asm':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/assembly.ts'
- 'lib/compilers/nasm.ts'
- 'lib/compilers/ptxas.ts'
- 'etc/config/assembly.*.properties'
- 'static/modes/asm-mode.ts'
- 'static/modes/asm6502-mode.ts'
'lang-c':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/cc65.ts'
- 'lib/compilers/ellcc.ts'
- 'lib/compilers/ewarm.ts'
- 'lib/compilers/ewavr.ts'
- 'lib/compilers/ppci.ts'
- 'lib/compilers/sdcc.ts'
- 'lib/compilers/tendra.ts'
- 'etc/config/c.*.properties'
'lang-c++':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/ewarm.ts'
- 'lib/compilers/ewavr.ts'
- 'etc/config/c++.*.properties'
- 'static/modes/cppp-mode.ts'
'lang-c++-opencl':
- changed-files:
- any-glob-to-any-file:
- 'etc/config/cpp_for_opencl.*.properties'
- 'static/modes/cpp-for-opencl-mode.ts'
'lang-c3':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/c3c.ts'
- 'etc/config/c3.*.properties'
- 'static/modes/c3-mode.ts'
'lang-cmakescript':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/cmakescript.ts'
- 'etc/config/cmakescript.*.properties'
'lang-circle':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/circle.ts'
- 'etc/config/circle.*.properties'
- 'static/modes/cppcircle-mode.ts'
'lang-circt':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/circt.ts'
- 'etc/config/circt.*.properties'
'lang-clean':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/clean.ts'
- 'etc/config/clean.*.properties'
- 'static/modes/clean-mode.ts'
'lang-cobol':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/gnucobol.ts'
- 'etc/config/cobol.*.properties'
- 'static/modes/cobol-mode.ts'
'lang-cppx':
- changed-files:
- any-glob-to-any-file:
- 'etc/config/cppx_blue.*.properties'
- 'etc/config/cppx_gold.*.properties'
- 'static/modes/cppx-blue-mode.ts'
- 'static/modes/cppx-gold-mode.ts'
'lang-crystal':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/crystal.ts'
- 'etc/config/crystal.*.properties'
- 'static/modes/crystal-mode.ts'
'lang-cuda':
- changed-files:
- any-glob-to-any-file:
- lib/compilers/nvcc.ts
- etc/config/cuda.*.properties
- static/modes/cuda-mode.ts
'lang-d':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/dmd.ts'
- 'lib/compilers/ldc.ts'
- 'etc/config/d.*.properties'
- 'static/modes/d-mode.ts'
'lang-dotnet':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/dotnet.ts'
- 'lib/parsers/asm-parser-dotnet.ts'
- 'etc/config/csharp.*.properties'
- 'etc/config/fsharp.*.properties'
- 'etc/config/vb.*.properties'
'lang-dart':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/dart.ts'
- 'etc/config/dart.*.properties'
'lang-fortran':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/flang.ts'
- 'lib/compilers/flang-fc1.ts'
- 'lib/compilers/lfortran.ts'
- 'lib/compilers/fortran.ts'
- 'etc/config/fortran.*.properties'
- 'static/modes/fortran-mode.ts'
'lang-gimple':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/gimple.ts'
- 'etc/config/gimple.*.properties'
'lang-hlsl':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/hlsl.ts'
- 'etc/config/hlsl.*.properties'
- 'static/modes/hlsl-mode.ts'
'lang-hook':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/hook.ts'
- 'etc/config/hook.*.properties'
- 'static/modes/hook-mode.ts'
'lang-jakt':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/jakt.ts'
- 'etc/config/jakt.*.properties'
- 'static/modes/jakt-mode.ts'
'lang-glsl':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/glsl.ts'
- 'etc/config/glsl.*.properties'
- 'static/modes/glsl-mode.ts'
'lang-go':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/golang.ts'
- 'etc/config/go.*.properties'
'lang-haskell':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/haskell.ts'
- 'etc/config/haskell.*.properties'
- 'static/modes/haskell-mode.ts'
'lang-ispc':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/ispc.ts'
- 'etc/config/ispc.*.properties'
- 'static/modes/ispc-mode.ts'
'lang-mlir':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/mlir.ts'
- 'etc/config/mlir.*.properties'
- 'static/modes/mlir-mode.ts'
'lang-java':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/java.ts'
- 'etc/config/java.*.properties'
'lang-julia':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/julia.ts'
- 'etc/config/julia.*.properties'
'lang-kotlin':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/kotlin.ts'
- 'etc/config/kotlin.*.properties'
'lang-llvm':
- changed-files:
- any-glob-to-any-file:
- 'lib/llvm-ast.ts'
- 'lib/llvm-ir.ts'
- 'lib/compilers/llc.ts'
- 'lib/compilers/llvm-mca.ts'
- 'lib/objdumper/llvm.ts'
- 'lib/tooling/llvm-mca-tool.ts'
- 'lib/tooling/llvm-dwarfdump-tool.ts'
- 'etc/config/llvm.*.properties'
- 'static/modes/llvm-ir-mode.ts'
'lang-modula2':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/gm2.ts'
- 'etc/config/modula2.*.properties'
- 'static/modes/modula2-mode.ts'
'lang-mojo':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/mojo.ts'
- 'etc/config/mojo.*.properties'
- 'static/modes/mojo-mode.ts'
'lang-nim':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/nim.ts'
- 'etc/config/nim.*.properties'
- 'static/modes/nim-mode.ts'
'lang-nix':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/nix.ts'
- 'etc/config/nix.*.properties'
- 'static/modes/nix-mode.ts'
'lang-numba':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/numba.ts'
- 'etc/config/numba.*.properties'
'lang-objc':
- changed-files:
- any-glob-to-any-file:
- 'etc/config/objc.*.properties'
'lang-objc++':
- changed-files:
- any-glob-to-any-file:
- 'etc/config/objc++.*.properties'
'lang-ocaml':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/ocaml.ts'
- 'etc/config/ocaml.*.properties'
- 'static/modes/ocaml-mode.ts'
'lang-odin':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/odin.ts'
- 'etc/config/odin.*.properties'
- 'static/modes/odin-mode.ts'
'lang-opencl-c':
- changed-files:
- any-glob-to-any-file:
- 'etc/config/openclc.*.properties'
- 'static/modes/openclc-mode.ts'
'lang-pascal':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/pascal.ts'
- 'etc/config/pascal.*.properties'
'lang-pony':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/pony.ts'
- 'etc/config/pony.*.properties'
'lang-python':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/python.ts'
- 'lib/compilers/pythran.ts'
- 'etc/config/python.*.properties'
'lang-racket':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/racket.ts'
- 'etc/config/racket.*.properties'
'lang-ruby':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/ruby.ts'
- 'etc/config/ruby.*.properties'
'lang-rust':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/rust.ts'
- 'etc/config/rust.*.properties'
'lang-scala':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/scala.ts'
- 'etc/config/scala.*.properties'
'lang-slang':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/slang.ts'
- 'etc/config/slang.*.properties'
'lang-solidity':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/solidity.ts'
- 'lib/compilers/solidity-zksync.ts'
- 'lib/compilers/solx.ts'
- 'etc/config/solidity.*.properties'
'lang-spice':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/spice.ts'
- 'etc/config/spice.*.properties'
- 'static/modes/spice-mode.ts'
'lang-spirv':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/spirv.ts'
- 'lib/compilers/spirv-tools.ts'
- 'etc/config/spirv.*.properties'
- 'static/modes/spirv-mode.ts'
'lang-swift':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/swift.ts'
- 'etc/config/swift.*.properties'
'lang-snowball':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/snowball.ts'
- 'etc/config/snowball.*.properties'
'lang-tablegen':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/tablegen.ts'
- 'etc/config/tablegen.*.properties'
- 'static/modes/tablegen-mode.ts'
'lang-toit':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/toit.ts'
- 'etc/config/toit.*.properties'
- 'static/modes/toit-mode.ts'
'lang-triton':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/triton.ts'
- 'etc/config/triton.*.properties'
'lang-typescript':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/typescript-native.ts'
- 'etc/config/typescript.*.properties'
'lang-v':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/v.ts'
- 'etc/config/v.*.properties'
- 'static/modes/v-mode.ts'
'lang-vala':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/vala.ts'
- 'etc/config/vala.*.properties'
- 'static/modes/vala-mode.ts'
'lang-wasm':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/wasmtime.ts'
- 'etc/config/wasm.*.properties'
- 'static/modes/wat-mode.ts'
'lang-zig':
- changed-files:
- any-glob-to-any-file:
- 'lib/compilers/zig.ts'
- 'etc/config/zig.*.properties'
- 'static/modes/zig-mode.ts'
'documentation':
- changed-files:
- any-glob-to-any-file:
- 'docs/**/*'
- 'README.md'
- 'CONTRIBUTING.md'
- 'SECURITY.md'