mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-19 04:10:54 +00:00
cpu info check
find avx2 and avx512
This commit is contained in:
parent
88da6f60f6
commit
b6ea96f367
2 changed files with 25 additions and 5 deletions
|
|
@ -75,10 +75,12 @@ enum ProcessorProperties
|
|||
CPU_PROP_SSE4_1 = (1<<7), ///< Supports SSE4_1 instruction set extension.
|
||||
CPU_PROP_SSE4_2 = (1<<8), ///< Supports SSE4_2 instruction set extension.
|
||||
CPU_PROP_AVX = (1<<9), ///< Supports AVX256 instruction set extension.
|
||||
CPU_PROP_MP = (1<<10), ///< This is a multi-processor system.
|
||||
CPU_PROP_LE = (1<<11), ///< This processor is LITTLE ENDIAN.
|
||||
CPU_PROP_64bit = (1<<12), ///< This processor is 64-bit capable
|
||||
CPU_PROP_NEON = (1<<13), ///< Supports the Arm Neon instruction set extension.
|
||||
CPU_PROP_AVX2 = (1<<10), ///< Supports AVX256 instruction set extension.
|
||||
CPU_PROP_AVX512 = (1<<11), ///< Supports AVX256 instruction set extension.
|
||||
CPU_PROP_MP = (1<<12), ///< This is a multi-processor system.
|
||||
CPU_PROP_LE = (1<<13), ///< This processor is LITTLE ENDIAN.
|
||||
CPU_PROP_64bit = (1<<14), ///< This processor is 64-bit capable
|
||||
CPU_PROP_NEON = (1<<15), ///< Supports the Arm Neon instruction set extension.
|
||||
};
|
||||
|
||||
/// Processor info manager.
|
||||
|
|
|
|||
|
|
@ -72,13 +72,15 @@ enum CpuFlags
|
|||
|
||||
BIT_XSAVE_RESTORE = BIT(27),
|
||||
BIT_AVX = BIT(28),
|
||||
BIT_AVX2 = BIT(5),
|
||||
BIT_AVX512F = BIT(16)
|
||||
};
|
||||
|
||||
static void detectCpuFeatures(Platform::SystemInfo_struct::Processor &processor)
|
||||
{
|
||||
S32 cpuInfo[4];
|
||||
__cpuid(cpuInfo, 1);
|
||||
//U32 eax = cpuInfo[0]; // eax
|
||||
int nIds = cpuInfo[0];
|
||||
U32 edx = cpuInfo[3]; // edx
|
||||
U32 ecx = cpuInfo[2]; // ecx
|
||||
|
||||
|
|
@ -90,6 +92,18 @@ static void detectCpuFeatures(Platform::SystemInfo_struct::Processor &processor)
|
|||
processor.properties |= (ecx & BIT_SSE4_1) ? CPU_PROP_SSE4_1 : 0;
|
||||
processor.properties |= (ecx & BIT_SSE4_2) ? CPU_PROP_SSE4_2 : 0;
|
||||
|
||||
if (nIds >= 7)
|
||||
{
|
||||
int ext[4];
|
||||
__cpuidex(ext, 7, 0);
|
||||
|
||||
if (ext[1] & (BIT_AVX2)) // EBX bit 5
|
||||
processor.properties |= CPU_PROP_AVX2;
|
||||
|
||||
if (ext[1] & (BIT_AVX512F)) // AVX-512 Foundation
|
||||
processor.properties |= CPU_PROP_AVX512;
|
||||
}
|
||||
|
||||
// AVX detection requires that xsaverestore is supported
|
||||
if (ecx & BIT_XSAVE_RESTORE && ecx & BIT_AVX)
|
||||
{
|
||||
|
|
@ -176,6 +190,10 @@ void Processor::init()
|
|||
Con::printf(" SSE4.2 detected" );
|
||||
if (Platform::SystemInfo.processor.properties & CPU_PROP_AVX)
|
||||
Con::printf(" AVX detected");
|
||||
if (Platform::SystemInfo.processor.properties & CPU_PROP_AVX2)
|
||||
Con::printf(" AVX2 detected");
|
||||
if (Platform::SystemInfo.processor.properties & CPU_PROP_AVX512)
|
||||
Con::printf(" AVX512 detected");
|
||||
|
||||
if (Platform::SystemInfo.processor.properties & CPU_PROP_MP)
|
||||
Con::printf(" MultiCore CPU detected [%i cores, %i logical]", Platform::SystemInfo.processor.numPhysicalProcessors, Platform::SystemInfo.processor.numLogicalProcessors);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue