Browse Source

Add SSE4.1, SSE4.2 and AVX2 system stat flags and fix documentation typo

tags/2021-05-28
hogliux 9 years ago
parent
commit
e6b4dcb6a2
6 changed files with 44 additions and 18 deletions
  1. +14
    -9
      examples/Demo/Source/Demos/SystemInfoDemo.cpp
  2. +3
    -0
      modules/juce_core/native/juce_linux_SystemStats.cpp
  3. +5
    -0
      modules/juce_core/native/juce_mac_SystemStats.mm
  4. +6
    -0
      modules/juce_core/native/juce_win32_SystemStats.cpp
  5. +6
    -2
      modules/juce_core/system/juce_SystemStats.cpp
  6. +10
    -7
      modules/juce_core/system/juce_SystemStats.h

+ 14
- 9
examples/Demo/Source/Demos/SystemInfoDemo.cpp View File

@@ -120,15 +120,20 @@ static String getAllSystemInfo()
<< "User language: " << SystemStats::getUserLanguage() << newLine << "User language: " << SystemStats::getUserLanguage() << newLine
<< "Display language: " << SystemStats::getDisplayLanguage() << newLine << "Display language: " << SystemStats::getDisplayLanguage() << newLine
<< newLine << newLine
<< "Number of CPUs: " << SystemStats::getNumCpus() << newLine
<< "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
<< "CPU vendor: " << SystemStats::getCpuVendor() << newLine
<< "CPU speed: " << SystemStats::getCpuSpeedInMegaherz() << " MHz" << newLine
<< "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
<< "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
<< "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
<< "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
<< "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
<< "Number of CPUs: " << SystemStats::getNumCpus() << newLine
<< "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
<< "CPU vendor: " << SystemStats::getCpuVendor() << newLine
<< "CPU speed: " << SystemStats::getCpuSpeedInMegaherz() << " MHz" << newLine
<< "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
<< "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
<< "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
<< "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
<< "CPU has SSSE3: " << (SystemStats::hasSSSE3() ? "yes" : "no") << newLine
<< "CPU has SSE4.1: " << (SystemStats::hasSSE41() ? "yes" : "no") << newLine
<< "CPU has SSE4.2: " << (SystemStats::hasSSE42() ? "yes" : "no") << newLine
<< "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
<< "CPU has AVX: " << (SystemStats::hasAVX() ? "yes" : "no") << newLine
<< "CPU has AVX2: " << (SystemStats::hasAVX2() ? "yes" : "no") << newLine
<< newLine << newLine
<< "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
<< "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine


+ 3
- 0
modules/juce_core/native/juce_linux_SystemStats.cpp View File

@@ -156,7 +156,10 @@ void CPUInformation::initialise() noexcept
hasSSE3 = flags.contains ("sse3"); hasSSE3 = flags.contains ("sse3");
has3DNow = flags.contains ("3dnow"); has3DNow = flags.contains ("3dnow");
hasSSSE3 = flags.contains ("ssse3"); hasSSSE3 = flags.contains ("ssse3");
hasSSE41 = flags.contains ("sse4_1");
hasSSE42 = flags.contains ("sse4_2");
hasAVX = flags.contains ("avx"); hasAVX = flags.contains ("avx");
hasAVX2 = flags.contains ("avx2");
numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1;
} }


+ 5
- 0
modules/juce_core/native/juce_mac_SystemStats.mm View File

@@ -81,7 +81,12 @@ void CPUInformation::initialise() noexcept
has3DNow = (b & (1u << 31)) != 0; has3DNow = (b & (1u << 31)) != 0;
hasSSE3 = (c & (1u << 0)) != 0; hasSSE3 = (c & (1u << 0)) != 0;
hasSSSE3 = (c & (1u << 9)) != 0; hasSSSE3 = (c & (1u << 9)) != 0;
hasSSE41 = (c & (1u << 20)) != 0;
hasSSE42 = (c & (1u << 19)) != 0;
hasAVX = (c & (1u << 28)) != 0; hasAVX = (c & (1u << 28)) != 0;
SystemStatsHelpers::doCPUID (a, b, c, d, 7);
hasAVX2 = (b & (1u << 5)) != 0;
#endif #endif
numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount]; numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount];


+ 6
- 0
modules/juce_core/native/juce_win32_SystemStats.cpp View File

