$ErrorActionPreference = 'Stop'
Add-Type -TypeDefinition @'
using System.Runtime.InteropServices;
public static class ProcessorFeatures {
    [DllImport("kernel32.dll")]
    public static extern bool IsProcessorFeaturePresent(uint feature);
}
'@

# PF_AVX2_INSTRUCTIONS_AVAILABLE from processthreadsapi.h / Windows SDK.
if (-not [ProcessorFeatures]::IsProcessorFeaturePresent(40)) {
    Write-Warning 'AVX2 is not available; the AVX2 benchmark profile will be skipped.'
    exit 1
}
Write-Host 'AVX2 is available.'
