[*] i swore i replaced this with a tpause before

[*] ...and the docs arent clear on whether or not this clock value is relative or absolute
This commit is contained in:
Reece Wilson 2024-05-06 22:04:26 +01:00
parent 316fb3f6b2
commit 8e1c74a5df
2 changed files with 30 additions and 4 deletions

View File

@ -117,7 +117,7 @@ namespace Aurora::Threading
#if (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86))
if (AuThreadPrimitives::ThrdCfg::gIsIntelAlderLakeOrGreater)
{
_tpause(0, 10000);
_tpause(0, __rdtsc() + 10000);
}
else
#endif
@ -168,7 +168,7 @@ namespace Aurora::Threading
#if (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86))
if (AuThreadPrimitives::ThrdCfg::gIsIntelAlderLakeOrGreater)
{
_tpause(0, 1000);
_tpause(0, __rdtsc() + 1000);
}
else
#endif

View File

@ -103,6 +103,19 @@ namespace Aurora::Threading::Primitives
inline AuUInt32 gUseFutexRWLock {};
inline AuUInt32 gPreferFutexEvent {};
static constexpr AuUInt32 kMWAITXUseTSC = (1 << 1);
static constexpr AuUInt32 kMWAITXAllowInterrupts = (1 << 0);
static constexpr AuUInt32 kMWAITXFaultGP0 = (1 << 31);
static constexpr AuUInt32 kMWAITXWaitOnStore = 0;
static constexpr AuUInt32 kMWAITXWaitOnStoreTimed = kMWAITXWaitOnStore | kMWAITXUseTSC;
struct Blocky
{
SMTAtomic_t a;
};
inline const AuAlignTo<16, Blocky> kMassiveBlock;
void InitAdaptiveThreshold();
void InitAdaptiveThresholdFirstTime();
void InitCfg();
@ -227,7 +240,20 @@ namespace Aurora::Threading::Primitives
}
else
{
_umwait(1, __rdtsc() + uCount);
_tpause(0, __rdtsc() + uCount);
bRet = callback();
}
}
else if (ThrdCfg::gIsZen3OrGreater)
{
if (callback())
{
bRet = true;
}
else
{
_mm_monitorx(&kMassiveBlock, 0, 0);
_mm_mwaitx(kMWAITXUseTSC, 0, uCount);
bRet = callback();
}
}
@ -461,7 +487,7 @@ namespace Aurora::Threading::Primitives
}
else
{
_mm_mwaitx(2, 0, uCount);
_mm_mwaitx(kMWAITXWaitOnStoreTimed, 0, uCount);
bRet = callback();
}
}