mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Add tests for SSE3 capability
This commit is contained in:
@@ -262,14 +262,8 @@ String SystemStats::getUserRegion() { return AndroidStatsHelpers::getLocale
|
|||||||
String SystemStats::getDisplayLanguage() { return getUserLanguage(); }
|
String SystemStats::getDisplayLanguage() { return getUserLanguage(); }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
SystemStats::CPUFlags::CPUFlags()
|
void CPUInformation::initialise() noexcept
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
hasMMX = false;
|
|
||||||
hasSSE = false;
|
|
||||||
hasSSE2 = false;
|
|
||||||
has3DNow = false;
|
|
||||||
|
|
||||||
numCpus = bmax (1, sysconf (_SC_NPROCESSORS_ONLN));
|
numCpus = bmax (1, sysconf (_SC_NPROCESSORS_ONLN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,12 +127,13 @@ String SystemStats::getUserRegion() { return getLocaleValue (_NL_IDENTIFICA
|
|||||||
String SystemStats::getDisplayLanguage() { return getUserLanguage(); }
|
String SystemStats::getDisplayLanguage() { return getUserLanguage(); }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
SystemStats::CPUFlags::CPUFlags()
|
void CPUInformation::initialise() noexcept
|
||||||
{
|
{
|
||||||
const String flags (LinuxStatsHelpers::getCpuInfo ("flags"));
|
const String flags (LinuxStatsHelpers::getCpuInfo ("flags"));
|
||||||
hasMMX = flags.contains ("mmx");
|
hasMMX = flags.contains ("mmx");
|
||||||
hasSSE = flags.contains ("sse");
|
hasSSE = flags.contains ("sse");
|
||||||
hasSSE2 = flags.contains ("sse2");
|
hasSSE2 = flags.contains ("sse2");
|
||||||
|
hasSSE3 = flags.contains ("sse3");
|
||||||
has3DNow = flags.contains ("3dnow");
|
has3DNow = flags.contains ("3dnow");
|
||||||
|
|
||||||
numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1;
|
numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1;
|
||||||
|
|||||||
@@ -64,21 +64,17 @@ namespace SystemStatsHelpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
SystemStats::CPUFlags::CPUFlags()
|
void CPUInformation::initialise() noexcept
|
||||||
{
|
{
|
||||||
#if BEAST_INTEL && ! BEAST_NO_INLINE_ASM
|
#if BEAST_INTEL && ! BEAST_NO_INLINE_ASM
|
||||||
uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0;
|
uint32 a = 0, b = 0, d = 0, c = 0;
|
||||||
SystemStatsHelpers::doCPUID (familyModel, extFeatures, dummy, features, 1);
|
SystemStatsHelpers::doCPUID (a, b, c, d, 1);
|
||||||
|
|
||||||
hasMMX = (features & (1u << 23)) != 0;
|
hasMMX = (d & (1u << 23)) != 0;
|
||||||
hasSSE = (features & (1u << 25)) != 0;
|
hasSSE = (d & (1u << 25)) != 0;
|
||||||
hasSSE2 = (features & (1u << 26)) != 0;
|
hasSSE2 = (d & (1u << 26)) != 0;
|
||||||
has3DNow = (extFeatures & (1u << 31)) != 0;
|
has3DNow = (b & (1u << 31)) != 0;
|
||||||
#else
|
hasSSE3 = (c & (1u << 0)) != 0;
|
||||||
hasMMX = false;
|
|
||||||
hasSSE = false;
|
|
||||||
hasSSE2 = false;
|
|
||||||
has3DNow = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BEAST_IOS || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
|
#if BEAST_IOS || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
|
||||||
|
|||||||
@@ -99,16 +99,13 @@ String SystemStats::getCpuVendor()
|
|||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
SystemStats::CPUFlags::CPUFlags()
|
void CPUInformation::initialise() noexcept
|
||||||
{
|
{
|
||||||
hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0;
|
hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0;
|
||||||
hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0;
|
hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0;
|
||||||
hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0;
|
hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0;
|
||||||
#ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE
|
hasSSE3 = IsProcessorFeaturePresent (13 /*PF_SSE3_INSTRUCTIONS_AVAILABLE*/) != 0;
|
||||||
has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0;
|
has3DNow = IsProcessorFeaturePresent (7 /*PF_AMD3D_INSTRUCTIONS_AVAILABLE*/) != 0;
|
||||||
#else
|
|
||||||
has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYSTEM_INFO systemInfo;
|
SYSTEM_INFO systemInfo;
|
||||||
GetNativeSystemInfo (&systemInfo);
|
GetNativeSystemInfo (&systemInfo);
|
||||||
|
|||||||
@@ -21,12 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
const SystemStats::CPUFlags& SystemStats::getCPUFlags()
|
|
||||||
{
|
|
||||||
static CPUFlags cpuFlags;
|
|
||||||
return cpuFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
String SystemStats::getBeastVersion()
|
String SystemStats::getBeastVersion()
|
||||||
{
|
{
|
||||||
// Some basic tests, to keep an eye on things and make sure these types work ok
|
// Some basic tests, to keep an eye on things and make sure these types work ok
|
||||||
@@ -62,6 +56,34 @@ String SystemStats::getBeastVersion()
|
|||||||
static BeastVersionPrinter beastVersionPrinter;
|
static BeastVersionPrinter beastVersionPrinter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
struct CPUInformation
|
||||||
|
{
|
||||||
|
CPUInformation() noexcept
|
||||||
|
: numCpus (0), hasMMX (false), hasSSE (false),
|
||||||
|
hasSSE2 (false), hasSSE3 (false), has3DNow (false)
|
||||||
|
{
|
||||||
|
initialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initialise() noexcept;
|
||||||
|
|
||||||
|
int numCpus;
|
||||||
|
bool hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const CPUInformation& getCPUInformation() noexcept
|
||||||
|
{
|
||||||
|
static CPUInformation info;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SystemStats::getNumCpus() noexcept { return getCPUInformation().numCpus; }
|
||||||
|
bool SystemStats::hasMMX() noexcept { return getCPUInformation().hasMMX; }
|
||||||
|
bool SystemStats::hasSSE() noexcept { return getCPUInformation().hasSSE; }
|
||||||
|
bool SystemStats::hasSSE2() noexcept { return getCPUInformation().hasSSE2; }
|
||||||
|
bool SystemStats::hasSSE3() noexcept { return getCPUInformation().hasSSE3; }
|
||||||
|
bool SystemStats::has3DNow() noexcept { return getCPUInformation().has3DNow; }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
String SystemStats::getStackBacktrace()
|
String SystemStats::getStackBacktrace()
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ public:
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
// CPU and memory information..
|
// CPU and memory information..
|
||||||
|
|
||||||
/** Returns the number of CPUs. */
|
/** Returns the number of CPU cores. */
|
||||||
static int getNumCpus() noexcept { return getCPUFlags().numCpus; }
|
static int getNumCpus() noexcept;
|
||||||
|
|
||||||
/** Returns the approximate CPU speed.
|
/** Returns the approximate CPU speed.
|
||||||
@returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
|
@returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
|
||||||
@@ -135,17 +135,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
static String getCpuVendor();
|
static String getCpuVendor();
|
||||||
|
|
||||||
/** Checks whether Intel MMX instructions are available. */
|
static bool hasMMX() noexcept; /**< Returns true if Intel MMX instructions are available. */
|
||||||
static bool hasMMX() noexcept { return getCPUFlags().hasMMX; }
|
static bool hasSSE() noexcept; /**< Returns true if Intel SSE instructions are available. */
|
||||||
|
static bool hasSSE2() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
|
||||||
/** Checks whether Intel SSE instructions are available. */
|
static bool hasSSE3() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
|
||||||
static bool hasSSE() noexcept { return getCPUFlags().hasSSE; }
|
static bool has3DNow() noexcept; /**< Returns true if AMD 3DNOW instructions are available. */
|
||||||
|
|
||||||
/** Checks whether Intel SSE2 instructions are available. */
|
|
||||||
static bool hasSSE2() noexcept { return getCPUFlags().hasSSE2; }
|
|
||||||
|
|
||||||
/** Checks whether AMD 3DNOW instructions are available. */
|
|
||||||
static bool has3DNow() noexcept { return getCPUFlags().has3DNow; }
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Finds out how much RAM is in the machine.
|
/** Finds out how much RAM is in the machine.
|
||||||
@@ -179,19 +173,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
struct CPUFlags
|
|
||||||
{
|
|
||||||
CPUFlags();
|
|
||||||
|
|
||||||
int numCpus;
|
|
||||||
bool hasMMX : 1;
|
|
||||||
bool hasSSE : 1;
|
|
||||||
bool hasSSE2 : 1;
|
|
||||||
bool has3DNow : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
SystemStats();
|
SystemStats();
|
||||||
static const CPUFlags& getCPUFlags();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user