@@ -107,8 +107,14 @@ void CPUInformation::initialise() noexcept
hasSSE3 = (info[2] & (1 << 0)) != 0; hasSSE3 = (info[2] & (1 << 0)) != 0;
hasAVX = (info[2] & (1 << 28)) != 0; hasAVX = (info[2] & (1 << 28)) != 0;
hasSSSE3 = (info[2] & (1 << 9)) != 0; hasSSSE3 = (info[2] & (1 << 9)) != 0;
hasSSE41 = (info[2] & (1 << 19)) != 0;
hasSSE42 = (info[2] & (1 << 20)) != 0;
has3DNow = (info[1] & (1 << 31)) != 0; has3DNow = (info[1] & (1 << 31)) != 0;
callCPUID (info, 7);
hasAVX2 = (info[1] & (1 << 5)) != 0;
SYSTEM_INFO systemInfo; SYSTEM_INFO systemInfo;
GetNativeSystemInfo (&systemInfo); GetNativeSystemInfo (&systemInfo);
numCpus = (int) systemInfo.dwNumberOfProcessors; numCpus = (int) systemInfo.dwNumberOfProcessors;


+ 6
- 2
modules/juce_core/system/juce_SystemStats.cpp View File

@@ -68,7 +68,8 @@ struct CPUInformation
CPUInformation() noexcept CPUInformation() noexcept
: numCpus (0), hasMMX (false), hasSSE (false), : numCpus (0), hasMMX (false), hasSSE (false),
hasSSE2 (false), hasSSE3 (false), has3DNow (false), hasSSE2 (false), hasSSE3 (false), has3DNow (false),
hasSSSE3 (false), hasAVX (false)
hasSSSE3 (false), hasSSE41 (false), hasSSE42 (false),
hasAVX (false), hasAVX2 (false)
{ {
initialise(); initialise();
} }
@@ -76,7 +77,7 @@ struct CPUInformation
void initialise() noexcept; void initialise() noexcept;
int numCpus; int numCpus;
bool hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow, hasSSSE3, hasAVX;
bool hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow, hasSSSE3, hasSSE41, hasSSE42, hasAVX, hasAVX2;
}; };
static const CPUInformation& getCPUInformation() noexcept static const CPUInformation& getCPUInformation() noexcept
@@ -92,7 +93,10 @@ bool SystemStats::hasSSE() noexcept { return getCPUInformation().hasSS
bool SystemStats::hasSSE2() noexcept { return getCPUInformation().hasSSE2; } bool SystemStats::hasSSE2() noexcept { return getCPUInformation().hasSSE2; }
bool SystemStats::hasSSE3() noexcept { return getCPUInformation().hasSSE3; } bool SystemStats::hasSSE3() noexcept { return getCPUInformation().hasSSE3; }
bool SystemStats::hasSSSE3() noexcept { return getCPUInformation().hasSSSE3; } bool SystemStats::hasSSSE3() noexcept { return getCPUInformation().hasSSSE3; }
bool SystemStats::hasSSE41() noexcept { return getCPUInformation().hasSSE41; }
bool SystemStats::hasSSE42() noexcept { return getCPUInformation().hasSSE42; }
bool SystemStats::hasAVX() noexcept { return getCPUInformation().hasAVX; } bool SystemStats::hasAVX() noexcept { return getCPUInformation().hasAVX; }
bool SystemStats::hasAVX2() noexcept { return getCPUInformation().hasAVX2; }
//============================================================================== //==============================================================================


+ 10
- 7
modules/juce_core/system/juce_SystemStats.h View File

@@ -152,13 +152,16 @@ public:
*/ */
static String getCpuVendor(); static String getCpuVendor();
static bool hasMMX() noexcept; /**< Returns true if Intel MMX instructions are available. */
static bool has3DNow() noexcept; /**< Returns true if AMD 3DNOW instructions are available. */
static bool hasSSE() noexcept; /**< Returns true if Intel SSE instructions are available. */
static bool hasSSE2() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
static bool hasSSE3() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
static bool hasSSSE3() noexcept; /**< Returns true if Intel SSSE3 instructions are available. */
static bool hasAVX() noexcept; /**< Returns true if Intel AVX instructions are available. */
static bool hasMMX() noexcept; /**< Returns true if Intel MMX instructions are available. */
static bool has3DNow() noexcept; /**< Returns true if AMD 3DNOW instructions are available. */
static bool hasSSE() noexcept; /**< Returns true if Intel SSE instructions are available. */
static bool hasSSE2() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
static bool hasSSE3() noexcept; /**< Returns true if Intel SSE3 instructions are available. */
static bool hasSSSE3() noexcept; /**< Returns true if Intel SSSE3 instructions are available. */
static bool hasSSE41() noexcept; /**< Returns true if Intel SSE4.1 instructions are available. */
static bool hasSSE42() noexcept; /**< Returns true if Intel SSE4.2 instructions are available. */
static bool hasAVX() noexcept; /**< Returns true if Intel AVX instructions are available. */
static bool hasAVX2() noexcept; /**< Returns true if Intel AVX2 instructions are available. */
//============================================================================== //==============================================================================
/** Finds out how much RAM is in the machine. /** Finds out how much RAM is in the machine.


Loading…
Cancel
Save