|
|
|
|
|
by jaen
88 days ago
|
|
For similar languages / compilers in this area: 1. ISPC [1], the IntelĀ® Implicit SPMD Program Compiler also compiles SIMD programs with branches and other control flow efficiently using predication/masking etc. 2. Futhark [2] compiles nice-looking functional programs into efficent parallel GPU/CPU code. [1]: https://github.com/ispc/ispc
[2]: https://futhark-lang.org/ |
|
We take a more draconian approach. We completely ban if and else inside compute kernels. If you want conditional logic, you must explicitly use branchless intrinsics like mix, step, or select. The goal is to make the cost of divergence mathematically explicit to the programmer rather than hiding it in the compiler. If a pathway is truly divergent, you handle it at the pipeline level using a filter node to split the stream. We also ban arbitrary pointers entirely. All memory is handled via a Host-Owned Static Arena, and structs are automatically decomposed into Struct-of-Arrays layouts. Because the compiler controls the exact byte-offset and knows there are no arbitrary pointers, it can aggressively decorate every LLVM IR pointer with noalias.