Skip to content

Do not stamp reqd_sub_group_size on kernels with indirect calls (#1380) - #1386

Merged
pvelesko merged 3 commits into
mainfrom
2026-07-28-warps-indirect-argdrop
Aug 27, 2026
Merged

Do not stamp reqd_sub_group_size on kernels with indirect calls (#1380)#1386
pvelesko merged 3 commits into
mainfrom
2026-07-28-warps-indirect-argdrop

Conversation

@pvelesko

Copy link
Copy Markdown
Collaborator

HipWarpsPass stamps intel_reqd_sub_group_size on every kernel in a module as soon as one shuffle or ballot intrinsic is declared anywhere in it. A stamped kernel then silently drops every argument after the first of a device indirect call, with no error and no diagnostic. One #include <Kokkos_Core.hpp> is enough to trigger it, so every Kokkos application that dispatches on the device computed garbage.

Skip kernels that can reach an indirect call over direct edges, and leave every other kernel stamped exactly as before.

Fixes #1380

HipWarpsPass puts intel_reqd_sub_group_size on every kernel in the module as
soon as one shuffle/ballot declaration appears anywhere in it, so that __shfl
and friends see the warp width chipStar was built for.

A stamped kernel silently loses the arguments of a device indirect call. The
callee receives the first argument and every argument after it arrives as
zero, with no error and no diagnostic.

Kokkos declares the shuffle intrinsics from Kokkos_Core.hpp, so a single
#include stamped an entire application and broke device-side indirect dispatch
for every Kokkos program. Virtual calls lower to the same indirect call, and
kynema-ugf / Nalu-Wind builds its whole Kernel, NodeKernel, EdgeKernel,
MasterElement and CoeffApplier architecture on exactly that, so it linked and
ran while computing garbage.

Skip kernels that can reach an indirect call over direct edges, and leave
every other kernel exactly as before. Narrowing the stamp the other way, to
only those kernels that provably reach a sensitive function, was tried first
and is wrong today: WarpSizeSensitiveFuncNames lists only some of the shuffle
overloads, so Kokkos' own reductions lost the subgroup size they depend on and
started accumulating each contribution four times.

Reduced reproducer, plain HIP, no Kokkos: adding one unused __global__ that
calls __shfl turns a correct indirect dispatch of f(7.0, 3) from 7036.0 into
7006.0. That is TestIndirectCallWithWarpPrimitive.hip.

Fixes #1380
@pvelesko
pvelesko force-pushed the 2026-07-28-warps-indirect-argdrop branch from 03bee9e to 99821fc Compare August 25, 2026 11:06
TestIndirectCall's callee takes a single argument, so it cannot observe
#1380: a kernel stamped with intel_reqd_sub_group_size
delivers the first argument of an indirect call and zero for every
argument after it.

Add the never-launched touchShfl kernel that puts the shuffle declaration
in the module, and a two-argument callee reached through a kernel
argument, so the same test covers both the plain indirect call and the
argument drop. Drop the separate TestIndirectCallWithWarpPrimitive, whose
only reason to exist was the missing second argument.
The blanket exclusion came in with #479, which disabled the test "for all
platforms due to lack of runtime query for detecting indirect call
support" while recording that it passes on Intel Level Zero and Intel
OpenCL CPU & GPU. #822 carried it into known_failures.yaml as a bare
entry and the reason was lost with the comment.

known_failures.yaml has per-backend and per-host sections now, so the
capability can be expressed directly: keep it excluded on PoCL, whose
SPIR-V reader is not built with SPV_INTEL_function_pointers enabled, and
on rusticl, whose spirv_to_nir implements no FunctionPointersINTEL
capability. It runs everywhere else, which is where #1380's argument drop
is observable in the first place.
@pvelesko

Copy link
Copy Markdown
Collaborator Author

/run-aurora-ci

@pvelesko
pvelesko merged commit 2b53227 into main Aug 27, 2026
18 of 19 checks passed
@pvelesko
pvelesko deleted the 2026-07-28-warps-indirect-argdrop branch August 27, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device indirect calls silently drop every argument after the first when a warp intrinsic is declared

1 participant