BenchmarkDotNet
BenchmarkDotNet copied to clipboard
NativeAOT benchmark started from .Net Framework host doesn't have all intrinsics enabled
BDN 0.13.1.1835 from nightlies is supposed to run NativeAOT with current machines CPU features, yet with a .Net Framework host on an AVX2 machine I got:
// Runtime=.NET 7.0.0-rc.1.22401.2, X64 NativeAOT SSE4.2
// GC=Concurrent Workstation
// HardwareIntrinsics=SSE4.2,AES,LZCNT,PCLMUL,POPCNT VectorSize=128
which was due to the fact the host can't check for their support on Net Framework (I don't understand why it's SSE4.2, not SSE2 though, does NativeAOT default to that? if yes then that's a bit weird). A possible solution would be to generate a separate .Net app that'd perform the CPU checks and return the data to the Net Framework host.
A possible solution would be to generate a separate .Net app that'd perform the CPU checks and return the data to the Net Framework host.
To be honest I am not sure if we want to invest in such edge case scenario if there is an easy workaround (running host as .NET Core app). But I understand that it can lead to confusion (not apples to apples comparison depending on host process runtime).
@jkotas is there a way to tell ILC to use all available instructions? Sth like <IlcInstructionSet>current</IlcInstructionSet>?
We do not have that today. It would require duplicating the runtime hardware capabilities detection in the AOT compiler, or somehow getting access to the runtime detection logic,
The AOT compiler cannot use the trick with calling IsSupported properties like what Benchmark.NET does. We want to be able to compile the AOT compiler using itself. It means that the IsSupported properties return what the compiler was AOT compiled with, not the current capabilities of the machine.
I have opened https://github.com/dotnet/runtime/issues/73246 to have this tracked. It is not the first time that this option is being discussed.
running host as .NET Core app
AFAIK you have to use a Net Framework host in order to use it in a benchmark, so doing benchmarks with 2 hosts is at least annoying.
AFAIK you have to use a Net Framework host in order to use it in a benchmark, so doing benchmarks with 2 hosts is at least annoying
You don't: https://benchmarkdotnet.org/articles/configs/toolchains.html#multiple-frameworks-support
Support for instructionset:native merged in https://github.com/dotnet/runtime/pull/87865 and unless it gets reverted, will be available in .NET 8.