From d882ad5e6efba7bc3059e450ec7c303acc40f0b0 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Wed, 20 Feb 2019 14:53:18 +0000 Subject: [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 --- llvm/include/llvm/MCA/HardwareUnits/ResourceManager.h | 6 +++++- llvm/include/llvm/MCA/Support.h | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'llvm/include') 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 Resource2Groups; - // A table to map processor resource IDs to processor resource masks. + // A table that maps processor resource IDs to processor resource masks. SmallVector ProcResID2Mask; + // A table that maps resource indices to actual processor resource IDs in the + // scheduling model. + SmallVector ResIndex2ProcResID; + // Keeps track of which resources are busy, and how many cycles are left // before those become usable again. SmallDenseMap 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 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::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 -- cgit v1.2.3