Skip to content

Commit e93b2b1

Browse files
authored
Use "native" for .NET 8, don't use "serialize" for .NET 7 (#2464)
1 parent db4d8b6 commit e93b2b1

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ private static string GetCoreRunToolchainDisplayName(IReadOnlyList<FileInfo> pat
763763
return coreRunPath.FullName.Substring(lastCommonDirectorySeparatorIndex);
764764
}
765765

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

src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text;
6+
using BenchmarkDotNet.ConsoleArguments;
67
using BenchmarkDotNet.Environments;
78
using BenchmarkDotNet.Extensions;
9+
using BenchmarkDotNet.Jobs;
810
using BenchmarkDotNet.Loggers;
911
using BenchmarkDotNet.Portability;
1012
using BenchmarkDotNet.Portability.Cpu;
@@ -219,8 +221,20 @@ private string GetCurrentInstructionSet(Platform platform)
219221
=> string.Join(",", GetCurrentProcessInstructionSets(platform));
220222

221223
// based on https://github.com/dotnet/runtime/blob/ce61c09a5f6fc71d8f717d3fc4562f42171869a0/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs#L727
222-
private static IEnumerable<string> GetCurrentProcessInstructionSets(Platform platform)
224+
private IEnumerable<string> GetCurrentProcessInstructionSets(Platform platform)
223225
{
226+
if (!ConfigParser.TryParse(TargetFrameworkMoniker, out RuntimeMoniker runtimeMoniker))
227+
{
228+
throw new NotSupportedException($"Invalid TFM: '{TargetFrameworkMoniker}'");
229+
}
230+
231+
if (platform == RuntimeInformation.GetCurrentPlatform() // "native" does not support cross-compilation (so does BDN for now)
232+
&& runtimeMoniker >= RuntimeMoniker.NativeAot80)
233+
{
234+
yield return "native"; // added in .NET 8 https://github.com/dotnet/runtime/pull/87865
235+
yield break;
236+
}
237+
224238
switch (platform)
225239
{
226240
case Platform.X86:
@@ -242,7 +256,7 @@ private static IEnumerable<string> GetCurrentProcessInstructionSets(Platform pla
242256
if (HardwareIntrinsics.IsX86PclmulqdqSupported) yield return "pclmul";
243257
if (HardwareIntrinsics.IsX86PopcntSupported) yield return "popcnt";
244258
if (HardwareIntrinsics.IsX86AvxVnniSupported) yield return "avxvnni";
245-
if (HardwareIntrinsics.IsX86SerializeSupported) yield return "serialize";
259+
if (HardwareIntrinsics.IsX86SerializeSupported && runtimeMoniker > RuntimeMoniker.NativeAot70) yield return "serialize"; // https://github.com/dotnet/BenchmarkDotNet/issues/2463#issuecomment-1809625008
246260
break;
247261
case Platform.Arm64:
248262
if (HardwareIntrinsics.IsArmBaseSupported) yield return "base";

0 commit comments

Comments
 (0)