Skip to content

Add AvxVnni.V512 hardware intrinsics - #128365

Merged
tannergooding merged 34 commits into
dotnet:mainfrom
jamesburton:feature/avxvnni.v512
Jun 27, 2026
Merged

Add AvxVnni.V512 hardware intrinsics#128365
tannergooding merged 34 commits into
dotnet:mainfrom
jamesburton:feature/avxvnni.v512

Conversation

@jamesburton

@jamesburtonjamesburton commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary - Add the managed AvxVnni.V512 surface for AVX-512 VNNI VPDPBUSD/VPDPWSSD intrinsics. - Wire CPUID AVX512-VNNI detection into the runtime/JIT AVXVNNI_V512 instruction-set flag. - Extend VPDP codegen and LSRA handling to cover the new V512 intrinsic IDs. Closes#86849 ## Validation - ./build.cmd clr+libs -c Release -arch x64 - ./build.cmd clr -c Release -arch x64 - Strix Halo hardware probe: - AvxVnni.V512.IsSupported == True - VPDPBUSD-zmm : got=160 want=160 OK - VPDPWSSD-zmm : got=8 want=8 OK - VPDPBUSDS-zmm: got=2147483647 ... OK - JIT disassembly includes EVEX-512 forms: - vpdpbusd zmm0, zmm1, ... - vpdpwssd zmm0, zmm1, ... - vpdpbusds zmm0, zmm1, ...

Compatibility note

Existing R2R images that record Avx512Vnni now map to the more precise AVXVNNI_V512 JIT ISA instead of the broader AVX512v3 bucket. This is intentional: AVX512-VNNI is a distinct CPUID feature and the new managed API requires that specific capability, while retaining the existing R2R numeric value (Avx512Vnni = 79).

CopilotAI review requested due to automatic review settings May 19, 2026 12:39
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 19, 2026
@dotnet-policy-servicedotnet-policy-serviceBot added the community-contribution Indicates that the PR has been added by a community member label May 19, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds AVX-VNNI 512-bit (AVX512-VNNI) hardware intrinsics support exposed as the new AvxVnni.V512 nested class, wiring it through the JIT, runtime, CPU feature detection, R2R metadata, and adding a sample test project.

