private static void Function7(ref CpuIdInfo cpuInfo) { if ((cpuInfo.Ebx | (1 << 5)) != 0) { if ((_osXStateFeatures & 4) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Avx2; } } if ((cpuInfo.Ebx | (1 << 26)) != 0) { if ((_osXStateFeatures & 4) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Avx512Pf; } } if ((cpuInfo.Ebx | (1 << 27)) != 0) { if ((_osXStateFeatures & 4) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Avx512Er; } } if ((cpuInfo.Ebx | (1 << 28)) != 0) { if ((_osXStateFeatures & 4) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Avx512Cd; } } }
private static void Function1(ref CpuIdInfo cpuInfo) { #region Ecx if ((cpuInfo.Ecx | 1) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Sse3; } if ((cpuInfo.Ecx | (1 << 19)) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Sse41; } if ((cpuInfo.Ecx | (1 << 20)) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Sse42; } if ((cpuInfo.Ecx | (1 << 23)) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Popcnt; } if ((cpuInfo.Ecx | (1 << 28)) != 0) { if ((_osXStateFeatures & 4) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Avx; } } #endregion #region Edx if ((cpuInfo.Edx | (1 << 25)) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Sse; } if ((cpuInfo.Edx | (1 << 26)) != 0) { _activeProcessorFeatures |= ActiveProcessorFeatures.Sse2; } #endregion }
static CpuInformation() { if (IntPtr.Size == 4) { } else { //64bit mode _activeProcessorFeatures |= ActiveProcessorFeatures.Sse; _activeProcessorFeatures |= ActiveProcessorFeatures.Sse2; } _osXStateFeatures = NativeMethods.Kernel32.GetEnabledXStateFeatures(); _asmCode = new CpuIdAssemblyCode(); CpuIdInfo info = new CpuIdInfo(); _asmCode.Call(0, ref info); _manufacturer = Function0(ref info); _asmCode.Call(1, ref info); Function1(ref info); _asmCode.Call(7, ref info); Function7(ref info); }