Repository navigation
Conversation
Base SPIR-V can't carry the `contract` fast-math flag, so `muladd` reaches the driver as a separate multiply and add (and the SPIR-V back-end marks every kernel `ContractionOff`), which drivers never fuse into an FMA (JuliaGPU/KernelAbstractions.jl#865). SPV_KHR_float_controls2 carries the flag as `FPFastMathMode AllowContract`. Enabling the extension makes the back-end declare it in every kernel, which drivers that don't accept it reject, so add a `spirv_extensions` device property (cl_khr_spirv_queries) and enable the extension only when the device lists it. Explicitly passed `extensions` replace this default, and programs built through spirv2clc don't get it. Also add a missing comma in `propertynames(::Device)`, which made it throw. Assisted-by: Claude Code (Opus 5.5)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #562 +/- ##
==========================================
+ Coverage 86.06% 86.08% +0.01%
==========================================
Files 17 17
Lines 1615 1617 +2
==========================================
+ Hits 1390 1392 +2
Misses 225 225 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft until JuliaGPU/GPUCompiler.jl#1007 is released (see below). Same change as JuliaGPU/KernelAbstractions.jl#876.
Base SPIR-V can't carry LLVM's
contractfast-math flag. Somuladdreaches the driver as a separateOpFMul+OpFAdd, the SPIR-V back-end marks every kernelContractionOff, and the driver never emits an FMA (JuliaGPU/KernelAbstractions.jl#865).SPV_KHR_float_controls2carries the flag asFPFastMathMode AllowContract, and both SPIR-V back-ends emit that when the extension is enabled.Once enabled, though, the back-ends declare the extension in every float kernel, and drivers that don't accept it reject the module. So this PR:
spirv_extensionsdevice property (CL_DEVICE_SPIRV_EXTENSIONS_KHR, fromcl_khr_spirv_queries; empty when the device doesn't support the query);extensionsin the compiler config to theOPTIONAL_SPIRV_EXTENSIONS(currently justSPV_KHR_float_controls2) that the device lists. Programs built through spirv2clc don't get it, and explicitly passedextensionsreplace the default;propertynames(::Device), which made:non_uniform_work_group_support :extensionsparse as a range, so calling it threw.Dependencies:
contractoperations once the extension is on. It omits theFloatControls2capability that its implicitFPFastMathDefaultneeds. SPIR-V: declare FloatControls2 for kernels with SPV_KHR_float_controls2 GPUCompiler.jl#1007 works around this. Before merging, this PR should raise the GPUCompiler compat to the release that contains it.Testing:
spirv_extensionsis added to the device-info test, and a new "fast-math contraction" test checks three things:AllowContractis emitted exactly when the config enables the extension; the extension is enabled when the device reports it; andextensions = String[]turns it off.deviceandexecutiontests on every platform on this machine (PoCL, PoCL-C, Intel CPU, AMD APP, NVIDIA, rusticl): the same results asmain, plus the new tests. The existing failures matchmain: Inteldevice1, AMDdevice2, AMDexecution1, rusticlexecution1.mainwith the same PoCL, where the extra 6 are the new tests. Both runs crash in the same two files,pocl/intrinsicsandpoclc/intrinsics, with illegal instructions from that PoCL dev build.@openclofy[i] = muladd(a[i], x[i], y[i])compiles tovfmaddand gives results bit-identical tofma.(a, x, y).🤖 Generated with Claude Code