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;
273 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
274 return AvailableSlots;
284 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
339 std::vector<std::unique_ptr<ResourceState>> Resources;
340 std::vector<std::unique_ptr<ResourceStrategy>> Strategies;
343 std::vector<uint64_t> Resource2Groups;
378 unsigned getNumUnits(
uint64_t ResourceID)
const;
382 void setCustomStrategyImpl(std::unique_ptr<ResourceStrategy> S,
392 unsigned ResourceID) {
394 "Invalid resource index in input!");
395 return setCustomStrategyImpl(std::move(S), ProcResID2Mask[ResourceID]);
439 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 releaseBuffers(uint64_t ConsumedBuffers)
void issueInstruction(const InstrDesc &Desc, SmallVectorImpl< std::pair< ResourceRef, ReleaseAtCycles > > &Pipes)
void releaseResource(uint64_t ResourceID)
virtual ~ResourceManager()=default
void reserveResource(uint64_t ResourceID)
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
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.