Hello!
My GPU compiler project booth now compiles Fortran do concurrent kernels to GPU machine code, and I wanted to share where it has got to.
Booth takes CUDA, HIP or Triton and emits machine code directly for AMD RDNA 2/3/4 as well as CDNA, Nvidia PTX, Tenstorrent and Apple (still a WIP with the runtime for apple). It also has its own CPU backend for x86-64 and RISC-V. It does all the good things a compiler does all by itself and doesn’t contain any dependencies like MLIR or LLVM, you only need any C compiler to run it.
What works is elementwise BLAS-1. saxpy, sscal, scopy, sswap, srot and srotm. Currently tested in CI everywhere except Tenstorrent as I’ve just been given a chip and we’re moving to emit machine code rather than their own c++ compiler. I’d like to publicly thank Hot Aisle as they provided the MI300X so I could validate Fortran running by hand.
What does not work: no reductions, so sdot, sasum and snrm2 are absent. Nested loops inside a do concurrent get dropped on the offload path, which blocks CSEVL and the SLATEC special functions (filed as lfortran/lfortran#12369). And intrinsics come out as abs and exp rather than fabsf and expf, so transcendentals do not resolve. Elementwise arithmetic only, but that part is tested.
I carried on the modernisation of SLATEC which you can see here: Zaneham/SLATEC: A modernisation of the SLATEC library. The goal is to have routines that would benefit from GPU acceleration be a part of the CI process.
If anyone has some time I would appreciate feedback. Especially because I come from a historical computing and hobby background so if there’s any routines or parts of Fortran that people would like to see prioritised first, I am all ears. If you do give this a go and find any problems with this, please feel free to reach out to me directly and/or raise an issue. If you’re unsure if it’s something LFortran isn’t supporting yet or something with my compiler you’re more than welcome to leave an issue on Booth too.
This is a new and ongoing project so there will be big gaps and errors so if you hit anything just sing out.
Thanks all!
Zane