Use mwaitx when busy-waiting signals

Use mwaitx instructions when busy waiting for signals to reduce CPU
energy usage.
This can be disabled by setting HSA_ENABLE_MWAITX=0

Change-Id: Ic207895a491b2bf6dacba47ef0921df3faad5b5a
This commit is contained in:
David Yat Sin
2022-11-15 17:21:59 +00:00
parent 0ed1568afc
commit cc48dfdbff
8 changed files with 59 additions and 14 deletions
@@ -71,6 +71,7 @@ const char rocrbuildid[] __attribute__((used)) = "ROCR BUILD ID: " STRING(ROCR_B
namespace rocr {
namespace core {
bool g_use_interrupt_wait = true;
bool g_use_mwaitx = true;
Runtime* Runtime::runtime_singleton_ = NULL;
@@ -680,6 +681,10 @@ hsa_status_t Runtime::GetSystemInfo(hsa_system_info_t attribute, void* value) {
*(bool*)value = ret;
break;
}
case HSA_AMD_SYSTEM_INFO_MWAITX_ENABLED: {
*((bool*)value) = g_use_mwaitx;
break;
}
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
@@ -1405,6 +1410,7 @@ hsa_status_t Runtime::Load() {
flag_.Refresh();
g_use_interrupt_wait = flag_.enable_interrupt();
g_use_mwaitx = flag_.check_mwaitx(cpuinfo.mwaitx);
if (!AMD::Load()) {
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;