-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: Expose xarch serialize instruction. #66467
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics Issue DetailsBackground and motivationCurrently, the However, Full details of the API Proposalnamespace System.Runtime.Intrinsics.X86
{
/// <summary>
/// This class provides access to Intel SERIALIZE hardware instruction via intrinsics
/// </summary>
[Intrinsic]
[CLSCompliant(false)]
public abstract class Serialize : X86Base
{
internal Serialize() { }
public static new bool IsSupported { get => IsSupported; }
[Intrinsic]
public new abstract class X64 : X86Base.X64
{
internal X64() { }
public static new bool IsSupported { get => IsSupported; }
}
/// <summary>
/// void _serialize (void);
/// </summary>
public static void Serialize() => Serialize();
}
} API UsageBroadly speaking, the developer can issue Serialize.Serialize();
if (someCondition)
{
// ...
} Alternative Designsdotnet developers currently need to call RisksAs
|
Thanks for the proposal here! I've gone ahead and marked it ready for review. Notably, we can't name the class and method both I don't have a strong preference, however. |
Thanks for looking at it! |
Hi @tannergooding , I can see this API hasn't been discussed yet (I believe) in the API proposal review meetings. Is there a long backlog of discussions before this would get discussed? Thanks! |
There is a decent backlog of issues which can be seen here: https://apireview.net/. If it is important for this to make it into .NET 7 (which will ship around November) than we can prioritize it further. |
Thank you @tannergooding , I think this is ok for now. Thanks for moving it to the .NET 7 milestone. |
namespace System.Runtime.Intrinsics.X86;
[Intrinsic]
[CLSCompliant(false)]
public abstract class X86Serialize : X86Base
{
public static new bool IsSupported { get; }
[Intrinsic]
public new abstract class X64 : X86Base.X64
{
public static new bool IsSupported { get; }
}
public static void Serialize();
} |
@anthonycanino, this is approved now and we can feel free to implement it whenever someone has availability. |
@tannergooding is adding the intrinsic lowering for the mono llvm path required for this implemtation, as seen in (#61707) or is adding it to RyuJIT enough? |
It shouldn't be required since this is a new ISA and However, it is generally preferable to bring both online where possible. CC. @fanyang-mono |
Yes, if it is possible, it would be nice to add intrinsics support to Mono at the same time as CoreCLR. And I could answer questions if there is any, regarding to Mono. |
Would that include the mini and llvm lowering pathway of mono, or just one? |
Hi @tannergooding can you answer a question regarding adding a new ISA to RyuJIT? Currently, I am adding just two lines to the InstructionSetDesc.txt...
and generating with I'm trying to get the superpmi diffs stable so I can test a branch of mine that does implement the intrinsic. |
Right, I'm not sure what the best way to get a diff in this case is. CC. @dotnet/jit-contrib who may have advice here |
You can find instructions here: https://gist.github.com/EgorBo/a72bfa70f08a4d890241037c0fc1fb93 (replace |
@AndyAyersMS will this work in my case though? Since I am creating a new ISA, I don't think I can isolate the base jit changes from the C# changes because of the re-generated corejit interface via InstructionSetDesc.txt. Essentially, I cannot only edit the jit due to the new ISA being needed for the JIT intrinsic nodes etc. |
Yes, it should work -- you would be comparing results from two entirely different builds. |
Both mini and LLVM. |
This was completed in #68677 |
Background and motivation
Currently, the
cpuid
instruction also functions as a full serializing instruction --- one that ensures all modifications to flags, registers, and memory are drained before the next instruction can execute --- on x86 hardware. Executing a serializing instructions on P6 and more recent processor families constrain speculative execution because the results of speculatively executed instructions are discarded (seeChapter 8: Multiple-Processor Management
in the Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A)However,
cpuid
has overhead in that it clobbersEAX
,EBX
,ECX
, andEDX
registers. Intel exposes a new instruction,serialize
under thecpuid
feature flagSERIALIZE
which acts as a full serializing instruction without the overhead of clobbering the registers ascpuid
does.Full details of the
serialize
instruction can be found inChapter 2.1 Instruction Set Reference
in Intel Architecture Instruction Set Extensions and Future Features.API Proposal
API Usage
Broadly speaking, the developer can issue
X86Serialize.Serialize()
whenever they want to serialize the instruction stream before a branching conditional:Alternative Designs
dotnet developers currently need to call
System.Runtime.Intrinsics.X86.X86Base.CpuId()
to issue a full serializing instruction which has the extra overhead stated above as opposed to issuing theserialize
instruction.Risks
As
serialize
functions as an alternative tocpuid
with less overhead and a 0-arg use, we don't foresee any additional risks here.The text was updated successfully, but these errors were encountered: