Try to check if cntcvt reads are monotonic.

https://lore.kernel.org/patchwork/patch/904607/
This commit is contained in:
Bartosz Taudul 2019-03-21 21:59:51 +01:00
parent 7f57b3dba9
commit 94ed1c637c

View File

@ -203,6 +203,26 @@ static int64_t SetupHwTimer()
sigaction( SIGILL, &oldact, nullptr );
GetTimeImpl = GetTimeImplCntvct;
// Check if cntcvt is monotonic (there is faulty hw out there)
enum { NumProbes = 32 * 1024 };
int64_t probe[NumProbes];
for( int j=0; j<10; j++ )
{
for( int i=0; i<NumProbes; i++ )
{
probe[i] = Profiler::GetTime();
}
for( int i=1; i<NumProbes; i++ )
{
if( probe[i] < probe[i-1] )
{
GetTimeImpl = GetTimeImplFallback;
return Profiler::GetTime();
}
}
}
return Profiler::GetTime();
}
#else