sys-sage
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sys_sage::Cache Class Reference

Represents a data cache in the system (of different levels/purposes). More...

#include <Cache.hpp>

Inheritance diagram for sys_sage::Cache:
sys_sage::Component

Public Member Functions

 Cache (int _id=0, int _cache_level=0, long long _cache_size=-1, int _associativity=-1, int _cache_line_size=-1)
 Cache constructor (no automatic insertion in the Component Tree).
 
 Cache (Component *parent, int _id, std::string _cache_type, long long _cache_size=0, int _associativity=-1, int _cache_line_size=-1)
 Cache constructor with insertion into the Component Tree as the parent's child (as long as parent is an existing Component).
 
 Cache (Component *parent, int _id=0, int _cache_level=0, long long _cache_size=-1, int _associativity=-1, int _cache_line_size=-1)
 Cache constructor with insertion into the Component Tree as the parent 's child (as long as parent is an existing Component).
 
int GetCacheLevel () const
 Get the cache level (e.g., 1 for L1, 2 for L2).
 
void SetCacheLevel (int _cache_level)
 Set the cache level using an integer value (e.g., 1 for "L1").
 
const std::string & GetCacheName () const
 Retrieves cache name/type (e.g., "L1", "texture").
 
void SetCacheName (std::string _name)
 Set the cache name/type (e.g., "L1", "texture").
 
long long GetCacheSize () const
 Retrieves size/capacity of the cache.
 
void SetCacheSize (long long _cache_size)
 Sets size/capacity of the cache.
 
int GetCacheAssociativityWays () const
 Get the number of cache associativity ways.
 
void SetCacheAssociativityWays (int _associativity)
 Set the number of cache associativity ways.
 
int GetCacheLineSize () const
 Get the size of a cache line.
 
void SetCacheLineSize (int _cache_line_size)
 Set the size of a cache line.
 
long long GetMIGSize (std::string uuid="") const
 Gets the MIG size of the cache element (NVIDIA-specific).
 
- Public Member Functions inherited from sys_sage::Component
 Component (int _id=0, std::string _name="unknown")
 Generic Component constructor (no automatic insertion in the Component Tree). Usually one of the derived subclasses for different Component Types will be created, not this one.
 
 Component (Component *parent, int _id=0, std::string _name="unknown")
 Generic Component constructor with insertion into the Component Tree as the parent's child. Usually one of the derived subclasses for different Component Types will be created.
 
void InsertChild (Component *child)
 Inserts a child component to this component (in the Component Tree). The child pointer will be inserted at the end of the children vector.
 
int InsertBetweenParentAndChild (Component *parent, Component *child, bool alreadyParentsChild)
 Inserts this component between a parent and one of its children. The parent component remains the parent, this Component becomes a new child of the parent, and the specified child becomes this component's child.
 
int InsertBetweenParentAndChildren (Component *parent, std::vector< Component * > children, bool alreadyParentsChild)
 Inserts this component between a parent and a (subset of) its children. The parent component remains parent, this Component becomes a new child, and the children become parent's grandchildren.
 
int RemoveChild (Component *child)
 Removes the passed component from the list of children, without completely deleting (and deallocating) the child itself.
 
void SetParent (Component *parent)
 Set a parent to the component. This is usually used when inserting a component in the tree (by calling InsertChild on the parent, and calling SetParent on the child).
 
void PrintSubtree () const
 Prints the whole subtree of this component (including the component itself) to stdout. The tree is printed in DFS order, so that the hierarchy can be easily seen. Each child is indented by " ". For each component in the subtree, the following is printed: "<string component type> (name <name>) id <id> - children: <num children>
 
void PrintAllDataPathsInSubtree ()
 Prints all DataPaths that go from or to components in the subtree.
 
void PrintAllRelationsInSubtree (RelationType::type RelationType=RelationType::Any)
 Prints all Relations in the subtree.
 
const std::string & GetName () const
 Returns name of the component.
 
void SetName (std::string _name)
 Sets name of the component.
 
int GetId () const
 Returns id of the component.
 
