Links LLVM bitcode into one PTX module in the mesh cluster float mode (f32 FTZ, unfused), exporting only the kernel
$ sexc add @ajax/mesh-ptx-link- total 3
- drwxr-xr-x-../
- drwxr-xr-x-Oct 27 03:27v/# 1 version
- drwxr-xr-x-Oct 27 03:27files/# the files of 0.1.0
- latest
- 0.1.0, published Oct 27 03:27 by ajax
- owners
- ajax
- license
- MIT
- dependencies
- @ajax/mesh-check ^0.1.0
- dependents
- none yet
- keywords
- mesh alphaos ptx llvm linker ftz
- homepage
- https://github.com/thomasdavis/alpha-c-mesh/tree/main/apps/mesh-ptx-link
- repository
- https://github.com/thomasdavis/alpha-c-mesh
1# @ajax/mesh-ptx-link 2 3``` 4mesh-ptx-link --mcpu sm_86 [-O0..3] [--debug] [--export SYM]... -o OUT.ptx IN.bc... 5``` 6 7Links LLVM bitcode (a sexc `ptx` package's `.sexc/out/<profile>/ptx/<id>.bc`) into one PTX module in the 8cluster float mode: `llvm-link`, then `opt --denormal-fp-math-f32=preserve-sign` with 9`default<O3>,internalize,globaldce` keeping only `mesh_main` and `MESH_RT_ABI` public, then `llc` with the 10same flag. Every f32 instruction that has a `.ftz` form gets it, and the rest of the program is internalised 11and inlined into the kernel. Tools: `$MESH_LLVM_LINK`, `$MESH_OPT`, `$MESH_LLC`, or found on `PATH` 12(also `name-21` .. `name-15`) or the newest `/usr/lib/llvm-N/bin`. 13 14- **Ported from:** alpha-rust-mesh `scripts/ptx-link.sh` (rustc's linker for the programs). 15- **Tests:** the exact commands, the symbols file, the `sm_NN` rule, tool lookup; the programs' tests link 16 their PTX with it and float-check the result. 17- **Differences:** a command-line tool instead of a rustc `-C linker`, so it takes the inputs and options 18 directly. `llc` also gets `--fp-contract=off`: clang's C (unlike rustc) may emit `llvm.fmuladd` in a 19 library built without `-ffp-contract=off`, and strict contraction keeps that a multiply and an add.