Repository navigation
Conversation
…t row clRunHostKernelPOCL used two 64-bit divisions to compute the range's first work-group coordinates. Each takes tens of cycles on Intel CPUs before Ice Lake. Ranges starting in the grid's first row, as launches on one thread do, now need neither division. A trivial KernelAbstractions launch on a Xeon E3-1245 v6 takes 518 instead of 566 cycles in a local build.
When the caller's floating-point environment already matches the kernel's, the kernel can only raise further exception flags, as a function call would. Leaving them avoids a second MXCSR read (STMXCSR) and a store-forwarding stall: a trivial KernelAbstractions launch on a Xeon E3-1245 v6 takes 498 instead of 518 cycles in a local build. The documented contract becomes the C function-call one on x86 and AArch64: the caller's control modes and previously raised flags are preserved, and which further flags the call raises is unspecified. AArch64 still restores FPCR and FPSR.
maleadt
force-pushed
the
tb/host-kernel-launch-cost
branch
from
October 27, 2026 06:01
7d686e6 to
0caf825
Compare
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.
Stacked on #2 (
cl_pocl_host_kernel). Two changes toclRunHostKernelPOCLreduce a trivial KernelAbstractions.jl launch on a Xeon E3-1245 v6 (Kaby Lake) from 566 to 498 cycles, measured with local builds:STMXCSRand a store-forwarding stall.Neither change is measurable on a Ryzen 5950X.
Contract change (2): the header now promises what a C function call does: the caller's floating-point control modes and previously raised exception flags are preserved, and which further flags the call raises is unspecified. On x86, when the caller's environment already matches the kernel's (round to nearest, exceptions masked, the kernel's FTZ setting, as in Julia by default), flags the kernel raises now stay raised. Previously, the caller's flags were always restored exactly. AArch64 still restores FPCR and FPSR. The test checks the contract (control modes and earlier flags survive, in both the matching and the differing case), not which flags leak.
Validation:
runtime/test_cl_pocl_host_kernelpasses with loopvec, cbs, and cpu_jit. The KernelAbstractions suite passes with both changes on the JLL series (tb/jll-series-release_next). On this branch's base, that suite stops inWorkitemLoopson a barrier kernel:mainlacks the barrier fixes included in the JLLs (#4 and others).