Repository navigation
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.Intrinsicsneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Description
Background and motivation
AMD introduced 3DNow! in its K6-2, with PREFETCHW instruction that prefetches the specified memory region into the processor's cache while invalidating other cached copies, with the intention of overwriting there in the future.
Almost all instructions in 3DNow! are now deprecated in favor of SSE, but PREFETCH and PREFETCHW still remain and are implemented in Zen4.
Intel also started supporting PREFETCHW from CedarMill by treating them as NOP, and they even started actually implementing these functionalities since Broadwell.
It's nice to have support for PREFETCHW instruction, since we have one for Sse.Prefetch*.
API Proposal
namespace System.Runtime.Intrinsics.X86;
public abstract class PrefetchW : X86Base
{
public static bool IsSupported { get; }
public static unsafe void PrefetchWrite(void* address);
public abstract class X64 : X86Base.X64
{
public static bool IsSupported { get; }
}
}API Usage
// Somewhere in a class
private uint v;
// In a function
PrefetchW.PrefetchWrite(Unsafe.AsPointer(ref v));
// some instructions
if (p < 0) v++;Alternative Designs
- Adding equivalent functions with
scoped ref readonly Tinstead ofvoid*would be fine since it shouldn't throw anything, even the read access to the same address would result in anAccessViolationException.
Risks
Nothing more than one for existing *.Prefetch* instructions
Reacted by Cole Tobin and Raphael DUCOM
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.Intrinsicsneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
Activity
dotnet-policy-service commentedon Aug 23, 2024
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
See info in area-owners.md if you want to be subscribed.
touitou-dan commentedon Jun 23, 2026
For anyone following this: I've opened a collection-level proposal that's a direct consumer of x86 prefetch intrinsics: batched + software-prefetch lookups and enumeration for large Dictionary / ImmutableDictionary: │ #129513.
It uses Sse.Prefetch0 today; sharing as a concrete motivating use case for richer managed prefetch support. Measured roughly 2–3x on memory-bound workloads at 10M entries