15 #ifndef LLVM_MCA_RESOURCE_MANAGER_H 16 #define LLVM_MCA_RESOURCE_MANAGER_H 57 virtual uint64_t
select(uint64_t ReadyMask) = 0;
63 virtual void used(uint64_t ResourceMask) {}
73 const uint64_t ResourceUnitMask;
96 uint64_t NextInSequenceMask;
118 uint64_t RemovedFromNextInSequence;
123 NextInSequenceMask(UnitMask), RemovedFromNextInSequence(0) {}
126 uint64_t
select(uint64_t ReadyMask)
override;
138 const unsigned ProcResourceDescIndex;
164 const uint64_t ResourceMask;
176 uint64_t ResourceSizeMask;
194 const int BufferSize;
197 unsigned AvailableSlots;
210 bool isSubResourceReady(uint64_t SubResMask)
const {
211 return ReadyMask & SubResMask;
234 bool isReady(
unsigned NumUnits = 1)
const;
241 assert(isSubResourceReady(ID));
246 assert(!isSubResourceReady(ID));
274 assert(AvailableSlots <= static_cast<unsigned>(BufferSize));
275 return AvailableSlots;
285 assert(AvailableSlots <= static_cast<unsigned>(BufferSize));
340 std::vector<std::unique_ptr<ResourceState>> Resources;
341 std::vector<std::unique_ptr<ResourceStrategy>> Strategies;
344 std::vector<uint64_t> Resource2Groups;
358 uint64_t ProcResUnitMask;
361 uint64_t AvailableProcResUnits;
364 uint64_t ReservedResourceGroups;
368 uint64_t AvailableBuffers;
371 uint64_t ReservedBuffers;
374 ResourceRef selectPipe(uint64_t ResourceID);
376 void use(
const ResourceRef &RR);
377 void release(
const ResourceRef &RR);
379 unsigned getNumUnits(uint64_t ResourceID)
const;
383 void setCustomStrategyImpl(std::unique_ptr<ResourceStrategy> S,
384 uint64_t ResourceMask);
393 unsigned ResourceID) {
395 "Invalid resource index in input!");
396 return setCustomStrategyImpl(std::move(S), ProcResID2Mask[ResourceID]);
404 unsigned resolveResourceMask(uint64_t
Mask)
const;
408 void reserveBuffers(uint64_t ConsumedBuffers);
414 void releaseBuffers(uint64_t ConsumedBuffers);
418 void reserveResource(uint64_t ResourceID);
421 void releaseResource(uint64_t ResourceID);
427 uint64_t checkAvailability(
const InstrDesc &Desc)
const;
432 void issueInstruction(
440 for (
const std::unique_ptr<ResourceState> &Resource : Resources)
448 #endif // LLVM_MCA_RESOURCE_MANAGER_H bool isAResourceGroup() const
A resource manager for processor resource units and groups.
This class represents lattice values for constants.
void setCustomStrategy(std::unique_ptr< ResourceStrategy > S, unsigned ResourceID)
void markSubResourceAsUsed(uint64_t ID)
bool containsResource(uint64_t ID) const
virtual ~ResourceStrategy()
virtual void used(uint64_t ResourceMask)
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
uint64_t getResourceMask() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
virtual uint64_t select(uint64_t ReadyMask)=0
Selects a processor resource unit from a ReadyMask.
unsigned getNumUnits() const
uint64_t getReadyMask() const
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Move duplicate certain instructions close to their use
void releaseBuffer()
Releases a slot in the buffer.
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
bool isADispatchHazard() const
Returns true if this is an in-order dispatch/issue resource.
Helper functions used by various pipeline components.
ResourceStateEvent
Used to notify the internal state of a processor resource.
int getBufferSize() const
unsigned countPopulation(T Value)
Count the number of set bits in a value.
uint64_t getAvailableProcResUnits() const
Define a kind of processor resource that will be modeled by the scheduler.
std::pair< unsigned, unsigned > BufferUsageEntry
An instruction descriptor.
A processor resource descriptor.
bool reserveBuffer()
Reserve a buffer slot.
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
void releaseSubResource(uint64_t ID)
DefaultResourceStrategy(uint64_t UnitMask)
unsigned getProcResourceID() const
Default resource allocation strategy used by processor resource groups and processor resources with m...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Resource allocation strategy used by hardware scheduler resources.
Machine model for scheduling, bundling, and heuristics.
uint64_t getProcResUnitMask() const