`launch_and_wait`, which is compiled for every kernel, runs a host kernel, or falls back to the
queue when there is none: when PoCL can't create a host kernel, or when the work-group's stack
would exceed `host_kernel_stack_limit`. KernelAbstractions' own launches always pass 3-d sizes, so
for them the queue is a rare fallback, but inference analyzed it for every kernel anyway:
`launch_queued`, `launch_converted`, `clcall` and nanoOpenCL's `call`, `convert_arguments` and
`set_args!`, partly with abstract types, and all of it specialized on the kernel and its arguments.
The queue is now a `@noinline` function, `launch_queued_and_wait`. Launches that may run a host
kernel call it through `Base.inferencebarrier`, so that it is only compiled for the kernels that
fall back to it. Whether a launch may run a host kernel only depends on the types of its keyword
arguments (`may_run_on_host`): launches without 3-d `global_size` and `local_size`, like `@opencl`
launches with integer sizes, always run on the queue, and keep calling it directly, without a
dynamic call or allocations. Host launches are unchanged.
The precompile workload's `@kernel` launch no longer compiles the queue, so the workload also
launches a kernel on the queue, with `@opencl`, which `@opencl` launches use from the package
image.
In Oceananigans, with `-O0 --check-bounds=yes` as in its CI, solving a Poisson problem on a new
grid size compiles 19 CPU kernels, which took 2.5-2.8 s and now take 2.3-2.4 s; its test of
Poisson solvers on stretched grids, which does that for about 270 grid sizes, goes from 606-675 to
550-608 s, and allocates 153 instead of 171 GiB. Launches that fall back to the queue allocate
176 more bytes for the dynamic call (240 instead of 64), and take as long as before; the first
`@opencl` launch takes about 165 instead of 250 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This seems to reduce a little bit CPU compilation latency in CliMA/Oceananigans.jl#5799