Use RTM instructions (skylake+)

This commit is contained in:
Nekotekina 2017-07-18 20:03:47 +03:00
parent 0fa148e65e
commit b24eb621ae
8 changed files with 190 additions and 21 deletions

View file

@ -28,7 +28,26 @@ namespace utils
inline bool has_rtm()
{
return get_cpuid(0, 0)[0] >= 0x7 && get_cpuid(7, 0)[1] & 0x800;
// Check RTM and MPX extensions in order to filter out TSX on Haswell CPUs
return get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x4800) == 0x4800;
}
inline bool transaction_enter()
{
while (true)
{
const auto status = _xbegin();
if (status == _XBEGIN_STARTED)
{
return true;
}
if (!(status & _XABORT_RETRY))
{
return false;
}
}
}
std::string get_system_info();