Skip to content

Use "native" for .NET 8, don't use "serialize" for .NET 7 #2464

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

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ private static string GetCoreRunToolchainDisplayName(IReadOnlyList<FileInfo> pat
return coreRunPath.FullName.Substring(lastCommonDirectorySeparatorIndex);
}

private static bool TryParse(string runtime, out RuntimeMoniker runtimeMoniker)
internal static bool TryParse(string runtime, out RuntimeMoniker runtimeMoniker)
{
int index = runtime.IndexOf('-');

Expand Down
18 changes: 16 additions & 2 deletions src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using System.IO;
using System.Linq;
using System.Text;
using BenchmarkDotNet.ConsoleArguments;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Extensions;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Portability.Cpu;
Expand Down Expand Up @@ -219,8 +221,20 @@ private string GetCurrentInstructionSet(Platform platform)
=> string.Join(",", GetCurrentProcessInstructionSets(platform));

// based on https://github.com/dotnet/runtime/blob/ce61c09a5f6fc71d8f717d3fc4562f42171869a0/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs#L727
private static IEnumerable<string> GetCurrentProcessInstructionSets(Platform platform)
private IEnumerable<string> GetCurrentProcessInstructionSets(Platform platform)
{
if (!ConfigParser.TryParse(TargetFrameworkMoniker, out RuntimeMoniker runtimeMoniker))
{
throw new NotSupportedException($"Invalid TFM: '{TargetFrameworkMoniker}'");
}

if (platform == RuntimeInformation.GetCurrentPlatform() // "native" does not support cross-compilation (so does BDN for now)
&& runtimeMoniker >= RuntimeMoniker.NativeAot80)
{
yield return "native"; // added in .NET 8 https://github.com/dotnet/runtime/pull/87865
yield break;
}

switch (platform)
{
case Platform.X86:
Expand All @@ -242,7 +256,7 @@ private static IEnumerable<string> GetCurrentProcessInstructionSets(Platform pla
if (HardwareIntrinsics.IsX86PclmulqdqSupported) yield return "pclmul";
if (HardwareIntrinsics.IsX86PopcntSupported) yield return "popcnt";
if (HardwareIntrinsics.IsX86AvxVnniSupported) yield return "avxvnni";
if (HardwareIntrinsics.IsX86SerializeSupported) yield return "serialize";
if (HardwareIntrinsics.IsX86SerializeSupported && runtimeMoniker > RuntimeMoniker.NativeAot70) yield return "serialize"; // https://github.com/dotnet/BenchmarkDotNet/issues/2463#issuecomment-1809625008
Copy link
Member

Choose a reason for hiding this comment

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

This list is missing intrinsics added in .NET 8 but maybe that's not relevant if this is for 7 and below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. But as you wrote, it's not relevant if we use "native" in .NET 8

break;
case Platform.Arm64:
if (HardwareIntrinsics.IsArmBaseSupported) yield return "base";
Expand Down