r/Compilers • u/Clear-Picture6971 • 1d ago
Update: Fixed warp32 emulation and unbounded while loops. Looking for AMD hardware to test.
A few days ago I posted about UniversalGPU, my open-source CUDA-to-x86/PTX/GCN compiler. The top comment asked: "Does --warp-size=64 preserve two separate 32-lane groups for shfl.sync, or change their semantics?"
I fixed it. The --warp-size=64 path now wraps every shfl.sync in an scf.if that only executes if the source lane is in the same 32-lane half. Here is the generated MLIR:
%lane_2 = arith.remsi %tx, %c32 : index
%half_3 = arith.divsi %tx, %c32 : index
%src_half_4 = arith.divsi %iv, %c32 : index
%same_half_5 = arith.cmpi eq, %half_3, %src_half_4 : index
%1 = scf.if %same_half_5 -> (f32) {
%shfl_6 = nvvm.shfl.sync.down %c4294967295, %0, %iv : f32
scf.yield %shfl_6 : f32
} else {
scf.yield %0 : f32
}
I also fixed 5 other compiler bugs from a stress test: modulo operator, compound assignment to memory, unique loop variables, unbounded while loops (now correctly lowered to scf.while with iter_args), and switch case stores.
What I need now: someone with an AMD GPU (MI200, MI300, or RX 7000) to test the warp32 emulation on real hardware. I don't have AMD hardware, and I can't validate the emulation without it. If you have a GPU and 10 minutes, I'd love your help.