15#ifndef LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
16#define LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
121 : ResourceUnitMask(UnitMask), NextInSequenceMask(UnitMask),
122 RemovedFromNextInSequence(0) {}
137 const unsigned ProcResourceDescIndex;
193 const int BufferSize;
196 unsigned AvailableSlots;
209 bool isSubResourceReady(
uint64_t SubResMask)
const {
210 return ReadyMask & SubResMask;
233 bool isReady(
unsigned NumUnits = 1)
const;
275 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
276 return AvailableSlots;
286 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
341 std::vector<std::unique_ptr<ResourceState>> Resources;
342 std::vector<std::unique_ptr<ResourceStrategy>> Strategies;
345 std::vector<uint64_t> Resource2Groups;
380 unsigned getNumUnits(
uint64_t ResourceID)
const;
384 void setCustomStrategyImpl(std::unique_ptr<ResourceStrategy> S,
394 unsigned ResourceID) {
396 "Invalid resource index in input!");
397 return setCustomStrategyImpl(std::move(S), ProcResID2Mask[ResourceID]);
437 if (
Desc.HasPartiallyOverlappingGroups)
464 for (
const std::unique_ptr<ResourceState> &Resource : Resources)
This file defines the DenseMap class.
@ Unavailable
We know the block is not fully available. This is a fixpoint.
Move duplicate certain instructions close to their use
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Default resource allocation strategy used by processor resource groups and processor resources with m...
DefaultResourceStrategy(uint64_t UnitMask)
void used(uint64_t Mask) override
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
virtual ~DefaultResourceStrategy()=default
uint64_t select(uint64_t ReadyMask) override
Selects a processor resource unit from a ReadyMask.
A resource manager for processor resource units and groups.
void reserveBuffers(uint64_t ConsumedBuffers)
void issueInstruction(const InstrDesc &Desc, SmallVectorImpl< ResourceWithCycles > &Pipes)
void releaseBuffers(uint64_t ConsumedBuffers)
void fastIssueInstruction(const InstrDesc &Desc, SmallVectorImpl< ResourceWithCycles > &Pipes)
std::pair< ResourceRef, ReleaseAtCycles > ResourceWithCycles
void releaseResource(uint64_t ResourceID)
virtual ~ResourceManager()=default
void reserveResource(uint64_t ResourceID)
void issueInstructionImpl(const InstrDesc &Desc, SmallVectorImpl< ResourceWithCycles > &Pipes)
unsigned resolveResourceMask(uint64_t Mask) const
void cycleEvent(SmallVectorImpl< ResourceRef > &ResourcesFreed)
uint64_t getProcResUnitMask() const
void setCustomStrategy(std::unique_ptr< ResourceStrategy > S, unsigned ResourceID)
ResourceStateEvent canBeDispatched(uint64_t ConsumedBuffers) const
uint64_t checkAvailability(const InstrDesc &Desc) const
uint64_t getAvailableProcResUnits() const
A processor resource descriptor.
ResourceStateEvent isBufferAvailable() const
Checks if there is an available slot in the resource buffer.
uint64_t getReadyMask() const
void markSubResourceAsUsed(uint64_t ID)
void releaseBuffer()
Releases a slot in the buffer.
unsigned getProcResourceID() const
void releaseSubResource(uint64_t ID)
int getBufferSize() const
bool isADispatchHazard() const
Returns true if this is an in-order dispatch/issue resource.
bool isReady(unsigned NumUnits=1) const
Returs true if this resource is not reserved, and if there are at least NumUnits available units.
bool containsResource(uint64_t ID) const
uint64_t getNumReadyUnits() const
unsigned getNumUnits() const
bool reserveBuffer()
Reserve a buffer slot.
uint64_t getResourceMask() const
bool isAResourceGroup() const
Resource allocation strategy used by hardware scheduler resources.
virtual uint64_t select(uint64_t ReadyMask)=0
Selects a processor resource unit from a ReadyMask.
virtual ~ResourceStrategy()
virtual void used(uint64_t ResourceMask)
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
ResourceStrategy()=default
Helper functions used by various pipeline components.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
ResourceStateEvent
Used to notify the internal state of a processor resource.
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
std::pair< unsigned, unsigned > BufferUsageEntry
This is an optimization pass for GlobalISel generic memory operations.
int popcount(T Value) noexcept
Count the number of set bits in a value.
Description of the encoding of one expression Op.
Define a kind of processor resource that will be modeled by the scheduler.
Machine model for scheduling, bundling, and heuristics.
An instruction descriptor.