Skip to content

Commit

Permalink
Use "native" for .NET 8, don't use "serialize" for .NET 7 (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsitnik authored Nov 14, 2023
1 parent db4d8b6 commit e93b2b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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
break;
case Platform.Arm64:
if (HardwareIntrinsics.IsArmBaseSupported) yield return "base";
Expand Down

0 comments on commit e93b2b1

Please sign in to comment.