diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2019-02-20 14:53:18 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2019-02-20 14:53:18 +0000 |
commit | d882ad5e6efba7bc3059e450ec7c303acc40f0b0 (patch) | |
tree | 1eb637e7ce2895110d4c8aa42a2cd2dd096cda4c /llvm/include | |
parent | 14e15ec18dd23e75fe54a72dde203dc266390561 (diff) | |
download | bcm5719-llvm-d882ad5e6efba7bc3059e450ec7c303acc40f0b0.tar.gz bcm5719-llvm-d882ad5e6efba7bc3059e450ec7c303acc40f0b0.zip |
[MCA][ResourceManager] Add a table that maps processor resource indices to processor resource identifiers.
This patch adds a lookup table to speed up resource queries in the ResourceManager.
This patch also moves helper function 'getResourceStateIndex()' from
ResourceManager.cpp to Support.h, so that we can reuse that logic in the
SummaryView (and potentially other views in llvm-mca).
No functional change intended.
llvm-svn: 354470
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/MCA/HardwareUnits/ResourceManager.h | 6 | ||||
-rw-r--r-- | llvm/include/llvm/MCA/Support.h | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/llvm/include/llvm/MCA/HardwareUnits/ResourceManager.h b/llvm/include/llvm/MCA/HardwareUnits/ResourceManager.h index 3addaaf4775..2f91185516f 100644 --- a/llvm/include/llvm/MCA/HardwareUnits/ResourceManager.h +++ b/llvm/include/llvm/MCA/HardwareUnits/ResourceManager.h @@ -334,9 +334,13 @@ class ResourceManager { // Used to quickly identify groups that own a particular resource unit. std::vector<uint64_t> Resource2Groups; - // A table to map processor resource IDs to processor resource masks. + // A table that maps processor resource IDs to processor resource masks. SmallVector<uint64_t, 8> ProcResID2Mask; + // A table that maps resource indices to actual processor resource IDs in the + // scheduling model. + SmallVector<unsigned, 8> ResIndex2ProcResID; + // Keeps track of which resources are busy, and how many cycles are left // before those become usable again. SmallDenseMap<ResourceRef, unsigned> BusyResources; diff --git a/llvm/include/llvm/MCA/Support.h b/llvm/include/llvm/MCA/Support.h index fc36ed492d1..1da097c9092 100644 --- a/llvm/include/llvm/MCA/Support.h +++ b/llvm/include/llvm/MCA/Support.h @@ -94,6 +94,13 @@ public: void computeProcResourceMasks(const MCSchedModel &SM, MutableArrayRef<uint64_t> Masks); +// Returns the index of the highest bit set. For resource masks, the position of +// the highest bit set can be used to construct a resource mask identifier. +inline unsigned getResourceStateIndex(uint64_t Mask) { + assert(Mask && "Processor Resource Mask cannot be zero!"); + return (std::numeric_limits<uint64_t>::digits - countLeadingZeros(Mask)) - 1; +} + /// Compute the reciprocal block throughput from a set of processor resource /// cycles. The reciprocal block throughput is computed as the MAX between: /// - NumMicroOps / DispatchWidth |