Skip to content
Snippets Groups Projects
Commit b77fe6dc authored by Tofu Linden's avatar Tofu Linden
Browse files

DEV-45468 SNOW-108: Fast timers are broken / badly-scaled on linux

more reliable fix based on feedback from Richard.  dicked with the Darwin results too since those seemed wrong based on the same feedback (also covered in test plan).
parent 3d771ed8
No related branches found
No related tags found
No related merge requests found
...@@ -113,7 +113,7 @@ inline U64 LLFastTimer::getCPUClockCount64() ...@@ -113,7 +113,7 @@ inline U64 LLFastTimer::getCPUClockCount64()
struct timespec tp; struct timespec tp;
#ifdef CLOCK_MONOTONIC // MONOTONIC supported at build-time? #ifdef CLOCK_MONOTONIC // MONOTONIC supported at build-time?
if (-1 == clock_gettime(CLOCK_MONOTONIC,&tp)) // if MONOTONIC isn't supported at runtime, try REALTIME if (-1 == clock_gettime(CLOCK_MONOTONIC,&tp)) // if MONOTONIC isn't supported at runtime then ouch, try REALTIME
#endif #endif
clock_gettime(CLOCK_REALTIME,&tp); clock_gettime(CLOCK_REALTIME,&tp);
...@@ -122,7 +122,7 @@ inline U64 LLFastTimer::getCPUClockCount64() ...@@ -122,7 +122,7 @@ inline U64 LLFastTimer::getCPUClockCount64()
inline U32 LLFastTimer::getCPUClockCount32() inline U32 LLFastTimer::getCPUClockCount32()
{ {
return (U32)LLFastTimer::getCPUClockCount64(); return (U32)(LLFastTimer::getCPUClockCount64() >> 8);
} }
#endif // (LL_LINUX || LL_SOLARIS)) #endif // (LL_LINUX || LL_SOLARIS))
...@@ -134,14 +134,14 @@ inline U32 LLFastTimer::getCPUClockCount32() ...@@ -134,14 +134,14 @@ inline U32 LLFastTimer::getCPUClockCount32()
{ {
U64 x; U64 x;
__asm__ volatile (".byte 0x0f, 0x31": "=A"(x)); __asm__ volatile (".byte 0x0f, 0x31": "=A"(x));
return (U32)x >> 8; return (U32)(x >> 8);
} }
inline U64 LLFastTimer::getCPUClockCount64() inline U64 LLFastTimer::getCPUClockCount64()
{ {
U64 x; U64 x;
__asm__ volatile (".byte 0x0f, 0x31": "=A"(x)); __asm__ volatile (".byte 0x0f, 0x31": "=A"(x));
return x >> 8; return x;
} }
#endif #endif
...@@ -154,7 +154,7 @@ inline U64 LLFastTimer::getCPUClockCount64() ...@@ -154,7 +154,7 @@ inline U64 LLFastTimer::getCPUClockCount64()
inline U32 LLFastTimer::getCPUClockCount32() inline U32 LLFastTimer::getCPUClockCount32()
{ {
return (U32)get_clock_count(); return (U32)(get_clock_count()>>8);
} }
inline U64 LLFastTimer::getCPUClockCount64() inline U64 LLFastTimer::getCPUClockCount64()
......
...@@ -226,12 +226,12 @@ void LLFastTimer::DeclareTimer::updateCachedPointers() ...@@ -226,12 +226,12 @@ void LLFastTimer::DeclareTimer::updateCachedPointers()
//static //static
#if LL_LINUX || LL_SOLARIS || ( LL_DARWIN && !(defined(__i386__) || defined(__amd64__)) ) #if LL_LINUX || LL_SOLARIS || ( LL_DARWIN && !(defined(__i386__) || defined(__amd64__)) )
U64 LLFastTimer::countsPerSecond() U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer
{ {
return sClockResolution; return sClockResolution >> 8;
} }
#else // windows or x86-mac #else // windows or x86-mac
U64 LLFastTimer::countsPerSecond() U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer
{ {
static U64 sCPUClockFrequency = U64(CProcessor().GetCPUFrequency(50)); static U64 sCPUClockFrequency = U64(CProcessor().GetCPUFrequency(50));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment