-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 System.Runtime.Intrinsics.X86.Aes256 and Aes512 #86952
Comments
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics Issue DetailsBackground and motivationOn some newer x86 CPUs VAES provides wider variants of encoding/decoding included in the older AES instruction set. The 256-bit VEX-encoded variant (effectively operating on 2 AES blocks in parallel using a single instruction) has a separate CPUID flag and is not dependent on AVX512 support. Additionally, if AVX512F is supported, a 512-bit EVEX-encoded variant is available. As expected, EVEX-encoded 128 and 256-bit variants are available if AVX512VL is supported. API Proposalnamespace System.Runtime.Intrinsics.X86;
public abstract class Vaes : Aes
{
public static new bool IsSupported { get; }
public new abstract class X64 : Aes.X64
{
public static new bool IsSupported { get; }
}
public static Vector256<byte> Decrypt(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> DecryptLast(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> Encrypt(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> EncryptLast(Vector256<byte> value, Vector256<byte> roundKey);
}
public static abstract class Avx512Vaes : Avx512F
{
public static new bool IsSupported { get; }
public new abstract class X64 : Avx512F.X64
{
public static new bool IsSupported { get; }
}
public new abstract class VL : Avx512F.VL
{
public static new bool IsSupported { get; }
public static Vector128<byte> Decrypt(Vector128<byte> value, Vector128<byte> roundKey);
public static Vector128<byte> DecryptLast(Vector128<byte> value, Vector128<byte> roundKey);
public static Vector256<byte> Encrypt(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> EncryptLast(Vector256<byte> value, Vector256<byte> roundKey);
}
public static Vector512<byte> Decrypt(Vector512<byte> value, Vector512<byte> roundKey);
public static Vector512<byte> DecryptLast(Vector512<byte> value, Vector512<byte> roundKey);
public static Vector512<byte> Encrypt(Vector512<byte> value, Vector512<byte> roundKey);
public static Vector512<byte> EncryptLast(Vector512<byte> value, Vector512<byte> roundKey);
} Note VAES doesn't include round key assist or inverse mix columns instructions. API UsageSame as AES intrinsics, except using wider vector types. Referenceshttps://en.wikichip.org/wiki/x86/vaes Alternative DesignsNo response RisksNo response
|
public new abstract class VL : Avx512F.VL
{
public static new bool IsSupported { get; }
public static Vector128<byte> Decrypt(Vector128<byte> value, Vector128<byte> roundKey);
public static Vector128<byte> DecryptLast(Vector128<byte> value, Vector128<byte> roundKey);
public static Vector256<byte> Encrypt(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> EncryptLast(Vector256<byte> value, Vector256<byte> roundKey);
} What's the benefit of exposing the EVEX variants separately? |
Technically, |
Users don't get to pick the prefix, the JIT picks based on the most optimal form. For V512, it's required to use EVEX. For V128/V256 it will pick VEX if only the lower 16 SIMD registers are used. If LSRA must allocate an extended SIMD register (one of the upper 16) or decides that it can take advantage of another EVEX only feature such as We intentionally do not duplicate APIs needlessly, and so we shouldn't need them under Given that, given the future for Avx10, and given what we had previously opted for with However, depending on how we decide to do |
@e4m2, could you update to follow the same general pattern as |
Thanks for the input. Updated! |
namespace System.Runtime.Intrinsics.X86;
public abstract class Aes
{
public abstract class V256
{
public static new bool IsSupported { get; }
public static Vector256<byte> Decrypt(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> DecryptLast(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> Encrypt(Vector256<byte> value, Vector256<byte> roundKey);
public static Vector256<byte> EncryptLast(Vector256<byte> value, Vector256<byte> roundKey);
}
public abstract class V512
{
public static Vector512<byte> Decrypt(Vector512<byte> value, Vector512<byte> roundKey);
public static Vector512<byte> DecryptLast(Vector512<byte> value, Vector512<byte> roundKey);
public static Vector512<byte> Encrypt(Vector512<byte> value, Vector512<byte> roundKey);
public static Vector512<byte> EncryptLast(Vector512<byte> value, Vector512<byte> roundKey);
}
} |
Background and motivation
On some newer x86 CPUs VAES provides wider variants of encoding/decoding included in the older AES instruction set.
The 256-bit VEX-encoded variant (effectively operating on 2 AES blocks in parallel using a single instruction) has a separate CPUID flag and is not dependent on AVX512 support. Additionally, if AVX512F is supported, a 512-bit EVEX-encoded variant is available. As expected, EVEX-encoded 128 and 256-bit variants are available if AVX512VL is supported.
API Proposal
Note VAES doesn't include round key assist or inverse mix columns instructions.
API Usage
Same as AES intrinsics, except using wider vector types.
Alternative Designs
No response
Risks
No response
References
https://en.wikichip.org/wiki/x86/vaes
https://en.wikipedia.org/wiki/AVX-512#VAES
https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#othertechs=VAES
The text was updated successfully, but these errors were encountered: