summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2019-02-06 14:57:28 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2019-02-06 14:57:28 +0000
commit02974728dc45d641ad6b833767150adcb8aaf5fe (patch)
tree314dc38187a89908d11005f5fe43cf2c96fdd0c7 /llvm/lib
parentae54e58b90a5e2208b6d3da5245eda6625dc1ed1 (diff)
downloadbcm5719-llvm-02974728dc45d641ad6b833767150adcb8aaf5fe.tar.gz
bcm5719-llvm-02974728dc45d641ad6b833767150adcb8aaf5fe.zip
[MCA] Speedup ResourceManager queries. NFCI
When a resource unit R is released, the ResourceManager notifies groups that contain R. Before this patch, the logic in method ResourceManager::release() implemented a potentially slow iterative search of dependent groups on the entire set of processor resources. This patch replaces that logic with a simpler (and often faster) lookup on array `Resource2Groups`. This patch gives an average speedup of ~3-4% (observed on a release build when testing for target btver2). No functional change intended. llvm-svn: 353301
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MCA/HardwareUnits/ResourceManager.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp b/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp
index f899b3d10c3..4cad4f40013 100644
--- a/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp
+++ b/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp
@@ -213,19 +213,20 @@ void ResourceManager::use(const ResourceRef &RR) {
}
void ResourceManager::release(const ResourceRef &RR) {
- ResourceState &RS = *Resources[getResourceStateIndex(RR.first)];
+ unsigned RSID = getResourceStateIndex(RR.first);
+ ResourceState &RS = *Resources[RSID];
bool WasFullyUsed = !RS.isReady();
RS.releaseSubResource(RR.second);
if (!WasFullyUsed)
return;
- for (std::unique_ptr<ResourceState> &Res : Resources) {
- ResourceState &Current = *Res;
- if (!Current.isAResourceGroup() || Current.getResourceMask() == RR.first)
- continue;
-
- if (Current.containsResource(RR.first))
- Current.releaseSubResource(RR.first);
+ // Notify groups that RR.first is now available again.
+ uint64_t Users = Resource2Groups[RSID];
+ while (Users) {
+ unsigned GroupIndex = getResourceStateIndex(Users & (-Users));
+ ResourceState &CurrentUser = *Resources[GroupIndex];
+ CurrentUser.releaseSubResource(RR.first);
+ Users &= Users - 1;
}
}
OpenPOWER on IntegriCloud