Changes:

  • New AvxVnni.V512 nested class with MultiplyWideningAndAdd/MultiplyWideningAndAddSaturate overloads (byte/sbyte and short/short) on Vector512<int>.
  • New AVXVNNI_V512 instruction set plumbed through CorInfo/JIT/R2R/cpufeatures, with AVX512 as its implication and AVXVNNI as its parent ISA.
  • New test project (AvxVnni_V512) plus a handwritten sample test that exercises VPDPBUSD/VPDPBUSDS/VPDPWSSD on 512-bit vectors.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/AvxVnni.csAdds AvxVnni.V512 nested class with the 4 VNNI 512-bit intrinsics.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/AvxVnni.PlatformNotSupported.csPNSE stubs for new V512 APIs.
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.csReference assembly entries for the new V512 APIs.
src/native/minipal/cpufeatures.hAdds XArchIntrinsicConstants_Avx512Vnni bit.
src/native/minipal/cpufeatures.cDetects AVX512-VNNI via CPUID leaf 7 ECX bit 11.
src/coreclr/inc/corinfoinstructionset.hInserts new AVXVNNI_V512 enum value (shifts subsequent values), implication and PNSE mapping for R2R.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csMirrors the new enum value and its forward/reverse implications.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtDefines AVXVNNI_V512 instruction set and AVX512 implication.
src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.csAdds Avx512Vnni flag bit and mapping from instruction set.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps new ISA to existing Avx512Vnni R2R set.
src/coreclr/tools/Common/InstructionSetHelpers.csAdds avxvnni_v512 to optimistic set on Intel.
src/coreclr/jit/hwintrinsiclistxarch.hDefines NI list entries for the new V512 intrinsics.
src/coreclr/jit/hwintrinsicxarch.cppAdds AVXVNNI→AVXVNNI_V512 mapping for V512 versioning.
src/coreclr/jit/hwintrinsiccodegenxarch.cppIncludes new NIs in the special codegen path.
src/coreclr/jit/hwintrinsic.cppAdds ISA range entry for AVXVNNI_V512.
src/coreclr/jit/lsraxarch.cppAdds LSRA handling for new NIs.
src/coreclr/jit/compiler.cppEnables AVXVNNI_V512 when EnableAVX512v3 config is set.
src/coreclr/vm/codeman.cppSets the JIT compile flag based on CPU detection.
src/coreclr/inc/jiteeversionguid.hBumps JIT/EE GUID.
src/tests/JIT/HardwareIntrinsics/X86_Avx/AvxVnni_V512/*New test project + handwritten sample test.

Comment threadsrc/coreclr/vm/codeman.cpp Outdated
Comment threadsrc/coreclr/jit/compiler.cpp
CopilotAI review requested due to automatic review settings May 19, 2026 12:45
@jamesburton

Copy link
Copy Markdown
ContributorAuthor

@dotnet-policy-service agree

@jamesburton

Copy link
Copy Markdown
ContributorAuthor

@copilot apply changes based on the comments in this thread

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.

Comment threadsrc/coreclr/jit/compiler.cpp
Comment threadsrc/coreclr/jit/hwintrinsicxarch.cpp Outdated
@jamesburton
jamesburtonforce-pushed the feature/avxvnni.v512 branch 2 times, most recently from 674a16a to ae37848CompareMay 19, 2026 14:18
CopilotAI review requested due to automatic review settings May 19, 2026 14:18

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comment threadsrc/coreclr/jit/compiler.cpp
Comment threadsrc/coreclr/vm/codeman.cpp Outdated
CopilotAI review requested due to automatic review settings May 19, 2026 14:44
@tannergooding

Copy link
Copy Markdown
Member

-- Could you resolve any copilot comments that have already been addressed to help make it easier to review and know what is or isn't pending?

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Comment threadsrc/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt Outdated
Comment threadsrc/coreclr/jit/jitconfigvalues.h Outdated
@jamesburtonfnz

jamesburtonfnz commented May 19, 2026 via email

Copy link
Copy Markdown

@jamesburton
jamesburtonforce-pushed the feature/avxvnni.v512 branch 2 times, most recently from ef626af to b7bc6afCompareMay 19, 2026 15:20
CopilotAI review requested due to automatic review settings May 19, 2026 15:20

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs Outdated
Comment threadsrc/coreclr/inc/clrconfigvalues.h Outdated
Comment threadsrc/coreclr/inc/corinfoinstructionset.h Outdated
CopilotAI review requested due to automatic review settings May 19, 2026 18:09

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Comment threadsrc/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt Outdated
Comment threadsrc/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.cs Outdated
@jamesburton
jamesburtonforce-pushed the feature/avxvnni.v512 branch from feaccd8 to 3677bdfCompareMay 19, 2026 18:22
CopilotAI review requested due to automatic review settings May 19, 2026 18:53

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/jitconfigvalues.h Outdated
Comment threadsrc/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs Outdated
Comment threadsrc/coreclr/inc/jiteeversionguid.h Outdated
@tannergooding
tannergooding requested review from dhartglassMSFT and removed request for kgJune 15, 2026 19:25
The V512VersionOfIsa wire-up correctly routes AvxVnni.V512 lookups
through AVX512v3 (via lookupIsa), and binarySearchId(AVX512v3,
"MultiplyWideningAndAdd") resolves to NI_AVX512v3_MultiplyWideningAndAdd
(the dedicated EVEX-encoded V512 entry that already had its codegen and
LSRA cases). Pre-fix, that lookup path was unreachable because
V512VersionOfIsa returned NONE for the AVXVNNI / AVX512v3 enclosing.
The default branch in Lowering::ContainCheckHWIntrinsic's 3-operand
SimpleSIMD path asserted that the intrinsicId was DivRem or in the
FIRST_NI_AVXVNNI..LAST_NI_AVXVNNIINT_V512 range. NI_AVX512v3_M*
intrinsics are declared earlier in hwintrinsiclistxarch.h (around line
1075), so their NI values fall below FIRST_NI_AVXVNNI and the range
check fails. ILC SIGABRTs (exit 134) on the X64Avx512 /
X64Avx512_VectorT512 NativeAOT smoke tests which now exercise
AvxVnni.V512.MultiplyWideningAndAdd as a real intrinsic.
Add the two NI_AVX512v3 multiply-widening NIs to the assert. Behavior is
unchanged (TryMakeSrcContainedOrRegOptional is the right containment
pattern — same as the VNNI variants).
AvxVnni.V512.IsSupported still verified True on Zen5 with VPDPBUSD512
lane0 = 24.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jamesburton

Copy link
Copy Markdown
ContributorAuthor

Pushed 80cb14ce181.

Root cause of the persistent NativeAOT Debug failures (exit 134 SIGABRT in ILC during X64Avx512 / X64Avx512_VectorT512 smoke tests): the V512VersionOfIsa fix correctly enabled the AVX512v3 lookup path, which resolves AvxVnni.V512.MultiplyWideningAndAdd to NI_AVX512v3_MultiplyWideningAndAdd (the dedicated EVEX entry at hwintrinsiclistxarch.h:1075-1076). Pre-fix that path was unreachable, so the test compiled the call as a regular method (the recursive [Intrinsic] stub) and ILC never reached the actual lowering path.

Now that the lookup resolves, lowering's default 3-operand SimpleSIMD branch asserted the intrinsicId was DivRem or in FIRST_NI_AVXVNNI..LAST_NI_AVXVNNIINT_V512. NI_AVX512v3_M* is declared earlier in the table so its NI value falls below the range — assert fires, ILC SIGABRTs.

LSRA (lsraxarch.cpp:2751-2752) and codegen (hwintrinsiccodegenxarch.cpp:905-906) already had explicit cases for NI_AVX512v3_MultiplyWideningAndAdd* — just the lowering assert was missing them. Added the two NIs to the assert, no behavior change (TryMakeSrcContainedOrRegOptional is the right containment pattern).

AvxVnni.V512.IsSupported = True + VPDPBUSD512 lane0 = 24 still verified on Zen5.

@jamesburton

Copy link
Copy Markdown
ContributorAuthor

@dhartglassMSFT — gentle nudge as Tanner CC'd you for secondary review. Head 80cb14ce181 has been stable since 2026-06-15; no further changes pending.

Quick orientation if helpful:

  • Net change since Tanner's approval: 1 merge-from-main (JIT-EE GUID bump only) + 3 small follow-ups addressing his V512VersionOfIsa / NativeAOT feedback.
  • CI: Windows NativeAOT Debug/Checked/Release all green — confirms the lowerxarch.cpp:10250 assert extension is doing its job.
  • 52 Linux failures are all the same Docker-registry auth flake (mcr.microsoft.com … no basic auth credentials pulling prereq containers) — pure Helix-infra cascade, not code.

Happy to walk through any of the follow-up commits if useful. Thanks!

# Conflicts:
#	src/coreclr/inc/jiteeversionguid.h
@jamesburton

Copy link
Copy Markdown
ContributorAuthor

CI status update on head 098843d73a1 (post-merge): 4 remaining red checks, none related to this PR.

CheckVerdict
Libraries Test Run checked coreclr linux_musl x64 DebugHelix-infra flake — Unable to pull image mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.23-helix-amd64@sha256:… exit -4 on 3 work items. Same Docker-registry pull pattern as the earlier 52-failure cascade, just a different prereq image.
Libraries Test Run checked coreclr osx arm64 DebugKnown flake — Microsoft.Extensions.FileProviders.PhysicalFileProviderTests.TokensFiredForNewDirectoryContentsOnRename matched against #104823 (PhysicalFilesWatcher symlink). Libraries-side test, no JIT/intrinsics correlation.
runtimeRollup of the two legs above.
Build AnalysisGates on the rollup.

The build's PR-file correlation against the failing tests is zero (Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs and the alpine-3.23 docker pull aren't in our diff). Happy to retry the legs on request, but nothing here to fix in code.

# Conflicts:
#	src/coreclr/inc/jiteeversionguid.h
Comment threadsrc/coreclr/jit/lsraxarch.cpp
# Conflicts:
#	src/coreclr/inc/jiteeversionguid.h
@jamesburton

Copy link
Copy Markdown
ContributorAuthor

Refreshed against upstream/main again (head 9a72325abfa, JIT-EE GUID rotated for the merge). The intrinsic surface and the V512VersionOfIsa + lowering-assert fixes are unchanged from before; rebuild + AvxVnni.V512 functional probe on Zen5 still confirm VPDPBUSD512 lane0 = 24 FUNCTIONAL_OK=True.

This is the third merge-from-main cycle since Tanner's original approval, and each one invalidates the review and re-runs CI. Could we land the secondary review (or re-approval) when convenient? Happy to address any remaining concerns inline — the longer the gap, the more cycles like this we accumulate, and there are downstream consumers (BF16 kernel work on Zen5) waiting on this to merge before they can drop their workarounds. No urgency to disturb your weekend — flagging for when the queue clears next week.

@tannergooding

Copy link
Copy Markdown
Member

CC. @dotnet/jit-contrib this is still pending secondary review.

@tannergooding

Copy link
Copy Markdown
Member

/ba-g all jobs finished, build analysis stuck

@tannergooding
tannergooding merged commit 8207ad3 into dotnet:mainJun 27, 2026
187 checks passed
@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview7 milestone Jun 28, 2026
@jamesburton

Copy link
Copy Markdown
ContributorAuthor

Thanks @tannergooding, @EgorBo, @dhartglassMSFT — appreciate the review attention and the patience through the merge-rebase cycles. Downstream consumers (BF16 quant kernels on Zen5 / Strix Halo) can finally drop their workarounds once this is in the next nightly. 🙏

eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
## Summary - Add the managed `AvxVnni.V512` surface for AVX-512 VNNI
VPDPBUSD/VPDPWSSD intrinsics. - Wire CPUID AVX512-VNNI detection into
the runtime/JIT `AVXVNNI_V512` instruction-set flag. - Extend VPDP
codegen and LSRA handling to cover the new V512 intrinsic IDs. Closes#86849 ## Validation - `./build.cmd clr+libs -c Release -arch x64` -
`./build.cmd clr -c Release -arch x64` - Strix Halo hardware probe: -
`AvxVnni.V512.IsSupported == True` - `VPDPBUSD-zmm : got=160 want=160
OK` - `VPDPWSSD-zmm : got=8 want=8 OK` - `VPDPBUSDS-zmm: got=2147483647
... OK` - JIT disassembly includes EVEX-512 forms: - `vpdpbusd zmm0,
zmm1, ...` - `vpdpwssd zmm0, zmm1, ...` - `vpdpbusds zmm0, zmm1, ...`
## Compatibility note
Existing R2R images that record `Avx512Vnni` now map to the more precise
`AVXVNNI_V512` JIT ISA instead of the broader `AVX512v3` bucket. This is
intentional: AVX512-VNNI is a distinct CPUID feature and the new managed
API requires that specific capability, while retaining the existing R2R
numeric value (`Avx512Vnni = 79`).
---------
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 29, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIcommunity-contributionIndicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Add support for AVX-512 VNNI hardware instructions

7 participants

@jamesburton@tannergooding@jamesburtonfnz@JulieLeeMSFT@EgorBo@dhartglassMSFT