sys_sage::ComponentType::type GetComponentType () const
 Returns component type of the component. The component type denotes which class the instance is (often stored as Component*, even though they are a member of one of the child classes).
 
std::string GetComponentTypeStr () const
 Returns component type as a human-readable string, as defined in ComponentType::names.
 
const std::vector< Component * > & GetChildren () const
 Returns a const reference to std::vector containing all children of the component (empty vector if no children).
 
ComponentGetParent () const
 Returns Component pointer to parent (or NULL if this component is the root)
 
ComponentGetChild (int _id) const
 Retrieve a Component* to a child with child.id=_id. Identical to GetChildById
Should there be more children with the same id, the first match will be retrieved (i.e. the one with lower index in the children array.)
 
ComponentGetChildById (int _id) const
 Retrieve a Component* to a child with child.id=_id. Should there be more children with the same id, the first match will be retrieved (i.e. the one with lower index in the children array.)
 
ComponentGetChildByType (ComponentType::type _componentType) const
 Retrieve a Component* to a child matching the given component type. Should there be more children with the same type, the first match will be retrieved (i.e. the one with lower index in the children array.)
 
std::vector< Component * > GetAllChildrenByType (ComponentType::type _componentType) const
 Searches for all children matching the given component type.
 
void GetAllChildrenByType (std::vector< Component * > *_outArray, ComponentType::type _componentType) const
 Searches for all the children matching the given component type.
 
ComponentGetSubcomponentById (int _id, ComponentType::type _componentType)
 Searches the subtree to find a component with a matching id and componentType, i.e. looks for a certain component with a matching ID. The search is a DFS. The search starts with the calling component.
 
void GetAllSubcomponentsByType (std::vector< Component * > *outArray, ComponentType::type _componentType)
 Searches for all the subcomponents (children, their children and so on) matching the given component type.
 
std::vector< Component * > GetAllSubcomponentsByType (ComponentType::type _componentType)
 Searches for all the subcomponents (children, their children and so on) matching the given component type.
 
int CountAllSubcomponents () const
 Counts number of subcomponents (children, grandchildren, etc.).
 
int CountAllSubcomponentsByType (ComponentType::type _componentType) const
 Counts number of subcomponents (children, their children and so on) matching the requested component type.
 
int CountAllChildrenByType (ComponentType::type _componentType) const
 Counts number of children matching the requested component type.
 
ComponentGetAncestorByType (ComponentType::type _componentType)
 Moves up the tree until a parent of the given type is found.
 
int GetSubtreeDepth () const
 Retrieves maximal distance to a leaf (i.e. the depth of the subtree). 0=leaf, 1=children are leaves, 2=at most children's children are leaves .....
 
ComponentGetNthAncestor (int n)
 Retrieves Nth ancestor, which resides N levels above. E.g. if n=1, the parent is retrieved; if n=2, the grandparent is retrieved and so on.
 
void GetNthDescendents (std::vector< Component * > *outArray, int depth)
 Retrieves a std::vector of Component pointers, which reside 'depth' levels deeper. The tree is traversed in order as the children are stored in std::vector children. E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved..
 
std::vector< Component * > GetNthDescendents (int depth)
 Retrieves a std::vector of Component pointers, which reside 'depth' levels deeper. The tree is traversed in order as the children are stored in the std::vector. E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved..
 
void GetSubcomponentsByType (std::vector< Component * > *outArray, int componentType)
 Retrieves a std::vector of Component pointers, which reside in the subtree and have a matching type. The tree is traversed DFS in order as the children are stored in each std::vector children.
 
std::vector< Component * > GetSubcomponentsByType (ComponentType::type _componentType)
 Retrieves a std::vector of Component pointers, which reside in the subtree and have a matching type. The tree is traversed DFS in order as the children are stored in the std::vector.
 
void GetComponentsInSubtree (std::vector< Component * > *outArray)
 Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this.
 
std::vector< Component * > GetComponentsInSubtree ()
 Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this.
 
const std::vector< Relation * > & GetRelations (RelationType::type relationType) const
 Returns a (const) reference to the internal vector of relations for a given type.
 
std::vector< Relation * > GetAllRelationsBy (RelationType::type relationType=RelationType::Any, int thisComponentPosition=-1) const
 Returns a newly-constructed vector of all relations of a given type and position.
 
DataPathGetDataPathByType (DataPathType::type dp_type, DataPathDirection::type direction=DataPathDirection::Any) const
 Retrieves a DataPath* from the list of this component's data paths with matching DataPathType and DataPathDirection. The first match is returned.
 
void GetAllDataPaths (std::vector< DataPath * > *outDpArr, DataPathType::type dp_type=DataPathType::Any, DataPathDirection::type direction=DataPathDirection::Any) const
 Retrieves all DataPath* from the list of this component's data paths with matching type and orientation. Results are returned in std::vector<DataPath*>* outDpArr, where first the matching data paths in dp_outgoing are pushed back, then the ones in dp_incoming.
 
std::vector< DataPath * > GetAllDataPaths (DataPathType::type dp_type=DataPathType::Any, DataPathDirection::type direction=DataPathDirection::Any) const
 Retrieves all DataPath* from the list of this component's data paths with matching type and orientation/direction. Results are returned in a std::vector<DataPath*>*.
 
int CheckComponentTreeConsistency () const
 Checks the consistency of the component tree starting from this component.
 
int GetTopologySize (unsigned *out_component_size, unsigned *out_dataPathSize) const
 Calculates approximate memory footprint of the subtree of this element (including the relevant Relations).
 
int GetDepth (bool refresh)
 Retrieves the depth (level) of a component in the topology.
 
void DeleteRelation (Relation *r)
 Deletes a Relation from this component as well as the Relation itself.
 
void DeleteDataPath (DataPath *dp)
 Deletes and deallocates the DataPath pointer from the list of outgoing/incoming DataPaths.
 
void DeleteAllRelations (RelationType::type relationType=RelationType::Any)
 Deletes all relations of this component (optionally filtered by type).
 
void DeleteAllDataPaths ()
 Deletes all DataPaths of this component.
 
void DeleteSubtree () const
 
void Delete (bool withSubtree=true)
 Deletes a component, its children (if withSubtree = true), and all associated Relations. If only the component itself is deleted, its children are inserted into its parent's children list.
 

Additional Inherited Members

- Public Attributes inherited from sys_sage::Component
std::map< std::string, void * > attrib
 
- Protected Member Functions inherited from sys_sage::Component
 Component (int _id, std::string _name, ComponentType::type _componentType)
 Protected constructor for derived classes (no automatic insertion in the Component Tree).
 
 Component (Component *parent, int _id, std::string _name, ComponentType::type _componentType)
 Protected constructor for derived classes with insertion into the Component Tree.
 
- Protected Attributes inherited from sys_sage::Component
int id
 
int depth
 
std::string name
 
int count {-1}
 
const ComponentType::type componentType
 
std::vector< Component * > children
 
Componentparent { nullptr }
 
std::array< std::vector< Relation * > *, RelationType::_num_relation_types > * relations = nullptr
 

Detailed Description

Represents a data cache in the system (of different levels/purposes).

Models hardware cache components (L1, L2, L3, texture, etc.) as part of the unified hardware topology abstraction. Inherits from Component and provides attributes and methods for describing cache hierarchy, size, associativity, and line size. The cache abstraction supports both classical and heterogeneous (e.g., GPU, accelerator) memory hierarchies, and is extensible for new architectures and data sources.

See also
Component

Constructor & Destructor Documentation

◆ Cache() [1/3]

sys_sage::Cache::Cache ( int _id = 0,
int _cache_level = 0,
long long _cache_size = -1,
int _associativity = -1,
int _cache_line_size = -1 )

Cache constructor (no automatic insertion in the Component Tree).

Parameters
_idUnique cache ID (default 0)
_cache_levelCache level (1=L1, 2=L2, ...), default 0. This value is represented as cache_type.
_cache_sizeSize of the cache in bytes (default -1)
_associativityNumber of cache associativity ways (default -1)
_cache_line_sizeSize of a cache line in bytes (default -1)

Sets componentType to sys_sage::ComponentType::Cache.

◆ Cache() [2/3]

sys_sage::Cache::Cache ( Component * parent,
int _id,
std::string _cache_type,
long long _cache_size = 0,
int _associativity = -1,
int _cache_line_size = -1 )

Cache constructor with insertion into the Component Tree as the parent's child (as long as parent is an existing Component).

Parameters
parentParent component
_idUnique cache ID (default 0)
_cache_typeName/type of the cache (e.g., "L1", "texture"). Only one of int cache_level or string cache_type should be used.
_cache_sizeSize of the cache in bytes (default 0)
_associativityNumber of cache associativity ways (default -1)
_cache_line_sizeSize of a cache line in bytes (default -1)

Sets componentType to sys_sage::ComponentType::Cache.

◆ Cache() [3/3]

sys_sage::Cache::Cache ( Component * parent,
int _id = 0,
int _cache_level = 0,
long long _cache_size = -1,
int _associativity = -1,
int _cache_line_size = -1 )

Cache constructor with insertion into the Component Tree as the parent 's child (as long as parent is an existing Component).

Parameters
parentParent component
_idUnique cache ID (default 0)
_cache_levelCache level (1=L1, 2=L2, ...), default 0. This value is represented as cache_type.
_cache_sizeSize of the cache in bytes (default -1)
_associativityNumber of cache associativity ways (default -1)
_cache_line_sizeSize of a cache line in bytes (default -1)

Sets componentType to sys_sage::ComponentType::Cache.

Member Function Documentation

◆ GetCacheAssociativityWays()

int sys_sage::Cache::GetCacheAssociativityWays ( ) const

Get the number of cache associativity ways.

Returns
Number of associativity ways.

◆ GetCacheLevel()

int sys_sage::Cache::GetCacheLevel ( ) const

Get the cache level (e.g., 1 for L1, 2 for L2).

Returns
Cache level as integer.

Assumes there's only 1 or no digit in the "cache_type" (e.g., "L1", "texture").

◆ GetCacheLineSize()

int sys_sage::Cache::GetCacheLineSize ( ) const

Get the size of a cache line.

Returns
Cache line size in bytes.

◆ GetCacheName()

const std::string & sys_sage::Cache::GetCacheName ( ) const

Retrieves cache name/type (e.g., "L1", "texture").

Returns
Cache name as string.
See also
cache_type

◆ GetCacheSize()

long long sys_sage::Cache::GetCacheSize ( ) const

Retrieves size/capacity of the cache.

Returns
Cache size in bytes.

◆ GetMIGSize()

long long sys_sage::Cache::GetMIGSize ( std::string uuid = "") const

Gets the MIG size of the cache element (NVIDIA-specific).

Parameters
uuidOptional UUID string for the MIG instance.
Returns
MIG size in bytes.

◆ SetCacheAssociativityWays()

void sys_sage::Cache::SetCacheAssociativityWays ( int _associativity)

Set the number of cache associativity ways.

Parameters
_associativityValue for cache_associativity_ways.

◆ SetCacheLevel()

void sys_sage::Cache::SetCacheLevel ( int _cache_level)

Set the cache level using an integer value (e.g., 1 for "L1").

Parameters
_cache_levelValue for cache_type.

◆ SetCacheLineSize()

void sys_sage::Cache::SetCacheLineSize ( int _cache_line_size)

Set the size of a cache line.

Parameters
_cache_line_sizeCache line size in bytes.

◆ SetCacheName()

void sys_sage::Cache::SetCacheName ( std::string _name)

Set the cache name/type (e.g., "L1", "texture").

Parameters
_nameValue for cache_type.

◆ SetCacheSize()

void sys_sage::Cache::SetCacheSize ( long long _cache_size)

Sets size/capacity of the cache.

Parameters
_cache_sizeSize in bytes.

The documentation for this class was generated from the following files: