Skip to content

[API Proposal]: x64 CLDEMOTE Intrinsics #107022

Open
@MineCake147E

Description

Background and motivation

CLDEMOTE is supported by Intel in the Sapphire Rapids and newer architectures.
It allows us to let the CPU move the specified cache line to a level more distant from the core without writing back to memory, accelerating subsequent accesses to the line by other cores in the same coherence domain.
This might be useful for passing some data between cores using shared memory.

API Proposal

namespace System.Runtime.Intrinsics.X86;

public abstract class CLDemote : X86Base
{
    public static bool IsSupported { get; }
    public static unsafe void DemoteCacheLine(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
v = 0;
CLDemote.DemoteCacheLine(Unsafe.AsPointer(ref v));

Alternative Designs

  • There may be a better name for CLDemote

Risks

None

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions