From 72093ff09b0d6a58d9ae8500851fac4093ca6e2c Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 20 Jun 2024 16:19:06 +0200 Subject: [PATCH 01/47] Privatised redundant API calls; added newer ones --- src/Topology.cpp | 15 +++++++++++-- src/Topology.hpp | 58 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index d0a858d..2779b57 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -119,6 +119,11 @@ int Component::RemoveChild(Component * child) //return std::erase(children, child); -- not supported in some compilers } Component* Component::GetChild(int _id) +{ + return GetChildById(_id); +} + +Component* Component::GetChildById(int _id) { for(Component* child: children) { @@ -282,10 +287,10 @@ int Component::CountAllSubcomponentsByType(int _componentType) Component* Component::FindParentByType(int _componentType) { - return GetAncestorType(_componentType); + return GetAncestorByType(_componentType); } -Component* Component::GetAncestorType(int _componentType) +Component* Component::GetAncestorByType(int _componentType) { if(componentType == _componentType){ return this; @@ -529,6 +534,7 @@ void Component::Delete(bool withSubtree) delete this; } +void Component::SetName(string _name){ name = _name; } Component* Component::GetParent(){return parent;} void Component::SetParent(Component* _parent){parent = _parent;} vector* Component::GetChildren(){return &children;} @@ -550,11 +556,13 @@ void Subdivision::SetSubdivisionType(int subdivisionType){type = subdivisionType int Subdivision::GetSubdivisionType(){return type;} long long Numa::GetSize(){return size;} +void Numa::SetSize(long long _size) { size = _size;} long long Memory::GetSize() {return size;} void Memory::SetSize(long long _size) {size = _size;} string Cache::GetCacheName(){return cache_type;} +void Cache::SetCacheName(string _name) { cache_type = _name;} int Cache::GetCacheLevel(){ @@ -573,11 +581,14 @@ int Cache::GetCacheLevel(){ return 0; } + +void Cache::SetCacheLevel(int _cache_level) { cache_type = to_string(_cache_level); } long long Cache::GetCacheSize(){return cache_size;} void Cache::SetCacheSize(long long _cache_size){cache_size = _cache_size;} int Cache::GetCacheLineSize(){return cache_line_size;} void Cache::SetCacheLineSize(int _cache_line_size){cache_line_size = _cache_line_size;} int Cache::GetCacheAssociativityWays(){return cache_associativity_ways;} +void Cache::SetCacheAssociativityWays(int _associativity) { cache_associativity_ways = _associativity;} Component::Component(int _id, string _name, int _componentType) : id(_id), name(_name), componentType(_componentType) { diff --git a/src/Topology.hpp b/src/Topology.hpp index a15c107..44c1fc3 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -94,7 +94,9 @@ class Component { For each component in the subtree, the following is printed: " (name ) id - children: */ void PrintSubtree(); + /** + @private Helper function of PrintSubtree();, which ensures the proper indentation. Using PrintSubtree(); is recommended, however this method can be used as well. @param level - number of " " to print out in front of the first component. @see PrintSubtree(); @@ -112,6 +114,12 @@ class Component { */ string GetName(); /** + Sets name of the component. + @param _name - name of the component + @see name + */ + void SetName(string _name); + /** Returns id of the component. @return id @see id @@ -161,10 +169,19 @@ class Component { */ Component* GetParent(); /** - Retrieve a Componet* to a child with child.id=_id. + Identical to GetChildById + Retrieve a Component* to a child with child.id=_id. \n 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.) + @see GetChildById */ Component* GetChild(int _id); + + /** + Retrieve a Component* to a child with child.id=_id. + \n 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.) + */ + Component* GetChildById(int _id); + /** * TODO */ @@ -174,10 +191,12 @@ class Component { */ vector GetAllChildrenByType(int _componentType); /** + @private OBSOLETE. Use GetSubcomponentById instead. This function will be removed in the future. */ Component* FindSubcomponentById(int _id, int _componentType); /** + @private OBSOLETE. Use GetAllSubcomponentsByType instead. This function will be removed in the future. */ void FindAllSubcomponentsByType(vector* outArray, int _componentType); @@ -210,13 +229,15 @@ class Component { @param _componentType - the desired component type @return Component * matching the criteria. NULL if no match found */ - Component* GetAncestorType(int _componentType); + Component* GetAncestorByType(int _componentType); /** - OBSOLETE. Use GetAncestorType instead. This function will be removed in the future. + @private + OBSOLETE. Use GetAncestorByType instead. This function will be removed in the future. */ Component* FindParentByType(int _componentType); /** + @private OBSOLETE. Use int CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) instead. Returns the number of Components of type SYS_SAGE_COMPONENT_THREAD in the subtree. */ @@ -264,6 +285,7 @@ class Component { */ vector* GetDataPaths(int orientation); /** + @private !!Normally should not be called; Use NewDataPath() instead!! Stores (pushes back) a DataPath pointer to the list(std::vector) of DataPaths of this component. According to the orientation param, the proper list is chosen. @param p - the pointer to store @@ -462,6 +484,7 @@ class Memory : public Component { */ void SetSize(long long _size); /** + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ @@ -510,6 +533,7 @@ class Storage : public Component { */ void SetSize(long long _size); /** + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ @@ -570,6 +594,7 @@ class Chip : public Component { */ int GetChipType(); /** + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ @@ -633,10 +658,23 @@ class Cache : public Component { @returns cache level of this cache, assuming there's only 1 or no digit in the "cache_type" (e.g. "L1", "texture") */ int GetCacheLevel(); + + /** + Sets cache level of this cache using integer value (For e.g. "1" for "L1", etc.) + @param _cache_level - value for cache_type + */ + void SetCacheLevel(int _cache_level); + /** * TODO */ string GetCacheName(); + + /** + Sets cache name of this cache (e.g. "L1", "texture") + @param _cache_name - value for cache_type + */ + void SetCacheName(string _name); /** @returns cache size of this cache */ @@ -650,6 +688,11 @@ class Cache : public Component { */ int GetCacheAssociativityWays(); /** + Sets cache associativity ways of this cache + @param _associativity - value for cache_associativity_ways + */ + void SetCacheAssociativityWays(int _associativity); + /** @returns the size of a cache line of this cache */ int GetCacheLineSize(); @@ -658,6 +701,7 @@ class Cache : public Component { */ void SetCacheLineSize(int _cache_line_size); /** + @private !!Should normally not be caller from the outside!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ @@ -708,6 +752,7 @@ class Subdivision : public Component { */ int GetSubdivisionType(); /** + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ @@ -750,6 +795,13 @@ class Numa : public Subdivision { long long GetSize(); /** + Set size of the Numa memory segment. + @param _size - size of the Numa memory segment. + */ + void SetSize(long long _size); + + /** + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ From ffbb18026289e179d3b47ffb4a8b990f76835e45 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 20 Jun 2024 20:34:08 +0200 Subject: [PATCH 02/47] Added more API calls --- src/Topology.cpp | 31 ++++++++++++++++++++++++++-- src/Topology.hpp | 53 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index 2779b57..c4632b3 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -145,12 +145,18 @@ Component* Component::GetChildByType(int _componentType) vector Component::GetAllChildrenByType(int _componentType) { vector ret; + GetAllChildrenByType(&ret, _componentType); + return ret; +} + +void Component::GetAllChildrenByType(vector *_outArray, int _componentType) +{ for(Component * child : children) { if(child->GetComponentType() == _componentType) - ret.push_back(child); + _outArray->push_back(child); } - return ret; + return; } int Component::GetNumThreads() @@ -197,6 +203,13 @@ void Component::GetComponentsNLevelsDeeper(vector* outArray, int dep return; } +vector Component::GetComponentsNLevelsDeeper(int depth) +{ + vector outArray; + GetComponentsNLevelsDeeper(&outArray, depth); + return outArray; +} + void Component::GetSubcomponentsByType(vector* outArray, int _componentType) { if(_componentType == componentType){ @@ -208,6 +221,13 @@ void Component::GetSubcomponentsByType(vector* outArray, int _compon } } +vector Component::GetSubcomponentsByType(int _componentType) +{ + vector outArray; + GetSubcomponentsByType(&outArray, _componentType); + return outArray; +} + void Component::GetSubtreeNodeList(vector* outArray) { outArray->push_back(this); @@ -218,6 +238,13 @@ void Component::GetSubtreeNodeList(vector* outArray) return; } +vector Component::GetSubtreeNodeList() +{ + vector outArray; + GetSubtreeNodeList(&outArray); + return outArray; +} + Component* Component::FindSubcomponentById(int _id, int _componentType) { return GetSubcomponentById(_id, _componentType); diff --git a/src/Topology.hpp b/src/Topology.hpp index 44c1fc3..a64a91d 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -94,7 +94,7 @@ class Component { For each component in the subtree, the following is printed: " (name ) id - children: */ void PrintSubtree(); - + /** @private Helper function of PrintSubtree();, which ensures the proper indentation. Using PrintSubtree(); is recommended, however this method can be used as well. @@ -186,12 +186,26 @@ class Component { * TODO */ Component* GetChildByType(int _componentType); + /** - * TODO + * Searches for all the children matching the given component type. + * + * @param _componentType - Required type of components + * @return A vector of all the children matching the _componentType + * @see void GetAllChildrenByType(vector *_outArray, int _componentType) */ vector GetAllChildrenByType(int _componentType); + + /** + * Searches for all the children matching the given component type. + * + * @param _componentType - Required type of components + * @param outArray - output parameter (vector with results) + \n An input is pointer to a std::vector, in which the elements will be pushed. It must be allocated before the call (but does not have to be empty). + \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, nothing will be pushed into the vector.) + */ + void GetAllChildrenByType(vector *_outArray, int _componentType); /** - @private OBSOLETE. Use GetSubcomponentById instead. This function will be removed in the future. */ Component* FindSubcomponentById(int _id, int _componentType); @@ -237,7 +251,6 @@ class Component { Component* FindParentByType(int _componentType); /** - @private OBSOLETE. Use int CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) instead. Returns the number of Components of type SYS_SAGE_COMPONENT_THREAD in the subtree. */ @@ -257,25 +270,45 @@ class Component { \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, nothing will be pushed into the vector.) */ void GetComponentsNLevelsDeeper(vector* 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 each std::vector children. + 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. \n E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved.. @param depth - how many levels down the tree should be looked + @return A std::vector with the results. + */ + vector GetComponentsNLevelsDeeper(int depth); + + /** + 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. + @param componentType - componentType @param outArray - output parameter (vector with results) \n An input is pointer to a std::vector, in which the elements will be pushed. It must be allocated before the call (but does not have to be empty). \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, the vector is not changed.) - */ void GetSubcomponentsByType(vector* 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. + 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. @param componentType - componentType + @return A std::vector with the results. + */ + vector GetSubcomponentsByType(int _componentType); + + /** + Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this. @param outArray - output parameter (vector with results) \n An input is pointer to a std::vector, in which the elements will be pushed. It must be allocated before the call (but does not have to be empty). \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, the vector is not changed.) */ void GetSubtreeNodeList(vector* outArray); + /** + Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this. + @return A std::vector with the results. + */ + vector GetSubtreeNodeList(); + /** Returns the DataPaths of this component according to their orientation. @param orientation - either SYS_SAGE_DATAPATH_OUTGOING or SYS_SAGE_DATAPATH_INCOMING @@ -669,12 +702,13 @@ class Cache : public Component { * TODO */ string GetCacheName(); - + /** Sets cache name of this cache (e.g. "L1", "texture") @param _cache_name - value for cache_type */ void SetCacheName(string _name); + /** @returns cache size of this cache */ @@ -687,6 +721,7 @@ class Cache : public Component { @returns the number of the cache associativity ways of this cache */ int GetCacheAssociativityWays(); + /** Sets cache associativity ways of this cache @param _associativity - value for cache_associativity_ways @@ -801,7 +836,7 @@ class Numa : public Subdivision { void SetSize(long long _size); /** - @private + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ From 589899df4eb380c14c220445d894c194d18f2519 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 21 Jun 2024 00:39:50 +0200 Subject: [PATCH 03/47] Renamed GetTopoTreeDepth --- src/Topology.cpp | 4 ++-- src/Topology.hpp | 2 +- test/topology.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index c4632b3..5355946 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -171,14 +171,14 @@ int Component::GetNumThreads() return numPu; } -int Component::GetTopoTreeDepth() +int Component::GetSubtreeDepth() { if(children.empty()) //is leaf return 0; int maxDepth = 0; for(Component* child: children) { - int subtreeDepth = child->GetTopoTreeDepth(); + int subtreeDepth = child->GetSubtreeDepth(); if(subtreeDepth > maxDepth) maxDepth = subtreeDepth; } diff --git a/src/Topology.hpp b/src/Topology.hpp index a64a91d..98c1097 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -260,7 +260,7 @@ class Component { \n 0=leaf, 1=children are leaves, 2=at most children's children are leaves ..... @return maximal distance to a leaf */ - int GetTopoTreeDepth();//0=empty, 1=1element,... + int GetSubtreeDepth();//0=empty, 1=1element,... /** 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. \n E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved.. diff --git a/test/topology.cpp b/test/topology.cpp index 484c252..b1ce46f 100644 --- a/test/topology.cpp +++ b/test/topology.cpp @@ -310,6 +310,6 @@ static suite<"topology"> _ = [] e.InsertChild(&f); a.InsertChild(&g); - expect(that % 3 == a.GetTopoTreeDepth()); + expect(that % 3 == a.GetSubtreeDepth()); }; }; From a07afbd8e5036b1b06535d09c8018d7cf2c43cf5 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 21 Jun 2024 11:09:06 +0200 Subject: [PATCH 04/47] Rename GetDp to GetDataPath and similar changes --- src/DataPath.cpp | 2 +- src/DataPath.hpp | 2 +- src/Topology.cpp | 12 ++++++------ src/Topology.hpp | 4 ++-- src/nvidia_mig.cpp | 10 +++++----- src/xml_dump.cpp | 2 +- test/caps-numa-benchmark.cpp | 4 ++-- test/datapath.cpp | 28 ++++++++++++++-------------- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/DataPath.cpp b/src/DataPath.cpp index 841a56e..96e914c 100644 --- a/src/DataPath.cpp +++ b/src/DataPath.cpp @@ -19,7 +19,7 @@ Component * DataPath::GetSource() {return source;} Component * DataPath::GetTarget() {return target;} double DataPath::GetBw() {return bw;} double DataPath::GetLatency() {return latency;} -int DataPath::GetDpType() {return dp_type;} +int DataPath::GetDataPathType() {return dp_type;} int DataPath::GetOriented() {return oriented;} DataPath::DataPath(Component* _source, Component* _target, int _oriented, int _type): DataPath(_source, _target, _oriented, _type, -1, -1) {} diff --git a/src/DataPath.hpp b/src/DataPath.hpp index 3464bc1..bfc294c 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -102,7 +102,7 @@ class DataPath { @returns Type of the Data Path. @see dp_type */ - int GetDpType(); + int GetDataPathType(); /** * TODO */ diff --git a/src/Topology.cpp b/src/Topology.cpp index 5355946..1998766 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -336,33 +336,33 @@ void Component::AddDataPath(DataPath* p, int orientation) dp_incoming.push_back(p); } -DataPath* Component::GetDpByType(int dp_type, int orientation) +DataPath* Component::GetDataPathByType(int dp_type, int orientation) { if(orientation & SYS_SAGE_DATAPATH_OUTGOING){ for(DataPath* dp : dp_outgoing){ - if(dp->GetDpType() == dp_type) + if(dp->GetDataPathType() == dp_type) return dp; } } if(orientation & SYS_SAGE_DATAPATH_INCOMING){ for(DataPath* dp : dp_incoming){ - if(dp->GetDpType() == dp_type) + if(dp->GetDataPathType() == dp_type) return dp; } } return NULL; } -void Component::GetAllDpByType(vector* outDpArr, int dp_type, int orientation) +void Component::GetAllDataPathsByType(vector* outDpArr, int dp_type, int orientation) { if(orientation & SYS_SAGE_DATAPATH_OUTGOING){ for(DataPath* dp : dp_outgoing){ - if(dp->GetDpType() == dp_type) + if(dp->GetDataPathType() == dp_type) outDpArr->push_back(dp); } } if(orientation & SYS_SAGE_DATAPATH_INCOMING){ for(DataPath* dp : dp_incoming){ - if(dp->GetDpType() == dp_type) + if(dp->GetDataPathType() == dp_type) outDpArr->push_back(dp); } } diff --git a/src/Topology.hpp b/src/Topology.hpp index 98c1097..fb2560b 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -333,7 +333,7 @@ class Component { @param orientation - orientation of the DataPath (SYS_SAGE_DATAPATH_OUTGOING or SYS_SAGE_DATAPATH_INCOMING or a logical or of these) @return DataPath pointer to the found data path; NULL if nothing found. */ - DataPath* GetDpByType(int dp_type, int orientation); + DataPath* GetDataPathByType(int dp_type, int orientation); /** Retrieves all DataPath * from the list of this component's data paths with matching type and orientation. Results are returned in vector* outDpArr, where first the matching data paths in dp_outgoing are pushed back, then the ones in dp_incoming. @@ -343,7 +343,7 @@ class Component { \n An input is pointer to a std::vector, in which the data paths will be pushed. It must be allocated before the call (but does not have to be empty). \n The method pushes back the found data paths -- i.e. the data paths(pointers) can be found in this array after the method returns. (If no found, the vector is not changed.) */ - void GetAllDpByType(vector* outDpArr, int dp_type, int orientation); + void GetAllDataPathsByType(vector* outDpArr, int dp_type, int orientation); /** * TODO */ diff --git a/src/nvidia_mig.cpp b/src/nvidia_mig.cpp index 8f06ea0..52c93db 100644 --- a/src/nvidia_mig.cpp +++ b/src/nvidia_mig.cpp @@ -52,7 +52,7 @@ int Chip::UpdateMIGSettings(string uuid) DataPath * d = NULL; //iterate over dp_outgoing to check if DP already exists for(DataPath* dp : dp_outgoing){ - if(dp->GetDpType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ + if(dp->GetDataPathType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ d = dp; break; } @@ -143,7 +143,7 @@ int Chip::GetMIGNumSMs(string uuid) else { for(DataPath* dp: dp_outgoing){ - if(dp->GetDpType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ + if(dp->GetDataPathType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ Component* target = dp->GetTarget(); if(target->GetComponentType() == SYS_SAGE_COMPONENT_SUBDIVISION && ((Subdivision*)target)->GetSubdivisionType() == SYS_SAGE_SUBDIVISION_TYPE_GPU_SM ){ num_sm++; @@ -178,7 +178,7 @@ int Chip::GetMIGNumCores(string uuid) else { for(DataPath* dp: dp_outgoing){ - if(dp->GetDpType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ + if(dp->GetDataPathType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ Component* target = dp->GetTarget(); if(target->GetComponentType() == SYS_SAGE_COMPONENT_SUBDIVISION && ((Subdivision*)target)->GetSubdivisionType() == SYS_SAGE_SUBDIVISION_TYPE_GPU_SM ){ sms.push_back((Subdivision*)target); @@ -210,7 +210,7 @@ long long Memory::GetMIGSize(string uuid) } for(DataPath* dp: dp_incoming){ - if(dp->GetDpType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ + if(dp->GetDataPathType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ if (dp->attrib.count("mig_size")){ long long r = *(long long*)dp->attrib["mig_size"]; return r; @@ -237,7 +237,7 @@ long long Cache::GetMIGSize(string uuid) if(GetCacheLevel() == 2){ for(DataPath* dp: dp_incoming){ - if(dp->GetDpType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ + if(dp->GetDataPathType() == SYS_SAGE_DATAPATH_TYPE_MIG && *(string*)dp->attrib["mig_uuid"] == uuid){ if (dp->attrib.count("mig_size")){ long long r = *(long long*)dp->attrib["mig_size"]; return r; diff --git a/src/xml_dump.cpp b/src/xml_dump.cpp index f300e64..124f681 100644 --- a/src/xml_dump.cpp +++ b/src/xml_dump.cpp @@ -265,7 +265,7 @@ int exportToXml(Component* root, string path, std::functionGetOriented())).c_str()); - xmlNewProp(dp_n, (const unsigned char *)"dp_type", (const unsigned char *)(std::to_string(dpPtr->GetDpType())).c_str()); + xmlNewProp(dp_n, (const unsigned char *)"dp_type", (const unsigned char *)(std::to_string(dpPtr->GetDataPathType())).c_str()); xmlNewProp(dp_n, (const unsigned char *)"bw", (const unsigned char *)(std::to_string(dpPtr->GetBw())).c_str()); xmlNewProp(dp_n, (const unsigned char *)"latency", (const unsigned char *)(std::to_string(dpPtr->GetLatency())).c_str()); xmlAddChild(data_paths_root, dp_n); diff --git a/test/caps-numa-benchmark.cpp b/test/caps-numa-benchmark.cpp index de1ee51..44b7e09 100644 --- a/test/caps-numa-benchmark.cpp +++ b/test/caps-numa-benchmark.cpp @@ -26,14 +26,14 @@ static suite<"caps-numa-benchmark"> _ = [] expect(that % (4 == numa->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING)->size()) >> fatal); for (const auto &dp : *numa->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING)) { - expect(that % SYS_SAGE_DATAPATH_TYPE_DATATRANSFER == dp->GetDpType()); + expect(that % SYS_SAGE_DATAPATH_TYPE_DATATRANSFER == dp->GetDataPathType()); expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp->GetOriented()); } expect(that % (4 == numa->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING)->size()) >> fatal); for (const auto &dp : *numa->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING)) { - expect(that % SYS_SAGE_DATAPATH_TYPE_DATATRANSFER == dp->GetDpType()); + expect(that % SYS_SAGE_DATAPATH_TYPE_DATATRANSFER == dp->GetDataPathType()); expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp->GetOriented()); } } diff --git a/test/datapath.cpp b/test/datapath.cpp index 0b6483b..38ebc95 100644 --- a/test/datapath.cpp +++ b/test/datapath.cpp @@ -15,7 +15,7 @@ static suite<"data-path"> _ = [] expect(that % &a == dp.GetSource()); expect(that % &b == dp.GetTarget()); expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOriented()); - expect(that % SYS_SAGE_DATAPATH_TYPE_PHYSICAL == dp.GetDpType()); + expect(that % SYS_SAGE_DATAPATH_TYPE_PHYSICAL == dp.GetDataPathType()); }; "Constructor #2"_test = [] { @@ -24,7 +24,7 @@ static suite<"data-path"> _ = [] expect(that % &a == dp.GetSource()); expect(that % &b == dp.GetTarget()); expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOriented()); - expect(that % SYS_SAGE_DATAPATH_TYPE_NONE == dp.GetDpType()); + expect(that % SYS_SAGE_DATAPATH_TYPE_NONE == dp.GetDataPathType()); expect(that % 5.0 == dp.GetBw()); expect(that % 42.0 == dp.GetLatency()); }; @@ -35,7 +35,7 @@ static suite<"data-path"> _ = [] expect(that % &a == dp.GetSource()); expect(that % &b == dp.GetTarget()); expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOriented()); - expect(that % SYS_SAGE_DATAPATH_TYPE_PHYSICAL == dp.GetDpType()); + expect(that % SYS_SAGE_DATAPATH_TYPE_PHYSICAL == dp.GetDataPathType()); expect(that % 5.0 == dp.GetBw()); expect(that % 42.0 == dp.GetLatency()); }; @@ -81,12 +81,12 @@ static suite<"data-path"> _ = [] DataPath dp3{&a, &b, SYS_SAGE_DATAPATH_ORIENTED, SYS_SAGE_DATAPATH_TYPE_PHYSICAL}; DataPath dp4{&b, &a, SYS_SAGE_DATAPATH_ORIENTED, SYS_SAGE_DATAPATH_TYPE_PHYSICAL}; - expect(that % &dp1 == a.GetDpByType(SYS_SAGE_DATAPATH_TYPE_LOGICAL, SYS_SAGE_DATAPATH_OUTGOING)); - expect(that % &dp2 == a.GetDpByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_OUTGOING)); - expect(that % nullptr == a.GetDpByType(SYS_SAGE_DATAPATH_TYPE_L3CAT, SYS_SAGE_DATAPATH_OUTGOING)); - expect(that % &dp4 == a.GetDpByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING)); - expect(that % &dp4 == b.GetDpByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_OUTGOING)); - expect(that % &dp4 == b.GetDpByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING | SYS_SAGE_DATAPATH_OUTGOING)); + expect(that % &dp1 == a.GetDataPathByType(SYS_SAGE_DATAPATH_TYPE_LOGICAL, SYS_SAGE_DATAPATH_OUTGOING)); + expect(that % &dp2 == a.GetDataPathByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_OUTGOING)); + expect(that % nullptr == a.GetDataPathByType(SYS_SAGE_DATAPATH_TYPE_L3CAT, SYS_SAGE_DATAPATH_OUTGOING)); + expect(that % &dp4 == a.GetDataPathByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING)); + expect(that % &dp4 == b.GetDataPathByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_OUTGOING)); + expect(that % &dp4 == b.GetDataPathByType(SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING | SYS_SAGE_DATAPATH_OUTGOING)); }; "Get all data paths by type"_test = [] @@ -101,35 +101,35 @@ static suite<"data-path"> _ = [] "Get all incoming logical data paths"_test = [&]() { - a.GetAllDpByType(&v, SYS_SAGE_DATAPATH_TYPE_LOGICAL, SYS_SAGE_DATAPATH_INCOMING); + a.GetAllDataPathsByType(&v, SYS_SAGE_DATAPATH_TYPE_LOGICAL, SYS_SAGE_DATAPATH_INCOMING); expect(that % v.empty()); }; "Get all incoming physical data paths"_test = [&]() { std::vector v; - a.GetAllDpByType(&v, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING); + a.GetAllDataPathsByType(&v, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING); expect(std::vector{&dp4} == v); }; "Get all outgoing logical data paths"_test = [&]() { std::vector v; - a.GetAllDpByType(&v, SYS_SAGE_DATAPATH_TYPE_LOGICAL, SYS_SAGE_DATAPATH_OUTGOING); + a.GetAllDataPathsByType(&v, SYS_SAGE_DATAPATH_TYPE_LOGICAL, SYS_SAGE_DATAPATH_OUTGOING); expect(that % std::vector{&dp1} == v); }; "Get all outgoing physical data paths"_test = [&]() { std::vector v; - a.GetAllDpByType(&v, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_OUTGOING); + a.GetAllDataPathsByType(&v, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_OUTGOING); expect(that % std::vector{&dp2, &dp3} == v); }; "Get all physical data paths"_test = [&]() { std::vector v; - a.GetAllDpByType(&v, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING | SYS_SAGE_DATAPATH_OUTGOING); + a.GetAllDataPathsByType(&v, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, SYS_SAGE_DATAPATH_INCOMING | SYS_SAGE_DATAPATH_OUTGOING); expect(that % std::vector{&dp2, &dp3, &dp4} == v); }; }; From de26d4d48c8d9636199a84dafee7e8ff210131eb Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 21 Jun 2024 11:58:04 +0200 Subject: [PATCH 05/47] Added newer API calls --- src/Topology.cpp | 19 +++++++++++++++++++ src/Topology.hpp | 31 +++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index 1998766..c569106 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -312,6 +312,18 @@ int Component::CountAllSubcomponentsByType(int _componentType) return cnt; } +int Component::CountAllChildrenByType(int _componentType) +{ + int cnt = 0; + for(Component * child : children) + { + if(child->GetComponentType() == _componentType) + cnt++; + } + + return cnt; +} + Component* Component::FindParentByType(int _componentType) { return GetAncestorByType(_componentType); @@ -369,6 +381,13 @@ void Component::GetAllDataPathsByType(vector* outDpArr, int dp_type, return; } +vector Component::GetAllDataPathsByType(int dp_type, int orientation) +{ + vector outDpArr; + GetAllDataPathsByType(&outDpArr, dp_type, orientation); + return outDpArr; +} + vector* Component::GetDataPaths(int orientation) { if(orientation == SYS_SAGE_DATAPATH_INCOMING) diff --git a/src/Topology.hpp b/src/Topology.hpp index fb2560b..b9aa6e3 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -231,13 +231,28 @@ class Component { */ vector GetAllSubcomponentsByType(int _componentType); /** - * TODO + Counts number of subcomponents (children, their children and so on). + + @return Returns number of subcomponents. */ int CountAllSubcomponents(); + /** - * TODO + Counts number of subcomponents (children, their children and so on) matching the requested component type. + + @param _componentType - Component type to look for. + @return Returns number of subcomponents matching the requested component type. */ int CountAllSubcomponentsByType(int _componentType); + + /** + Counts number of children matching the requested component type. + + @param _componentType - Component type to look for. + @return Returns number of children matching the requested component type. + */ + int CountAllChildrenByType(int _componentType); + /** Moves up the tree until a parent of given type. @param _componentType - the desired component type @@ -344,6 +359,16 @@ class Component { \n The method pushes back the found data paths -- i.e. the data paths(pointers) can be found in this array after the method returns. (If no found, the vector is not changed.) */ void GetAllDataPathsByType(vector* outDpArr, int dp_type, int orientation); + + /** + Retrieves all DataPath * from the list of this component's data paths with matching type and orientation. + Results are returned in a vector*, where first the matching data paths in dp_outgoing are pushed back, then the ones in dp_incoming. + @param dp_type - DataPath type (dp_type) to search for. + @param orientation - orientation of the DataPath (SYS_SAGE_DATAPATH_OUTGOING or SYS_SAGE_DATAPATH_INCOMING or a logical or of these) + @return A std::vector with the results. + */ + vector GetAllDataPathsByType(int dp_type, int orientation); + /** * TODO */ @@ -356,6 +381,7 @@ class Component { */ int GetTopologySize(unsigned * out_component_size, unsigned * out_dataPathSize); /** + @private Helper function of int GetTopologySize(unsigned * out_component_size, unsigned * out_dataPathSize); -- normally you would call this one. \n Calculates approximate memory footprint of the subtree of this element (including the relevant data paths). Does not count DataPaths stored in counted_dataPaths. @param out_component_size - output parameter (contains the footprint of the component tree elements); an already allocated unsigned * is the input, the value is expected to be 0 (the result is accumulated here) @@ -367,6 +393,7 @@ class Component { int GetTopologySize(unsigned * out_component_size, unsigned * out_dataPathSize, std::set* counted_dataPaths); /** + @private !!Should normally not be used!! Helper function of XML dump generation. @see exportToXml(Component* root, string path = "", std::function custom_search_attrib_key_fcn = NULL); */ From a7ae2566eaf10401aa08265baccbbe0cea07b46a Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 21 Jun 2024 12:18:59 +0200 Subject: [PATCH 06/47] Modified datapaths and parser API calls --- examples/basic_usage.cpp | 10 ++++---- examples/cccbenchplushwloc.cpp | 6 ++--- examples/cpu-frequency.cpp | 12 +++++----- examples/custom_attributes.cpp | 12 +++++----- examples/larger_topo.cpp | 6 ++--- examples/sys-sage-benchmarking.cpp | 8 +++---- src/DataPath.cpp | 6 +++-- src/DataPath.hpp | 21 +++++++++++++++-- src/parsers/hwloc.cpp | 10 ++++---- src/parsers/hwloc.hpp | 4 ++-- src/xml_dump.cpp | 4 ++-- test/caps-numa-benchmark.cpp | 38 +++++++++++++++--------------- test/datapath.cpp | 10 ++++---- 13 files changed, 83 insertions(+), 64 deletions(-) diff --git a/examples/basic_usage.cpp b/examples/basic_usage.cpp index 9931f9d..824be8e 100644 --- a/examples/basic_usage.cpp +++ b/examples/basic_usage.cpp @@ -13,17 +13,17 @@ void usage(char* argv0) int main(int argc, char *argv[]) { - string topoPath; + string xmlPath; string bwPath; if(argc < 2){ std::string path_prefix(argv[0]); std::size_t found = path_prefix.find_last_of("/\\"); path_prefix=path_prefix.substr(0,found) + "/"; - topoPath = path_prefix + "example_data/skylake_hwloc.xml"; + xmlPath = path_prefix + "example_data/skylake_hwloc.xml"; bwPath = path_prefix + "example_data/skylake_caps_numa_benchmark.csv"; } else if(argc == 3){ - topoPath = argv[1]; + xmlPath = argv[1]; bwPath = argv[2]; } else{ @@ -36,8 +36,8 @@ int main(int argc, char *argv[]) Node* n = new Node(topo, 1); - cout << "-- Parsing Hwloc output from file " << topoPath << endl; - if(parseHwlocOutput(n, topoPath) != 0) { //adds topo to a next node + cout << "-- Parsing Hwloc output from file " << xmlPath << endl; + if(parseHwlocOutput(n, xmlPath) != 0) { //adds topo to a next node usage(argv[0]); return 1; } diff --git a/examples/cccbenchplushwloc.cpp b/examples/cccbenchplushwloc.cpp index a073e78..6e68502 100644 --- a/examples/cccbenchplushwloc.cpp +++ b/examples/cccbenchplushwloc.cpp @@ -12,10 +12,10 @@ void usage(char* argv0) int main(int argc, char *argv[]) { - string topoPath; + string xmlPath; const char *cccPath; if(argc == 3){ - topoPath = argv[1]; + xmlPath = argv[1]; cccPath = argv[2]; } else{ @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) Topology* topo = new Topology(); Node* n = new Node(topo, 1); - if(parseHwlocOutput(n, topoPath) != 0) { //adds topo to a next node + if(parseHwlocOutput(n, xmlPath) != 0) { //adds topo to a next node usage(argv[0]); return 1; } diff --git a/examples/cpu-frequency.cpp b/examples/cpu-frequency.cpp index 8a0e88e..cde5f75 100644 --- a/examples/cpu-frequency.cpp +++ b/examples/cpu-frequency.cpp @@ -13,19 +13,19 @@ void usage(char* argv0) int main(int argc, char *argv[]) { - string topoPath; + string xmlPath; string output_name = "sys-sage_cpu-frequency.xml"; if(argc < 2){ std::string path_prefix(argv[0]); std::size_t found = path_prefix.find_last_of("/\\"); path_prefix=path_prefix.substr(0,found) + "/"; - topoPath = path_prefix + "example_data/skylake_hwloc.xml"; + xmlPath = path_prefix + "example_data/skylake_hwloc.xml"; } else if(argc == 2){ - topoPath = argv[1]; + xmlPath = argv[1]; } else if(argc == 3){ - topoPath = argv[1]; + xmlPath = argv[1]; output_name = argv[2]; } else{ @@ -37,8 +37,8 @@ int main(int argc, char *argv[]) Topology* topo = new Topology(); Node* n = new Node(topo, 1); - cout << "-- Parsing Hwloc output from file " << topoPath << endl; - if(parseHwlocOutput(n, topoPath) != 0) { //adds topo to a next node + cout << "-- Parsing Hwloc output from file " << xmlPath << endl; + if(parseHwlocOutput(n, xmlPath) != 0) { //adds topo to a next node usage(argv[0]); return 1; } diff --git a/examples/custom_attributes.cpp b/examples/custom_attributes.cpp index e17ecc2..c2df91c 100644 --- a/examples/custom_attributes.cpp +++ b/examples/custom_attributes.cpp @@ -57,17 +57,17 @@ void usage(char* argv0) int main(int argc, char *argv[]) { - string topoPath; + string xmlPath; string bwPath; if(argc < 2){ std::string path_prefix(argv[0]); std::size_t found = path_prefix.find_last_of("/\\"); path_prefix=path_prefix.substr(0,found) + "/"; - topoPath = path_prefix + "example_data/skylake_hwloc.xml"; + xmlPath = path_prefix + "example_data/skylake_hwloc.xml"; bwPath = path_prefix + "example_data/skylake_caps_numa_benchmark.csv"; } else if(argc == 3){ - topoPath = argv[1]; + xmlPath = argv[1]; bwPath = argv[2]; } else{ @@ -79,8 +79,8 @@ int main(int argc, char *argv[]) Topology* topo = new Topology(); Node* n = new Node(topo, 1); - cout << "-- Parsing Hwloc output from file " << topoPath << endl; - if(parseHwlocOutput(n, topoPath) != 0) { //adds topo to a next node + cout << "-- Parsing Hwloc output from file " << xmlPath << endl; + if(parseHwlocOutput(n, xmlPath) != 0) { //adds topo to a next node usage(argv[0]); return 1; } @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) int r = 15; n->attrib["codename"]=(void*)&codename; n->attrib["rack_no"]=(void*)&r; - n->attrib["unknown_will_not_be_printed"]=(void*)&topoPath; + n->attrib["unknown_will_not_be_printed"]=(void*)&xmlPath; My_core_attributes c1_attrib(38.222, 2000000000); Core* c1 = (Core*)n->FindSubcomponentById(1, SYS_SAGE_COMPONENT_CORE); diff --git a/examples/larger_topo.cpp b/examples/larger_topo.cpp index b8f1b7e..25d129a 100644 --- a/examples/larger_topo.cpp +++ b/examples/larger_topo.cpp @@ -19,16 +19,16 @@ int main(int argc, char *argv[]) std::string path_prefix(argv[0]); std::size_t found = path_prefix.find_last_of("/\\"); path_prefix=path_prefix.substr(0,found) + "/"; - string topoPath = "example_data/skylake_hwloc.xml"; + string xmlPath = "example_data/skylake_hwloc.xml"; string bwPath = "example_data/skylake_caps_numa_benchmark.csv"; for(int n_idx=0; n_idxSetParent((Component*)topo); topo->InsertChild((Component*)n); - if(parseHwlocOutput(n, path_prefix+topoPath) != 0) + if(parseHwlocOutput(n, path_prefix+xmlPath) != 0) { - cout << "error parsing hwloc in path " << path_prefix+topoPath << endl; + cout << "error parsing hwloc in path " << path_prefix+xmlPath << endl; return 1; } if(parseCapsNumaBenchmark((Component*)n, path_prefix+bwPath, ";") != 0) diff --git a/examples/sys-sage-benchmarking.cpp b/examples/sys-sage-benchmarking.cpp index 6e380e5..6870da2 100644 --- a/examples/sys-sage-benchmarking.cpp +++ b/examples/sys-sage-benchmarking.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) std::string path_prefix(argv[0]); std::size_t found = path_prefix.find_last_of("/\\"); path_prefix=path_prefix.substr(0,found) + "/"; - string topoPath = path_prefix + "example_data/skylake_hwloc.xml"; + string xmlPath = path_prefix + "example_data/skylake_hwloc.xml"; string bwPath = path_prefix + "example_data/skylake_caps_numa_benchmark.csv"; string mt4gPath = path_prefix + "example_data/pascal_gpu_topo.csv"; @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) //time hwloc_parser t_start = high_resolution_clock::now(); - int ret = parseHwlocOutput(n, topoPath); + int ret = parseHwlocOutput(n, xmlPath); t_end = high_resolution_clock::now(); uint64_t time_parseHwlocOutput = t_end.time_since_epoch().count()-t_start.time_since_epoch().count()-timer_overhead; if(ret != 0) {//adds topo to a next node @@ -90,8 +90,8 @@ int main(int argc, char *argv[]) t_start = high_resolution_clock::now(); vector* dp = numa->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING); for(auto it = std::begin(*dp); it != std::end(*dp); ++it) { - if( (*it)->GetBw() > max_bw ){ - max_bw = (*it)->GetBw(); + if( (*it)->GetBandwidth() > max_bw ){ + max_bw = (*it)->GetBandwidth(); max_bw_component = (*it)->GetTarget(); } } diff --git a/src/DataPath.cpp b/src/DataPath.cpp index 96e914c..e160716 100644 --- a/src/DataPath.cpp +++ b/src/DataPath.cpp @@ -17,10 +17,12 @@ DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, int Component * DataPath::GetSource() {return source;} Component * DataPath::GetTarget() {return target;} -double DataPath::GetBw() {return bw;} +double DataPath::GetBandwidth() {return bw;} +void DataPath::SetBandwidth(double _bandwidth) { bw = _bandwidth;} double DataPath::GetLatency() {return latency;} +void DataPath::SetLatency(double _latency) { latency = _latency; } int DataPath::GetDataPathType() {return dp_type;} -int DataPath::GetOriented() {return oriented;} +int DataPath::GetOrientation() {return oriented;} DataPath::DataPath(Component* _source, Component* _target, int _oriented, int _type): DataPath(_source, _target, _oriented, _type, -1, -1) {} DataPath::DataPath(Component* _source, Component* _target, int _oriented, double _bw, double _latency): DataPath(_source, _target, _oriented, SYS_SAGE_DATAPATH_TYPE_NONE, _bw, _latency) {} diff --git a/src/DataPath.hpp b/src/DataPath.hpp index bfc294c..04a0c00 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -29,16 +29,19 @@ class Component; class DataPath; /** + @private Obsolete; use DataPath() constructors directly instead @see DataPath() */ DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, int _type = SYS_SAGE_DATAPATH_TYPE_NONE); /** + * @private Obsolete; use DataPath() constructors directly instead @see DataPath() */ DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, double _bw, double _latency); /** + * @private Obsolete; use DataPath() constructors directly instead @see DataPath() */ @@ -93,11 +96,25 @@ class DataPath { /** @returns Bandwidth from the source(provides the data) to the target(requests the data) */ - double GetBw(); + double GetBandwidth(); + + /** + * Sets the bandwidth from the source to the target. + @param _bandwidth - value for bw + @see bw + */ + void SetBandwidth(double _bandwidth); /** @returns Data load latency from the source(provides the data) to the target(requests the data) */ double GetLatency(); + + /** + * Sets the data load latency from the source to the target. + @param _latency - value for latency + @see latency + */ + void SetLatency(double _latency); /** @returns Type of the Data Path. @see dp_type @@ -106,7 +123,7 @@ class DataPath { /** * TODO */ - int GetOriented(); + int GetOrientation(); /** Prints basic information about the Data Path to stdout. Prints componentType and Id of the source and target Components, the bandwidth, load latency, and the attributes; for each attribute, the name and value are printed, however the value is only retyped to uint64_t (therefore will print nonsensical values for other data types). diff --git a/src/parsers/hwloc.cpp b/src/parsers/hwloc.cpp index 95d9293..0366bc0 100644 --- a/src/parsers/hwloc.cpp +++ b/src/parsers/hwloc.cpp @@ -220,11 +220,11 @@ int removeUnknownCompoents(Component* c){ } //parses a hwloc output and adds it to topology -int parseHwlocOutput(Node* n, string topoPath) +int parseHwlocOutput(Node* n, string xmlPath) { - xmlDoc *document = xmlReadFile(topoPath.c_str(), NULL, 0); + xmlDoc *document = xmlReadFile(xmlPath.c_str(), NULL, 0); if (document == NULL) { - cerr << "error: could not parse file " << topoPath.c_str() << endl; + cerr << "error: could not parse file " << xmlPath.c_str() << endl; xmlFreeDoc(document); return 1; } @@ -232,12 +232,12 @@ int parseHwlocOutput(Node* n, string topoPath) xmlNode *root= xmlDocGetRootElement(document); int err = xmlProcessChildren(n, root, 0); if(err != 0){ - std::cerr << "parseHwlocOutput on file " << topoPath << " failed on xmlProcessChildren" << std::endl; + std::cerr << "parseHwlocOutput on file " << xmlPath << " failed on xmlProcessChildren" << std::endl; return err; } err = removeUnknownCompoents(n); if(err != 0){ - std::cerr << "parseHwlocOutput on file " << topoPath << " failed on removeUnknownCompoents BUT WILL CONTINUE" << std::endl; + std::cerr << "parseHwlocOutput on file " << xmlPath << " failed on removeUnknownCompoents BUT WILL CONTINUE" << std::endl; //return ret; } xmlFreeDoc(document); diff --git a/src/parsers/hwloc.hpp b/src/parsers/hwloc.hpp index da3f04c..70f7038 100644 --- a/src/parsers/hwloc.hpp +++ b/src/parsers/hwloc.hpp @@ -15,9 +15,9 @@ Parser function for importing hwloc XML output to sys-sage. \n The parser looks for the XML object names defined in xmlRelevantNames, and considers (i.e. parses) the XML object types as defined in xmlRelevantObjectTypes. @param n - Pointer to an already existing Node where the hwloc topology will get parsed. -@param topoPath - Path to the XML output of hwloc that should be parsed and uploaded to sys-sage. +@param xmlPath - Path to the XML output of hwloc that should be parsed and uploaded to sys-sage. */ -int parseHwlocOutput(Node* n, std::string topoPath); +int parseHwlocOutput(Node* n, std::string xmlPath); /// @private int xmlProcessChildren(Component* c, xmlNode* parent, int level); /// @private diff --git a/src/xml_dump.cpp b/src/xml_dump.cpp index 124f681..7d3830e 100644 --- a/src/xml_dump.cpp +++ b/src/xml_dump.cpp @@ -264,9 +264,9 @@ int exportToXml(Component* root, string path, std::functionGetTarget(); xmlNewProp(dp_n, (const unsigned char *)"source", (const unsigned char *)(src_addr.str().c_str())); xmlNewProp(dp_n, (const unsigned char *)"target", (const unsigned char *)(target_addr.str().c_str())); - xmlNewProp(dp_n, (const unsigned char *)"oriented", (const unsigned char *)(std::to_string(dpPtr->GetOriented())).c_str()); + xmlNewProp(dp_n, (const unsigned char *)"oriented", (const unsigned char *)(std::to_string(dpPtr->GetOrientation())).c_str()); xmlNewProp(dp_n, (const unsigned char *)"dp_type", (const unsigned char *)(std::to_string(dpPtr->GetDataPathType())).c_str()); - xmlNewProp(dp_n, (const unsigned char *)"bw", (const unsigned char *)(std::to_string(dpPtr->GetBw())).c_str()); + xmlNewProp(dp_n, (const unsigned char *)"bw", (const unsigned char *)(std::to_string(dpPtr->GetBandwidth())).c_str()); xmlNewProp(dp_n, (const unsigned char *)"latency", (const unsigned char *)(std::to_string(dpPtr->GetLatency())).c_str()); xmlAddChild(data_paths_root, dp_n); diff --git a/test/caps-numa-benchmark.cpp b/test/caps-numa-benchmark.cpp index 44b7e09..8ecd69d 100644 --- a/test/caps-numa-benchmark.cpp +++ b/test/caps-numa-benchmark.cpp @@ -27,14 +27,14 @@ static suite<"caps-numa-benchmark"> _ = [] for (const auto &dp : *numa->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING)) { expect(that % SYS_SAGE_DATAPATH_TYPE_DATATRANSFER == dp->GetDataPathType()); - expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp->GetOriented()); + expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp->GetOrientation()); } expect(that % (4 == numa->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING)->size()) >> fatal); for (const auto &dp : *numa->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING)) { expect(that % SYS_SAGE_DATAPATH_TYPE_DATATRANSFER == dp->GetDataPathType()); - expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp->GetOriented()); + expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp->GetOrientation()); } } }; @@ -47,7 +47,7 @@ static suite<"caps-numa-benchmark"> _ = [] { auto dp1 = (*numas[i]->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING))[k]; auto dp2 = (*numas[k]->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING))[i]; - expect(that % dp1->GetBw() == dp2->GetBw()); + expect(that % dp1->GetBandwidth() == dp2->GetBandwidth()); expect(that % dp1->GetLatency() == dp2->GetLatency()); } } @@ -60,37 +60,37 @@ static suite<"caps-numa-benchmark"> _ = [] return (*numas[i]->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING))[k]; }; - expect(that % 8621 == dp(0, 0)->GetBw()); - expect(that % 8502 == dp(1, 0)->GetBw()); - expect(that % 6467 == dp(2, 0)->GetBw()); - expect(that % 6476 == dp(3, 0)->GetBw()); + expect(that % 8621 == dp(0, 0)->GetBandwidth()); + expect(that % 8502 == dp(1, 0)->GetBandwidth()); + expect(that % 6467 == dp(2, 0)->GetBandwidth()); + expect(that % 6476 == dp(3, 0)->GetBandwidth()); expect(that % 244 == dp(0, 0)->GetLatency()); expect(that % 195 == dp(1, 0)->GetLatency()); expect(that % 307 == dp(2, 0)->GetLatency()); expect(that % 313 == dp(3, 0)->GetLatency()); - expect(that % 8237 == dp(0, 1)->GetBw()); - expect(that % 8663 == dp(1, 1)->GetBw()); - expect(that % 6291 == dp(2, 1)->GetBw()); - expect(that % 6267 == dp(3, 1)->GetBw()); + expect(that % 8237 == dp(0, 1)->GetBandwidth()); + expect(that % 8663 == dp(1, 1)->GetBandwidth()); + expect(that % 6291 == dp(2, 1)->GetBandwidth()); + expect(that % 6267 == dp(3, 1)->GetBandwidth()); expect(that % 203 == dp(0, 1)->GetLatency()); expect(that % 237 == dp(1, 1)->GetLatency()); expect(that % 315 == dp(2, 1)->GetLatency()); expect(that % 319 == dp(3, 1)->GetLatency()); - expect(that % 6439 == dp(0, 2)->GetBw()); - expect(that % 6609 == dp(1, 2)->GetBw()); - expect(that % 8539 == dp(2, 2)->GetBw()); - expect(that % 8412 == dp(3, 2)->GetBw()); + expect(that % 6439 == dp(0, 2)->GetBandwidth()); + expect(that % 6609 == dp(1, 2)->GetBandwidth()); + expect(that % 8539 == dp(2, 2)->GetBandwidth()); + expect(that % 8412 == dp(3, 2)->GetBandwidth()); expect(that % 302 == dp(0, 2)->GetLatency()); expect(that % 313 == dp(1, 2)->GetLatency()); expect(that % 237 == dp(2, 2)->GetLatency()); expect(that % 210 == dp(3, 2)->GetLatency()); - expect(that % 6315 == dp(0, 3)->GetBw()); - expect(that % 6324 == dp(1, 3)->GetBw()); - expect(that % 8177 == dp(2, 3)->GetBw()); - expect(that % 8466 == dp(3, 3)->GetBw()); + expect(that % 6315 == dp(0, 3)->GetBandwidth()); + expect(that % 6324 == dp(1, 3)->GetBandwidth()); + expect(that % 8177 == dp(2, 3)->GetBandwidth()); + expect(that % 8466 == dp(3, 3)->GetBandwidth()); expect(that % 309 == dp(0, 3)->GetLatency()); expect(that % 316 == dp(1, 3)->GetLatency()); expect(that % 211 == dp(2, 3)->GetLatency()); diff --git a/test/datapath.cpp b/test/datapath.cpp index 38ebc95..c81ee81 100644 --- a/test/datapath.cpp +++ b/test/datapath.cpp @@ -14,7 +14,7 @@ static suite<"data-path"> _ = [] DataPath dp{&a, &b, SYS_SAGE_DATAPATH_ORIENTED, SYS_SAGE_DATAPATH_TYPE_PHYSICAL}; expect(that % &a == dp.GetSource()); expect(that % &b == dp.GetTarget()); - expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOriented()); + expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOrientation()); expect(that % SYS_SAGE_DATAPATH_TYPE_PHYSICAL == dp.GetDataPathType()); }; "Constructor #2"_test = [] @@ -23,9 +23,9 @@ static suite<"data-path"> _ = [] DataPath dp{&a, &b, SYS_SAGE_DATAPATH_ORIENTED, 5.0, 42.0}; expect(that % &a == dp.GetSource()); expect(that % &b == dp.GetTarget()); - expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOriented()); + expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOrientation()); expect(that % SYS_SAGE_DATAPATH_TYPE_NONE == dp.GetDataPathType()); - expect(that % 5.0 == dp.GetBw()); + expect(that % 5.0 == dp.GetBandwidth()); expect(that % 42.0 == dp.GetLatency()); }; "Constructor #3"_test = [] @@ -34,9 +34,9 @@ static suite<"data-path"> _ = [] DataPath dp{&a, &b, SYS_SAGE_DATAPATH_ORIENTED, SYS_SAGE_DATAPATH_TYPE_PHYSICAL, 5.0, 42.0}; expect(that % &a == dp.GetSource()); expect(that % &b == dp.GetTarget()); - expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOriented()); + expect(that % SYS_SAGE_DATAPATH_ORIENTED == dp.GetOrientation()); expect(that % SYS_SAGE_DATAPATH_TYPE_PHYSICAL == dp.GetDataPathType()); - expect(that % 5.0 == dp.GetBw()); + expect(that % 5.0 == dp.GetBandwidth()); expect(that % 42.0 == dp.GetLatency()); }; }; From 8e56f3a1f8fd34aa492df0925783e1120aa0eea2 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Mon, 24 Jun 2024 01:09:45 +0200 Subject: [PATCH 07/47] Added explanantory comments/documentation updates --- src/DataPath.hpp | 20 ++++--- src/Topology.hpp | 149 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 129 insertions(+), 40 deletions(-) diff --git a/src/DataPath.hpp b/src/DataPath.hpp index 04a0c00..11fe4ef 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -121,7 +121,10 @@ class DataPath { */ int GetDataPathType(); /** - * TODO + * Retrieves the orientation of the datapath (SYS_SAGE_DATAPATH_ORIENTED or SYS_SAGE_DATAPATH_BIDIRECTIONAL) + * @returns orientation + * @see oriented + * */ int GetOrientation(); @@ -138,18 +141,19 @@ class DataPath { void DeleteDataPath(); /** - * TODO + For storing arbitrary pieces of information or data. key denotes the name of the attribute, + and the value points to the data. */ map attrib; private: - Component * source; /**< TODO */ - Component * target; /**< TODO */ + Component * source; /**< source component of the datapath */ + Component * target; /**< taget component of the datapath */ - const int oriented; /**< TODO */ - const int dp_type; /**< TODO */ + const int oriented; /**< orientation of the datapath (SYS_SAGE_DATAPATH_ORIENTED or SYS_SAGE_DATAPATH_BIDIRECTIONAL) */ + const int dp_type; /**< type of the datapath */ - double bw; /**< TODO */ - double latency; /**< TODO */ + double bw; /**< Bandwidth from the source(provides the data) to the target(requests the data) */ + double latency; /**< Data load latency from the source(provides the data) to the target(requests the data) */ }; diff --git a/src/Topology.hpp b/src/Topology.hpp index b9aa6e3..ab63c01 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -68,18 +68,38 @@ class Component { @see GetChild(int _id) */ void InsertChild(Component * child); + /** - * TODO + * 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. + * @param parent The parent component to which this component will be inserted as a child. + * @param child The child component that will become the child of this component and will remain a descendant of the original parent. + * @param alreadyParentsChild A boolean flag indicating whether this component is already a child of the parent. + * \n If true, the function assumes that this component is already present as a child of the parent and only needs to reassign the specified child. + * \n If false, the function will add this component as a new child of the parent after reassigning the specified child. + * @return 0 on success; + * 1 if the child and parent are not child and parent in the component tree; + * 2 if the component tree is corrupt (parent is a parent of child but child is not in the parent's children list); + * 3 if the component tree is corrupt (parent is not a parent of child but child is in the parent's children list). */ int InsertBetweenParentAndChild(Component* parent, Component* child, bool alreadyParentsChild); + /** * Inserts this component between a parent and a (subset of) his children. The parent component remains parent, this Component becomes a new child, and the children become parent's grandchildren. - * @param TODO - * @return 0 on success, 1 on incompatible parent-children components (one or more children are not parent's children); 2 on corrupt component tree (parent is a parent of child but child is NOT in children list of parent); 3 on corrupt component tree (parent is NOT a parent of child but child is in children list of parent) + * @param parent The parent component to which this component will be inserted as a child. + * @param children A vector of child components that will become the children of this component and the grandchildren of the original parent. + * @param alreadyParentsChild A boolean flag indicating whether this component is already a child of the parent. + * \n If true, the function assumes that this component is already present as a child of the parent and only needs to reassign the specified children. + * \n If false, the function will add this component as a new child of the parent after reassigning the specified children. + * @return 0 on success + * \n 1 on incompatible parent-children components (one or more children are not parent's children); + * \n 2 on corrupt component tree (parent is a parent of child but child is NOT in children list of parent); + * \n 3 on corrupt component tree (parent is NOT a parent of child but child is in children list of parent) */ int InsertBetweenParentAndChildren(Component* parent, vector children, bool alreadyParentsChild); + /** - //TODO + Removes the passed component from the list of children, without completely deleting (and deallocating) the child itself + @param child - child to remove @return how many elements were deleted (normally, 0 or 1 should be possible) */ int RemoveChild(Component * child); @@ -183,7 +203,8 @@ class Component { Component* GetChildById(int _id); /** - * TODO + Retrieve a Component* to a child matching the given component type. + \n 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.) */ Component* GetChildByType(int _componentType); @@ -191,8 +212,7 @@ class Component { * Searches for all the children matching the given component type. * * @param _componentType - Required type of components - * @return A vector of all the children matching the _componentType - * @see void GetAllChildrenByType(vector *_outArray, int _componentType) + * @returns A vector of all the children matching the _componentType */ vector GetAllChildrenByType(int _componentType); @@ -222,24 +242,33 @@ class Component { @return Component * matching the criteria. Returns the first match. NULL if no match found */ Component* GetSubcomponentById(int _id, int _componentType); + /** - * TODO + * Searches for all the subcomponents (children, their children and so on) matching the given component type. + * + * @param _componentType - Required type of components + * @param outArray - output parameter (vector with results) + \n An input is pointer to a std::vector, in which the elements will be pushed. It must be allocated before the call (but does not have to be empty). + \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, nothing will be pushed into the vector.) */ void GetAllSubcomponentsByType(vector* outArray, int _componentType); + /** - * TODO -- make this non-public? + * Searches for all the subcomponents (children, their children and so on) matching the given component type. + * + * @param _componentType - Required type of components. + * @returns A vector of all the subcomponents matching the _componentType. */ vector GetAllSubcomponentsByType(int _componentType); + /** Counts number of subcomponents (children, their children and so on). - @return Returns number of subcomponents. */ int CountAllSubcomponents(); /** Counts number of subcomponents (children, their children and so on) matching the requested component type. - @param _componentType - Component type to look for. @return Returns number of subcomponents matching the requested component type. */ @@ -270,12 +299,14 @@ class Component { Returns the number of Components of type SYS_SAGE_COMPONENT_THREAD in the subtree. */ int GetNumThreads(); + /** Retrieves maximal distance to a leaf (i.e. the depth of the subtree). \n 0=leaf, 1=children are leaves, 2=at most children's children are leaves ..... @return maximal distance to a leaf */ int GetSubtreeDepth();//0=empty, 1=1element,... + /** 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. \n E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved.. @@ -370,7 +401,15 @@ class Component { vector GetAllDataPathsByType(int dp_type, int orientation); /** - * TODO + @brief Checks the consistency of the component tree starting from this component. + + This function verifies that each child component has this component set as its parent. + It logs an error message for each child that has an incorrect parent and increments the error count. + The function then recursively checks the consistency of the entire subtree rooted at each child component. + + @return The total number of inconsistencies found in the component tree. + + The function returns the total number of errors found in the component tree, including errors in the direct children and any nested descendants. */ int CheckComponentTreeConsistency(); /** @@ -415,7 +454,8 @@ class Component { void Delete(bool withSubtree = true); /** - TODO this part + For storing arbitrary pieces of information or data. key denotes the name of the attribute, + and the value points to the data. */ map attrib; protected: @@ -536,11 +576,14 @@ class Memory : public Component { */ ~Memory() override = default; /** - * TODO + * Retrieves size/capacity of the memory element + * @return size + * @see size */ long long GetSize(); /** - * TODO + * Sets size/capacity of the memory element + * @param _size = size */ void SetSize(long long _size); /** @@ -585,11 +628,14 @@ class Storage : public Component { */ ~Storage() override = default; /** - * TODO + * Retrieves size/capacity of the storage device + * @return size + * @see size */ long long GetSize(); /** - * TODO + * Sets size/capacity of the storage device + * @param _size = size */ void SetSize(long long _size); /** @@ -630,29 +676,43 @@ class Chip : public Component { */ ~Chip() override = default; /** - * TODO + Sets the vendor of the chip. + @param _vendor - The name of the vendor to set. */ void SetVendor(string _vendor); /** - * TODO + Gets the vendor of the chip. + @return The name of the vendor. + @see vendor */ string GetVendor(); + /** - * TODO + Sets the model of the chip. + @param _model - The model name to set. */ void SetModel(string _model); + /** - * TODO + Gets the model of the chip. + @return The model name. + @see model */ string GetModel(); + /** - * TODO + Sets the type of the chip. + @param chipType - The chip type to set. */ void SetChipType(int chipType); + /** - * TODO + Gets the type of the chip. + @return The chip type. + @see type */ int GetChipType(); + /** @private !!Should normally not be used!! Helper function of XML dump generation. @@ -660,13 +720,30 @@ class Chip : public Component { */ xmlNodePtr CreateXmlSubtree(); private: - string vendor; /**< TODO */ - string model; /**< TODO */ - int type; /**< TODO */ + string vendor; /**< Vendor of the chip */ + string model; /**< Model of the chip */ + int type; /**< Type of the chip, e.g., CPU, GPU */ #ifdef NVIDIA_MIG public: + /** + Updates the MIG settings for the chip. + @param uuid - The UUID of the chip, default is an empty string. + @return Status of the update operation. + */ int UpdateMIGSettings(string uuid = ""); + + /** + Gets the number of SMs for the MIG. + @param uuid - The UUID of the chip, default is an empty string. + @return The number of SMs. + */ int GetMIGNumSMs(string uuid = ""); + + /** + Gets the number of cores for the MIG. + @param uuid - The UUID of the chip, default is an empty string. + @return The number of cores. + */ int GetMIGNumCores(string uuid = ""); #endif }; @@ -726,7 +803,9 @@ class Cache : public Component { void SetCacheLevel(int _cache_level); /** - * TODO + Retrieves cache name of this cache (e.g. "L1", "texture") + @returns cache name + @see cache_name */ string GetCacheName(); @@ -737,11 +816,14 @@ class Cache : public Component { void SetCacheName(string _name); /** - @returns cache size of this cache + * Retrieves size/capacity of the cache + * @return size + * @see size */ long long GetCacheSize(); /** - * TODO + * Sets size/capacity of the cache + * @param _size = size */ void SetCacheSize(long long _cache_size); /** @@ -759,7 +841,8 @@ class Cache : public Component { */ int GetCacheLineSize(); /** - * TODO + * Sets the size of a cache line of this cache + @param _cache_line_size = cache_line_size */ void SetCacheLineSize(int _cache_line_size); /** @@ -806,11 +889,13 @@ class Subdivision : public Component { */ ~Subdivision() override = default; /** - * TODO + * Sets the type of the subdivision + @param subdivisionType = type */ void SetSubdivisionType(int subdivisionType); /** - * TODO + @returns the type of subdivision + @see type */ int GetSubdivisionType(); /** From 27f79f7f3a0eafb4d93139aa9cbd0d7fa6d527cd Mon Sep 17 00:00:00 2001 From: Durganshu Date: Mon, 24 Jun 2024 11:25:47 +0200 Subject: [PATCH 08/47] Small comment --- src/DataPath.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataPath.hpp b/src/DataPath.hpp index 11fe4ef..f2c4192 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -7,7 +7,7 @@ #include "Topology.hpp" //Component pointing to a DataPath -#define SYS_SAGE_DATAPATH_NONE 1 /**< TODO */ +#define SYS_SAGE_DATAPATH_NONE 1 /**< Reserved for development purposes. */ #define SYS_SAGE_DATAPATH_OUTGOING 2 /**< This Component is the source DataPath. */ #define SYS_SAGE_DATAPATH_INCOMING 4 /**< This Component is the taerget DataPath. */ From 6130826615677b0042a9cc7a249110198a7300a0 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Mon, 24 Jun 2024 14:25:10 +0200 Subject: [PATCH 09/47] Added comments for the destructors --- src/Topology.hpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Topology.hpp b/src/Topology.hpp index ab63c01..c0b1274 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -57,7 +57,8 @@ class Component { */ Component(Component * parent, int _id = 0, string _name = "unknown", int _componentType = SYS_SAGE_COMPONENT_NONE); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ virtual ~Component() = default; /** @@ -502,7 +503,8 @@ class Topology : public Component { */ Topology(); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Topology() override = default; private: @@ -530,7 +532,8 @@ class Node : public Component { */ Node(Component * parent, int _id = 0, string _name = "Node"); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Node() override = default; #ifdef CPUINFO @@ -572,7 +575,8 @@ class Memory : public Component { */ Memory(Component * parent, int id = 0, string _name = "Memory", long long _size = -1); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Memory() override = default; /** @@ -624,7 +628,8 @@ class Storage : public Component { */ Storage(Component * parent); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Storage() override = default; /** @@ -672,7 +677,8 @@ class Chip : public Component { */ Chip(Component * parent, int _id = 0, string _name = "Chip", int _type = SYS_SAGE_CHIP_TYPE_NONE); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Chip() override = default; /** @@ -787,7 +793,8 @@ class Cache : public Component { */ Cache(Component * parent, int _id = 0, int _cache_level = 0, long long _cache_size = -1, int _associativity = -1, int _cache_line_size = -1); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Cache() override = default; @@ -885,7 +892,8 @@ class Subdivision : public Component { */ Subdivision(Component * parent, int _id = 0, string _name = "Subdivision", int _componentType = SYS_SAGE_COMPONENT_SUBDIVISION); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Subdivision() override = default; /** @@ -932,7 +940,8 @@ class Numa : public Subdivision { */ Numa(Component * parent, int _id = 0, long long _size = -1); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Numa() override = default; /** @@ -979,7 +988,8 @@ class Core : public Component { */ Core(Component * parent, int _id = 0, string _name = "Core"); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Core() override = default; private: @@ -1016,7 +1026,8 @@ class Thread : public Component { */ Thread(Component * parent, int _id = 0, string _name = "Thread"); /** - * TODO + * @private + * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Thread() override = default; From 67a95003b5f4258675ade2b9b8b33b1c2df67d06 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Mon, 24 Jun 2024 23:50:44 +0200 Subject: [PATCH 10/47] Added GetNthDescendent --- src/Topology.cpp | 31 +++++++++++++++++++++++++++---- src/Topology.hpp | 12 ++++++++++-- test/topology.cpp | 2 +- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index c569106..c9c4647 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -185,7 +185,30 @@ int Component::GetSubtreeDepth() return maxDepth + 1; } -void Component::GetComponentsNLevelsDeeper(vector* outArray, int depth) +Component* Component::GetNthAncestor(int n) +{ + // For cases with incorrect inputs (0 and negative values) + if (n < 0) + return nullptr; // n can't be negative + else if(n == 0) + return this; // n = 0 means "this" + + Component* parent = GetParent(); + + // No parent means no further ancestors, the search can be stopped here. + if(parent == nullptr) + return nullptr; + + // base case + if(n == 1) + { + return parent; + } + return parent->GetNthAncestor(n - 1); + +} + +void Component::GetNthDescendents(vector* outArray, int depth) { if(depth <= 0) @@ -198,15 +221,15 @@ void Component::GetComponentsNLevelsDeeper(vector* outArray, int dep { cout << GetComponentTypeStr() << " (name " << name << ") id " << id << " - children: " << children.size(); cout << " depth: " << depth<<"\n"; - child->GetComponentsNLevelsDeeper(outArray, depth - 1); + child->GetNthDescendents(outArray, depth - 1); } return; } -vector Component::GetComponentsNLevelsDeeper(int depth) +vector Component::GetNthDescendents(int depth) { vector outArray; - GetComponentsNLevelsDeeper(&outArray, depth); + GetNthDescendents(&outArray, depth); return outArray; } diff --git a/src/Topology.hpp b/src/Topology.hpp index c0b1274..1dbb04e 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -308,6 +308,14 @@ class Component { */ int GetSubtreeDepth();//0=empty, 1=1element,... + /** + Retrieves Nth ancestor, which resides N levels above. + \n E.g. if n=1, the parent is retrieved; if n=2, the grandparent is retrieved and so on. + @param n - how many levels above the tree should be looked. + @returns The ancestor residing N levels above. + */ + Component* GetNthAncestor(int n); + /** 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. \n E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved.. @@ -316,7 +324,7 @@ class Component { \n An input is pointer to a std::vector, in which the elements will be pushed. It must be allocated before the call (but does not have to be empty). \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, nothing will be pushed into the vector.) */ - void GetComponentsNLevelsDeeper(vector* outArray, int depth); + void GetNthDescendents(vector* 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 the std::vector. @@ -324,7 +332,7 @@ class Component { @param depth - how many levels down the tree should be looked @return A std::vector with the results. */ - vector GetComponentsNLevelsDeeper(int depth); + vector GetNthDescendents(int depth); /** 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. diff --git a/test/topology.cpp b/test/topology.cpp index b1ce46f..963a633 100644 --- a/test/topology.cpp +++ b/test/topology.cpp @@ -239,7 +239,7 @@ static suite<"topology"> _ = [] c.InsertChild(&d); std::vector array; - a.GetComponentsNLevelsDeeper(&array, 1); + a.GetNthDescendents(&array, 1); expect(that % 2_u == array.size()); }; From a3539fe12b7ef2b7f2bdb79bac45bc833b773f7c Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 27 Jun 2024 13:56:40 +0200 Subject: [PATCH 11/47] Added deprecated compiler warnings --- src/DataPath.hpp | 3 +++ src/Topology.hpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/DataPath.hpp b/src/DataPath.hpp index f2c4192..694969c 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -33,18 +33,21 @@ class DataPath; Obsolete; use DataPath() constructors directly instead @see DataPath() */ +[[deprecated("Use DataPath() constructors directly instead.")]] DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, int _type = SYS_SAGE_DATAPATH_TYPE_NONE); /** * @private Obsolete; use DataPath() constructors directly instead @see DataPath() */ +[[deprecated("Use DataPath() constructors directly instead.")]] DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, double _bw, double _latency); /** * @private Obsolete; use DataPath() constructors directly instead @see DataPath() */ +[[deprecated("Use DataPath() constructors directly instead.")]] DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, int _type, double _bw, double _latency); /** diff --git a/src/Topology.hpp b/src/Topology.hpp index 1dbb04e..954e98c 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -229,11 +229,13 @@ class Component { /** OBSOLETE. Use GetSubcomponentById instead. This function will be removed in the future. */ + [[deprecated("Use GetSubcomponentById instead. This function will be removed in the future.")]] Component* FindSubcomponentById(int _id, int _componentType); /** @private OBSOLETE. Use GetAllSubcomponentsByType instead. This function will be removed in the future. */ + [[deprecated("Use GetAllSubcomponentsByType instead. This function will be removed in the future.")]] void FindAllSubcomponentsByType(vector* outArray, int _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. @@ -293,12 +295,14 @@ class Component { @private OBSOLETE. Use GetAncestorByType instead. This function will be removed in the future. */ + [[deprecated("Use GetAncestorByType instead. This function will be removed in the future.")]] Component* FindParentByType(int _componentType); /** OBSOLETE. Use int CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) instead. Returns the number of Components of type SYS_SAGE_COMPONENT_THREAD in the subtree. */ + [[deprecated("Use int CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) instead.")]] int GetNumThreads(); /** From 4d4142780200199f4210160b5596c0a8a3c38ce2 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 28 Jun 2024 18:59:43 +0200 Subject: [PATCH 12/47] GetSubtreeNodeList renamed and Component::DeleteDataPath added --- examples/sys-sage-benchmarking.cpp | 6 +++--- src/DataPath.hpp | 4 ++-- src/Topology.cpp | 15 ++++++++++----- src/Topology.hpp | 10 ++++++++-- src/xml_dump.cpp | 2 +- test/topology.cpp | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/examples/sys-sage-benchmarking.cpp b/examples/sys-sage-benchmarking.cpp index 6870da2..1c90f8e 100644 --- a/examples/sys-sage-benchmarking.cpp +++ b/examples/sys-sage-benchmarking.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) //time get a vector with all Components (of hwloc parser) hwlocComponentList.clear(); t_start = high_resolution_clock::now(); - n->GetSubtreeNodeList(&hwlocComponentList); + n->GetComponentsInSubtree(&hwlocComponentList); t_end = high_resolution_clock::now(); uint64_t time_GetHwlocSubtreeNodeList = t_end.time_since_epoch().count()-t_start.time_since_epoch().count()-timer_overhead; @@ -112,14 +112,14 @@ int main(int argc, char *argv[]) //time get a vector with all Components (of mt4g parser) mt4gComponentList.clear(); t_start = high_resolution_clock::now(); - gpu->GetSubtreeNodeList(&mt4gComponentList); + gpu->GetComponentsInSubtree(&mt4gComponentList); t_end = high_resolution_clock::now(); uint64_t time_GetMt4gSubtreeNodeList = t_end.time_since_epoch().count()-t_start.time_since_epoch().count()-timer_overhead; //time get a vector with all Components allComponentList.clear(); t_start = high_resolution_clock::now(); - t->GetSubtreeNodeList(&allComponentList); + t->GetComponentsInSubtree(&allComponentList); t_end = high_resolution_clock::now(); uint64_t time_GetAllComponentsList = t_end.time_since_epoch().count()-t_start.time_since_epoch().count()-timer_overhead; diff --git a/src/DataPath.hpp b/src/DataPath.hpp index 694969c..4b980c4 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -137,12 +137,12 @@ class DataPath { void Print(); /** - Deletes and de-allocated the DataPath pointer from the list(std::vector) of outgoing and incoming DataPaths of source and target Components. + Deletes and de-allocates the DataPath pointer from the list(std::vector) of outgoing and incoming DataPaths of source and target Components. @see dp_incoming @see dp_outgoing */ void DeleteDataPath(); - + /** For storing arbitrary pieces of information or data. key denotes the name of the attribute, and the value points to the data. diff --git a/src/Topology.cpp b/src/Topology.cpp index c9c4647..8b05126 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -22,7 +22,7 @@ void Component::PrintSubtree(int level) void Component::PrintAllDataPathsInSubtree() { vector subtreeList; - GetSubtreeNodeList(&subtreeList); + GetComponentsInSubtree(&subtreeList); for(Component * c : subtreeList) { vector* dp_in = c->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING); @@ -251,20 +251,20 @@ vector Component::GetSubcomponentsByType(int _componentType) return outArray; } -void Component::GetSubtreeNodeList(vector* outArray) +void Component::GetComponentsInSubtree(vector* outArray) { outArray->push_back(this); for(Component * child : children) { - child->GetSubtreeNodeList(outArray); + child->GetComponentsInSubtree(outArray); } return; } -vector Component::GetSubtreeNodeList() +vector Component::GetComponentsInSubtree() { vector outArray; - GetSubtreeNodeList(&outArray); + GetComponentsInSubtree(&outArray); return outArray; } @@ -547,6 +547,11 @@ int Component::GetTopologySize(unsigned * out_component_size, unsigned * out_dat } +void Component::DeleteDataPath(DataPath * dp) +{ + dp->DeleteDataPath(); +} + void Component::DeleteAllDataPaths() { while(!dp_outgoing.empty()) diff --git a/src/Topology.hpp b/src/Topology.hpp index 954e98c..32bc998 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -360,13 +360,13 @@ class Component { \n An input is pointer to a std::vector, in which the elements will be pushed. It must be allocated before the call (but does not have to be empty). \n The method pushes back the found elements -- i.e. the elements(pointers) can be found in this array after the method returns. (If no found, the vector is not changed.) */ - void GetSubtreeNodeList(vector* outArray); + void GetComponentsInSubtree(vector* outArray); /** Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this. @return A std::vector with the results. */ - vector GetSubtreeNodeList(); + vector GetComponentsInSubtree(); /** Returns the DataPaths of this component according to their orientation. @@ -451,6 +451,12 @@ class Component { */ xmlNodePtr CreateXmlSubtree(); + /** + Deletes and de-allocates the DataPath pointer from the list(std::vector) of outgoing and incoming DataPaths of the Components. + @param dp - DataPath to Delete + */ + void DeleteDataPath(DataPath * dp); + /** Deletes all DataPaths of this component. */ diff --git a/src/xml_dump.cpp b/src/xml_dump.cpp index 7d3830e..a431b88 100644 --- a/src/xml_dump.cpp +++ b/src/xml_dump.cpp @@ -245,7 +245,7 @@ int exportToXml(Component* root, string path, std::function components; - root->GetSubtreeNodeList(&components); + root->GetComponentsInSubtree(&components); std::cout << "Number of components to export: " << components.size() << std::endl; for(Component* cPtr : components) { diff --git a/test/topology.cpp b/test/topology.cpp index 963a633..3871232 100644 --- a/test/topology.cpp +++ b/test/topology.cpp @@ -289,7 +289,7 @@ static suite<"topology"> _ = [] a.InsertChild(&c); std::vector array; - a.GetSubtreeNodeList(&array); + a.GetComponentsInSubtree(&array); expect(that % array == (std::vector{&a, &b, &d, &c})); }; From a67eaa883b0f87570c44f73a45325b96e02a7442 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 28 Jun 2024 20:35:13 +0200 Subject: [PATCH 13/47] deprecated all the warnings --- examples/basic_usage.cpp | 2 +- examples/cccbenchplushwloc.cpp | 4 ++-- examples/custom_attributes.cpp | 6 +++--- examples/custom_parser_musa/musa_parser.cpp | 10 +++++++--- examples/custom_parser_musa/use_custom_parser.cpp | 2 +- examples/mt4g-parser.cpp | 2 +- examples/sys-sage-benchmarking.cpp | 2 +- src/DataPath.cpp | 10 ++++++---- src/Topology.cpp | 4 ++-- src/parsers/caps-numa-benchmark.cpp | 6 +++--- src/parsers/cccbench.cpp | 2 +- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/examples/basic_usage.cpp b/examples/basic_usage.cpp index 824be8e..7b2e274 100644 --- a/examples/basic_usage.cpp +++ b/examples/basic_usage.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) } cout << "-- End parseHwlocOutput" << endl; - cout << "Total num HW threads: " << topo->GetNumThreads() << endl; + cout << "Total num HW threads: " << topo->CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) << endl; cout << "---------------- Printing the whole tree ----------------" << endl; topo->PrintSubtree(); diff --git a/examples/cccbenchplushwloc.cpp b/examples/cccbenchplushwloc.cpp index 6e68502..f682f4c 100644 --- a/examples/cccbenchplushwloc.cpp +++ b/examples/cccbenchplushwloc.cpp @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) } cout << "-- End parseHwlocOutput" << endl; - cout << "Total num HW threads: " << topo->GetNumThreads() << endl; + cout << "Total num HW threads: " << topo->CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) << endl; cout << "---------------- Printing the whole tree ----------------" << endl; topo->PrintSubtree(2); @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) cccparser->applyDataPaths(n); auto allcores = new vector(); - topo->FindAllSubcomponentsByType(allcores, SYS_SAGE_COMPONENT_CORE); + topo->GetAllSubcomponentsByType(allcores, SYS_SAGE_COMPONENT_CORE); //auto allcores = topo->GetAllChildrenByType(SYS_SAGE_COMPONENT_CORE); for(auto c0 : *allcores) diff --git a/examples/custom_attributes.cpp b/examples/custom_attributes.cpp index c2df91c..898e02e 100644 --- a/examples/custom_attributes.cpp +++ b/examples/custom_attributes.cpp @@ -101,17 +101,17 @@ int main(int argc, char *argv[]) n->attrib["unknown_will_not_be_printed"]=(void*)&xmlPath; My_core_attributes c1_attrib(38.222, 2000000000); - Core* c1 = (Core*)n->FindSubcomponentById(1, SYS_SAGE_COMPONENT_CORE); + Core* c1 = (Core*)n->GetSubcomponentById(1, SYS_SAGE_COMPONENT_CORE); if(c1 != NULL) c1->attrib["my_core_info"]=(void*)&c1_attrib; My_core_attributes c4_attrib(44.1, 1500000000); - Core* c4 = (Core*)n->FindSubcomponentById(4, SYS_SAGE_COMPONENT_CORE); + Core* c4 = (Core*)n->GetSubcomponentById(4, SYS_SAGE_COMPONENT_CORE); if(c4 != NULL) c4->attrib["my_core_info"]=(void*)&c4_attrib; string benchmark_info="measured with no load on 07.07."; - Numa* n2 = (Numa*)n->FindSubcomponentById(2, SYS_SAGE_COMPONENT_NUMA); + Numa* n2 = (Numa*)n->GetSubcomponentById(2, SYS_SAGE_COMPONENT_NUMA); if(n2 != NULL){ DataPath * dp = (*(n2->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING)))[0]; if(dp != NULL) diff --git a/examples/custom_parser_musa/musa_parser.cpp b/examples/custom_parser_musa/musa_parser.cpp index dfa2f1f..a2c5120 100644 --- a/examples/custom_parser_musa/musa_parser.cpp +++ b/examples/custom_parser_musa/musa_parser.cpp @@ -128,10 +128,14 @@ Memory* MusaParser::ParseMemory() { int pos1 = input.find("_"); int pos2 = input.find("_", pos1+1); std::string output; - if(pos2 == std::string::npos) //no second underscore + if(pos2 == std::string::npos) {//no second underscore output = input.substr(pos1 + 1); - else - output = input.substr(pos1 + 1, pos2 - pos1 - 1); + } + else{ + output = input.substr(pos1 + 1, pos2 - pos1 - 1); + } + + long long size = stol(output); long long channels = stol(mapping["RAMULATOR"]["channels"]); if(channels > 0) diff --git a/examples/custom_parser_musa/use_custom_parser.cpp b/examples/custom_parser_musa/use_custom_parser.cpp index 3b35fa5..a807479 100644 --- a/examples/custom_parser_musa/use_custom_parser.cpp +++ b/examples/custom_parser_musa/use_custom_parser.cpp @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) return 1; } cout << "-- End parseMusa" << endl; - cout << "Total num HW threads: " << topo->GetNumThreads() << endl; + cout << "Total num HW threads: " << topo->CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) << endl; cout << "---------------- Printing the whole tree ----------------" << endl; topo->PrintSubtree(2); diff --git a/examples/mt4g-parser.cpp b/examples/mt4g-parser.cpp index cb5ea10..3001276 100644 --- a/examples/mt4g-parser.cpp +++ b/examples/mt4g-parser.cpp @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) } cout << "-- End parseGpuTopo" << endl; - cout << "Total num GPU cores: " << topo->GetNumThreads() << endl; + cout << "Total num GPU cores: " << topo->CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD) << endl; string output_name = "sys-sage_gpu_sample_output.xml"; cout << "-------- Exporting as XML to " << output_name << " --------" << endl; diff --git a/examples/sys-sage-benchmarking.cpp b/examples/sys-sage-benchmarking.cpp index 1c90f8e..196344e 100644 --- a/examples/sys-sage-benchmarking.cpp +++ b/examples/sys-sage-benchmarking.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) unsigned total_size = n->GetTopologySize(&hwloc_component_size, &caps_numa_dataPathSize); //for NUMA 0 get NUMA with min BW - Numa * numa = (Numa*)n->FindSubcomponentById(0, SYS_SAGE_COMPONENT_NUMA); + Numa * numa = (Numa*)n->GetSubcomponentById(0, SYS_SAGE_COMPONENT_NUMA); if(numa==NULL){ cerr << "numa 0 not found in sys-sage" << endl; return 1;} unsigned int max_bw = 0; Component* max_bw_component = NULL; diff --git a/src/DataPath.cpp b/src/DataPath.cpp index e160716..cba4f6c 100644 --- a/src/DataPath.cpp +++ b/src/DataPath.cpp @@ -4,15 +4,17 @@ #include DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, int _type){ - return NewDataPath(_source,_target,_oriented,_type,(double)-1,(double)-1); + DataPath *dp = new DataPath(_source, _target, _oriented, _type, -1, -1); + return dp; } DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, double _bw, double _latency){ - return NewDataPath(_source,_target,_oriented,SYS_SAGE_DATAPATH_TYPE_NONE,_bw,_latency); + DataPath *dp = new DataPath(_source,_target,_oriented,SYS_SAGE_DATAPATH_TYPE_NONE,_bw,_latency); + return dp; } DataPath* NewDataPath(Component* _source, Component* _target, int _oriented, int _type, double _bw, double _latency) { - DataPath* p = new DataPath(_source, _target, _oriented, _type, _bw, _latency); - return p; + DataPath* dp = new DataPath(_source, _target, _oriented, _type, _bw, _latency); + return dp; } Component * DataPath::GetSource() {return source;} diff --git a/src/Topology.cpp b/src/Topology.cpp index 8b05126..46bbfd9 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -166,7 +166,7 @@ int Component::GetNumThreads() int numPu = 0; for(Component * child: children) { - numPu += child->GetNumThreads(); + numPu += child->CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD); } return numPu; } @@ -358,7 +358,7 @@ Component* Component::GetAncestorByType(int _componentType) return this; } if(parent != NULL){ - return parent->FindParentByType(_componentType); + return parent->GetAncestorByType(_componentType); } return NULL; } diff --git a/src/parsers/caps-numa-benchmark.cpp b/src/parsers/caps-numa-benchmark.cpp index 27a24a0..7ea8a8a 100644 --- a/src/parsers/caps-numa-benchmark.cpp +++ b/src/parsers/caps-numa-benchmark.cpp @@ -57,13 +57,13 @@ int parseCapsNumaBenchmark(Component* rootComponent, string benchmarkPath, strin if(cpu_is_source){ src_cpu_id = stoi(benchmarkData[i][src_cpu_idx]); - src = rootComponent->FindSubcomponentById(src_cpu_id, SYS_SAGE_COMPONENT_THREAD); + src = rootComponent->GetSubcomponentById(src_cpu_id, SYS_SAGE_COMPONENT_THREAD); }else{ src_numa_id = stoi(benchmarkData[i][src_numa_idx]); - src = rootComponent->FindSubcomponentById(src_numa_id, SYS_SAGE_COMPONENT_NUMA); + src = rootComponent->GetSubcomponentById(src_numa_id, SYS_SAGE_COMPONENT_NUMA); } target_numa_id = stoi(benchmarkData[i][target_numa_idx]); - target = rootComponent->FindSubcomponentById(target_numa_id, SYS_SAGE_COMPONENT_NUMA); + target = rootComponent->GetSubcomponentById(target_numa_id, SYS_SAGE_COMPONENT_NUMA); if(src == NULL || target == NULL) cerr << "error: could not find components; skipping " << endl; else{ diff --git a/src/parsers/cccbench.cpp b/src/parsers/cccbench.cpp index 5cfc85a..a4449ff 100644 --- a/src/parsers/cccbench.cpp +++ b/src/parsers/cccbench.cpp @@ -87,7 +87,7 @@ CccbenchParser::CccbenchParser(const char *csv_path) void CccbenchParser::applyDataPaths(Component *root) { auto corev = new vector(); - root->FindAllSubcomponentsByType(corev, SYS_SAGE_COMPONENT_CORE); + root->GetAllSubcomponentsByType(corev, SYS_SAGE_COMPONENT_CORE); //auto corev = root->GetAllChildrenByType(SYS_SAGE_COMPONENT_CORE); for(auto xcore : *corev) From 1f530e6d321434ab2d96d4e9664510bcb0f3d170 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 3 Jul 2024 01:38:26 +0200 Subject: [PATCH 14/47] Added GetDepth(bool refresh) --- src/Topology.cpp | 16 ++++++++++++++++ src/Topology.hpp | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Topology.cpp b/src/Topology.cpp index 46bbfd9..e0c8c2b 100644 --- a/src/Topology.cpp +++ b/src/Topology.cpp @@ -470,6 +470,7 @@ int Component::GetTopologySize(unsigned * out_component_size, unsigned * out_dat { return GetTopologySize(out_component_size, out_dataPathSize, NULL); } + int Component::GetTopologySize(unsigned * out_component_size, unsigned * out_dataPathSize, std::set* counted_dataPaths) { if(counted_dataPaths == NULL) @@ -546,6 +547,21 @@ int Component::GetTopologySize(unsigned * out_component_size, unsigned * out_dat return component_size + dataPathSize + subtreeSize; } +int Component::GetDepth(bool refresh) +{ + if(refresh) + { + depth = 0; + Component *parent = GetParent(); + while(parent != NULL) + { + depth++; + parent = parent->GetParent(); + } + } + + return depth; +} void Component::DeleteDataPath(DataPath * dp) { diff --git a/src/Topology.hpp b/src/Topology.hpp index 32bc998..d1b89a7 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -444,6 +444,15 @@ class Component { */ int GetTopologySize(unsigned * out_component_size, unsigned * out_dataPathSize, std::set* counted_dataPaths); + /** + * Retrieves the depth (level) of a component in the topology. + * @param refresh - Boolean value, if true: recalculate the position (depth) of the component in the tree, + * if false, return the already stored value + * @return The depth (level) of a component in the topology + * @see depth + */ + int GetDepth(bool refresh); + /** @private !!Should normally not be used!! Helper function of XML dump generation. @@ -480,7 +489,7 @@ class Component { protected: int id; /**< Numeric ID of the component. There is no requirement for uniqueness of the ID, however it is advised to have unique IDs at least in the realm of parent's children. Some tree search functions, which take the id as a search parameter search for first match, so the user is responsible to manage uniqueness in the realm of the search subtree (or should be aware of the consequences of not doing so). Component's ID is set by the constructor, and is retrieved via int GetId(); */ - int depth; /**< TODO not implemented */ + int depth; /**< Depth (level) of the Component in the Component Tree */ string name; /**< Name of the component (as a string). */ int count{-1}; /**< Can be used to represent multiple Components with the same properties. By default, it represents only 1 component, and is set to -1. */ /** From 3007ca8cf1f1bbb47f844c81634c8a90b4de5da6 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 3 Jul 2024 17:14:59 +0200 Subject: [PATCH 15/47] Added UpdateSource and UpdateTarget --- src/DataPath.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ src/DataPath.hpp | 15 ++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/DataPath.cpp b/src/DataPath.cpp index cba4f6c..90da610 100644 --- a/src/DataPath.cpp +++ b/src/DataPath.cpp @@ -26,6 +26,58 @@ void DataPath::SetLatency(double _latency) { latency = _latency; } int DataPath::GetDataPathType() {return dp_type;} int DataPath::GetOrientation() {return oriented;} +void DataPath::UpdateSource(Component * _new_source) +{ + if(oriented == SYS_SAGE_DATAPATH_BIDIRECTIONAL) + { + std::vector* source_dp_outgoing = source->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING); + std::vector* source_dp_incoming = source->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING); + + source_dp_outgoing->erase(std::remove(source_dp_outgoing->begin(), source_dp_outgoing->end(), this), source_dp_outgoing->end()); + source_dp_incoming->erase(std::remove(source_dp_incoming->begin(), source_dp_incoming->end(), this), source_dp_incoming->end()); + + _new_source->AddDataPath(this, SYS_SAGE_DATAPATH_OUTGOING); + _new_source->AddDataPath(this, SYS_SAGE_DATAPATH_INCOMING); + + } + else if(oriented == SYS_SAGE_DATAPATH_ORIENTED) + { + std::vector* source_dp_outgoing = source->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING); + source_dp_outgoing->erase(std::remove(source_dp_outgoing->begin(), source_dp_outgoing->end(), this), source_dp_outgoing->end()); + + _new_source->AddDataPath(this, SYS_SAGE_DATAPATH_OUTGOING); + } + + source = _new_source; + +} + +void DataPath::UpdateTarget(Component * _new_target) +{ + if(oriented == SYS_SAGE_DATAPATH_BIDIRECTIONAL) + { + std::vector* target_dp_outgoing = target->GetDataPaths(SYS_SAGE_DATAPATH_OUTGOING); + std::vector* target_dp_incoming = target->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING); + + target_dp_outgoing->erase(std::remove(target_dp_outgoing->begin(), target_dp_outgoing->end(), this), target_dp_outgoing->end()); + target_dp_incoming->erase(std::remove(target_dp_incoming->begin(), target_dp_incoming->end(), this), target_dp_incoming->end()); + + _new_target->AddDataPath(this, SYS_SAGE_DATAPATH_OUTGOING); + _new_target->AddDataPath(this, SYS_SAGE_DATAPATH_INCOMING); + + } + else if(oriented == SYS_SAGE_DATAPATH_ORIENTED) + { + std::vector* target_dp_incoming = target->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING); + target_dp_incoming->erase(std::remove(target_dp_incoming->begin(), target_dp_incoming->end(), this), target_dp_incoming->end()); + + _new_target->AddDataPath(this, SYS_SAGE_DATAPATH_INCOMING); + } + + target = _new_target; + +} + DataPath::DataPath(Component* _source, Component* _target, int _oriented, int _type): DataPath(_source, _target, _oriented, _type, -1, -1) {} DataPath::DataPath(Component* _source, Component* _target, int _oriented, double _bw, double _latency): DataPath(_source, _target, _oriented, SYS_SAGE_DATAPATH_TYPE_NONE, _bw, _latency) {} DataPath::DataPath(Component* _source, Component* _target, int _oriented, int _type, double _bw, double _latency): source(_source), target(_target), oriented(_oriented), dp_type(_type), bw(_bw), latency(_latency) diff --git a/src/DataPath.hpp b/src/DataPath.hpp index 4b980c4..afac45b 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -118,6 +118,21 @@ class DataPath { @see latency */ void SetLatency(double _latency); + + /** + * Updates the source of the DataPath. The datapath is removed from the outgoing/incoming vectors of the old source and + * added to the vectors of the newer source. + * @param _new_source - New source of the DataPath. + */ + void UpdateSource(Component * _new_source); + + /** + * Updates the target of the DataPath. The datapath is removed from the outgoing/incoming vectors of the old target and + * added to the vectors of the newer target. + * @param _new_source - New target of the DataPath. + */ + void UpdateTarget(Component * _new_target); + /** @returns Type of the Data Path. @see dp_type From d46d5786e64a6eb8c6a02df55dbeb9a2f8acf3b6 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 3 Jul 2024 20:13:16 +0200 Subject: [PATCH 16/47] Renamed Topology.cpp -> Component.cpp --- src/CAT_aware.cpp | 2 +- src/CMakeLists.txt | 4 ++-- src/{Topology.cpp => Component.cpp} | 2 +- src/{Topology.hpp => Component.hpp} | 4 ++-- src/DataPath.hpp | 2 +- src/cpuinfo.cpp | 2 +- src/nvidia_mig.cpp | 2 +- src/parsers/caps-numa-benchmark.hpp | 2 +- src/parsers/cccbench.hpp | 2 +- src/parsers/hwloc.hpp | 2 +- src/parsers/mt4g.hpp | 2 +- src/sys-sage.hpp | 2 +- src/xml_dump.hpp | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) rename src/{Topology.cpp => Component.cpp} (99%) rename src/{Topology.hpp => Component.hpp} (99%) diff --git a/src/CAT_aware.cpp b/src/CAT_aware.cpp index f1ea6a5..b4726d6 100644 --- a/src/CAT_aware.cpp +++ b/src/CAT_aware.cpp @@ -9,7 +9,7 @@ #include //memset #include //numeric_limits -#include "Topology.hpp" +#include "Component.hpp" using namespace std; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d29ea64..478367e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) configure_file(${PROJECT_SOURCE_DIR}/src/defines.hpp.in ${PROJECT_SOURCE_DIR}/src/defines.hpp) set(SOURCES - Topology.cpp + Component.cpp DataPath.cpp CAT_aware.cpp cpuinfo.cpp @@ -19,7 +19,7 @@ set(SOURCES set(HEADERS sys-sage.hpp defines.hpp - Topology.hpp + Component.hpp DataPath.hpp xml_dump.hpp parsers/hwloc.hpp diff --git a/src/Topology.cpp b/src/Component.cpp similarity index 99% rename from src/Topology.cpp rename to src/Component.cpp index e0c8c2b..ef6ed09 100644 --- a/src/Topology.cpp +++ b/src/Component.cpp @@ -1,4 +1,4 @@ -#include "Topology.hpp" +#include "Component.hpp" #include diff --git a/src/Topology.hpp b/src/Component.hpp similarity index 99% rename from src/Topology.hpp rename to src/Component.hpp index d1b89a7..4cca5b3 100644 --- a/src/Topology.hpp +++ b/src/Component.hpp @@ -1,5 +1,5 @@ -#ifndef TOPOLOGY -#define TOPOLOGY +#ifndef COMPONENT +#define COMPONENT #include #include diff --git a/src/DataPath.hpp b/src/DataPath.hpp index afac45b..017bcdc 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -4,7 +4,7 @@ #include #include "defines.hpp" -#include "Topology.hpp" +#include "Component.hpp" //Component pointing to a DataPath #define SYS_SAGE_DATAPATH_NONE 1 /**< Reserved for development purposes. */ diff --git a/src/cpuinfo.cpp b/src/cpuinfo.cpp index 95f0dbb..c47bf1f 100644 --- a/src/cpuinfo.cpp +++ b/src/cpuinfo.cpp @@ -14,7 +14,7 @@ #include #include -#include "Topology.hpp" +#include "Component.hpp" //retrieve frequency in MHz from /proc/cpuinfo for each thread in vector threads //helper function is called by RefreshCpuCoreFrequency/RefreshFreq methods diff --git a/src/nvidia_mig.cpp b/src/nvidia_mig.cpp index 52c93db..74f9eaf 100644 --- a/src/nvidia_mig.cpp +++ b/src/nvidia_mig.cpp @@ -11,7 +11,7 @@ #include -#include "Topology.hpp" +#include "Component.hpp" //nvmlReturn_t nvmlDeviceGetMigDeviceHandleByIndex ( nvmlDevice_t device, unsigned int index, nvmlDevice_t* migDevice ) --> look for all mig devices and add/update them diff --git a/src/parsers/caps-numa-benchmark.hpp b/src/parsers/caps-numa-benchmark.hpp index 0e3dafb..ee3795e 100644 --- a/src/parsers/caps-numa-benchmark.hpp +++ b/src/parsers/caps-numa-benchmark.hpp @@ -1,7 +1,7 @@ #ifndef CAPS_NUMA_BENCHMARK #define CAPS_NUMA_BENCHMARK -#include "Topology.hpp" +#include "Component.hpp" #include "DataPath.hpp" int parseCapsNumaBenchmark(Component* rootComponent, string benchmarkPath, string delim = ";"); diff --git a/src/parsers/cccbench.hpp b/src/parsers/cccbench.hpp index e8d188e..133d910 100644 --- a/src/parsers/cccbench.hpp +++ b/src/parsers/cccbench.hpp @@ -2,7 +2,7 @@ #define CCCBENCH_PARSER #include -#include "Topology.hpp" +#include "Component.hpp" #include "DataPath.hpp" int parseCccbenchOutput(Node* , std::string ); diff --git a/src/parsers/hwloc.hpp b/src/parsers/hwloc.hpp index 70f7038..2fc4f7c 100644 --- a/src/parsers/hwloc.hpp +++ b/src/parsers/hwloc.hpp @@ -7,7 +7,7 @@ #include #include -#include "Topology.hpp" +#include "Component.hpp" /*! \file */ diff --git a/src/parsers/mt4g.hpp b/src/parsers/mt4g.hpp index 611c224..8ccb13b 100644 --- a/src/parsers/mt4g.hpp +++ b/src/parsers/mt4g.hpp @@ -1,7 +1,7 @@ #ifndef MT4G_PARSER #define MT4G_PARSER -#include "Topology.hpp" +#include "Component.hpp" #include "DataPath.hpp" /*! \file */ diff --git a/src/sys-sage.hpp b/src/sys-sage.hpp index d11ad74..cf7a1c2 100644 --- a/src/sys-sage.hpp +++ b/src/sys-sage.hpp @@ -2,7 +2,7 @@ #define SYS_SAGE //includes all other headers -#include "Topology.hpp" +#include "Component.hpp" #include "DataPath.hpp" #include "xml_dump.hpp" #include "parsers/hwloc.hpp" diff --git a/src/xml_dump.hpp b/src/xml_dump.hpp index 202817e..eb8bb2c 100644 --- a/src/xml_dump.hpp +++ b/src/xml_dump.hpp @@ -3,7 +3,7 @@ #include -#include "Topology.hpp" +#include "Component.hpp" #include "DataPath.hpp" int exportToXml(Component *root, string path = "", std::function search_custom_attrib_key_fcn = NULL, std::function search_custom_complex_attrib_key_fcn = NULL); From b7c5bb73f62fb1e4f229f66aa8a29e734815bd2a Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 3 Jul 2024 20:40:45 +0200 Subject: [PATCH 17/47] Renamed CAT_aware ->intel_pqos --- CMakeLists.txt | 2 +- README.md | 2 +- docs/Installation_Guide.md | 2 +- examples/CMakeLists.txt | 2 +- examples/matmul.cpp | 4 ++-- src/CMakeLists.txt | 2 +- src/Component.hpp | 8 ++++---- src/defines.hpp.in | 2 +- src/{CAT_aware.cpp => intel_pqos.cpp} | 10 +++++----- 9 files changed, 17 insertions(+), 17 deletions(-) rename src/{CAT_aware.cpp => intel_pqos.cpp} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c6495f..e93027c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ install(FILES ${sys-sage_BINARY_DIR}/pkg/sys-sage.pc ###Options: -option(CAT_AWARE "Build and install functionality regarding Intel L3 CAT" OFF) +option(INTEL_PQOS "Build and install functionality regarding Intel L3 CAT" OFF) option(NVIDIA_MIG "Build and install functionality regarding NVidia MIG(multi-instance GPU, ampere or newer)" OFF) option(CPUINFO "Build and install functionality regarding Linux cpuinfo" OFF) option(DATA_SOURCES "Build and install all data sources" OFF) diff --git a/README.md b/README.md index d93c466..3580acf 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ cd sys-sage mkdir build && cd build cmake .. # build options: -# -DCAT_AWARE=ON - builds with Intel CAT functionality. For that, Intel-specific pqos header/library are necessary. +# -DINTEL_PQOS=ON - builds with Intel CAT functionality. For that, Intel-specific pqos header/library are necessary. # -DNVIDIA_MIG=ON - Build and install functionality regarding NVidia MIG(multi-instance GPU, ampere or newer). # -DCPUINFO=ON - Build and install functionality regarding Linux cpuinfo (only x86) -- default ON. # -DDATA_SOURCES=ON - builds all data sources from folder 'data-sources' listed below. Data sources are used to collecting HW-related information, so it only makes sense to compile that on the system where the topology information is queried. diff --git a/docs/Installation_Guide.md b/docs/Installation_Guide.md index 6a75eeb..61414fc 100644 --- a/docs/Installation_Guide.md +++ b/docs/Installation_Guide.md @@ -23,7 +23,7 @@ Installation with CMAKE: mkdir build && cd build cmake .. # build options: -# -DCAT_AWARE=ON - builds with Intel CAT functionality. For that, Intel-specific pqos header/library are necessary. +# -DINTEL_PQOS=ON - builds with Intel CAT functionality. For that, Intel-specific pqos header/library are necessary. # -DBUILD_DATA_SOURCES=ON - builds data sources from folder 'data-sources'. If turned on, includes Linux-specific libraries and hwloc. Data sources are used to collecting HW-related information, so it only makes sense to compile that on the system where the topology information is queried. # -DCMAKE_INSTALL_PREFIX=../inst-dir - to install locally into the git repo folder make all install diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9449df7..75b29bf 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,7 +20,7 @@ add_executable(cccbenchplushwloc cccbenchplushwloc.cpp) install(TARGETS basic_usage mt4g-parser custom_attributes larger_topo sys-sage-benchmarking use_custom_parser cccbenchplushwloc DESTINATION bin/examples) install(DIRECTORY example_data DESTINATION bin/examples) -if(CAT_AWARE) +if(INTEL_PQOS) add_executable(matmul matmul.cpp) set_source_files_properties(matmul.cpp PROPERTIES COMPILE_FLAGS -O3) target_link_libraries(matmul hwloc pqos ) diff --git a/examples/matmul.cpp b/examples/matmul.cpp index afce5a0..b8c7dc5 100644 --- a/examples/matmul.cpp +++ b/examples/matmul.cpp @@ -15,7 +15,7 @@ #include //intel cat -#ifdef CAT_AWARE +#ifdef INTEL_PQOS #include #endif @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) { } //////////////////////////////////// whole L3 size -#ifndef CAT_AWARE +#ifndef INTEL_PQOS Component * c = (Component*)t; while(c->GetParent() != NULL){ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 478367e..a2126b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ configure_file(${PROJECT_SOURCE_DIR}/src/defines.hpp.in ${PROJECT_SOURCE_DIR}/sr set(SOURCES Component.cpp DataPath.cpp - CAT_aware.cpp + intel_pqos.cpp cpuinfo.cpp nvidia_mig.cpp xml_dump.cpp diff --git a/src/Component.hpp b/src/Component.hpp index 4cca5b3..a4c4bcd 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -567,10 +567,10 @@ class Node : public Component { public: int RefreshCpuCoreFrequency(bool keep_history = false); #endif -#ifdef CAT_AWARE //defined in CAT_aware.cpp +#ifdef INTEL_PQOS //defined in intel_pqos.cpp public: /** - !!! Only if compiled with CAT_AWARE functionality, only for Intel CPUs !!! + !!! Only if compiled with INTEL_PQOS functionality, only for Intel CPUs !!! \n Creates/updates (bidirectional) data paths between all cores (class Thread) and their L3 cache segment (class Cache). The data paths of type SYS_SAGE_DATAPATH_TYPE_L3CAT contain the COS id (attrib with key "CATcos", value is of type uint64_t*) and the open L3 cache ways (attrib with key "CATL3mask", value is of type uint64_t*) to contain the current settings. \n Each time the method is called, new DataPath objects get created, so the last one is always the most up-to-date. */ @@ -1064,10 +1064,10 @@ class Thread : public Component { double GetFreq(); #endif -#ifdef CAT_AWARE //defined in CAT_aware.cpp +#ifdef INTEL_PQOS //defined in intel_pqos.cpp public: /** - !!! Only if compiled with CAT_AWARE functionality, only for Intel CPUs !!! + !!! Only if compiled with INTEL_PQOS functionality, only for Intel CPUs !!! \n Retrieves the L3 cache size available to this thread. This size is retrieved based on the last update with UpdateL3CATCoreCOS() -- i.e. you should call that method before. @returns Available L3 cache size in bytes. @see int UpdateL3CATCoreCOS(); diff --git a/src/defines.hpp.in b/src/defines.hpp.in index cc12d1f..feeaa67 100644 --- a/src/defines.hpp.in +++ b/src/defines.hpp.in @@ -3,7 +3,7 @@ //add cmake-style define, so that when headers are included as an external library, the options/defines used during compilation will be reflected also in the headers #cmakedefine CPUINFO //in cmake, add -DCPUINFO=OFF to turn off (default on) -#cmakedefine CAT_AWARE //in cmake, add -DCAT_AWARE=ON to turn on +#cmakedefine INTEL_PQOS //in cmake, add -DINTEL_PQOS=ON to turn on #cmakedefine NVIDIA_MIG //in cmake, add -DNVIDIA_MIG=ON to turn on #endif \ No newline at end of file diff --git a/src/CAT_aware.cpp b/src/intel_pqos.cpp similarity index 98% rename from src/CAT_aware.cpp rename to src/intel_pqos.cpp index b4726d6..dd9c3e5 100644 --- a/src/CAT_aware.cpp +++ b/src/intel_pqos.cpp @@ -1,8 +1,8 @@ -#ifndef CAT_AWARE_CPP -#define CAT_AWARE_CPP +#ifndef INTEL_PQOS_CPP +#define INTEL_PQOS_CPP #include "defines.hpp" -#ifdef CAT_AWARE +#ifdef INTEL_PQOS //code written based on https://github.com/intel/intel-cmt-cat/blob/master/examples/c/CAT_MBA/allocation_app_l3cat.c #include @@ -195,5 +195,5 @@ long long Thread::GetCATAwareL3Size() return -1; } -#endif //CAT_AWARE -#endif //CAT_AWARE_CPP +#endif //INTEL_PQOS +#endif //INTEL_PQOS_CPP From bd3baffe00353b9e03116bf7bbb3c611042d86c9 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 3 Jul 2024 20:54:24 +0200 Subject: [PATCH 18/47] Renamed src/cpuinfo.cpp -> src/proc_cpuinfo.cpp --- CMakeLists.txt | 2 +- README.md | 2 +- examples/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- src/Component.hpp | 6 +++--- src/defines.hpp.in | 2 +- src/{cpuinfo.cpp => proc_cpuinfo.cpp} | 10 +++++----- test/CMakeLists.txt | 2 +- test/{cpuinfo.cpp => proc_cpuinfo.cpp} | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) rename src/{cpuinfo.cpp => proc_cpuinfo.cpp} (97%) rename test/{cpuinfo.cpp => proc_cpuinfo.cpp} (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e93027c..9ab1464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ install(FILES ${sys-sage_BINARY_DIR}/pkg/sys-sage.pc ###Options: option(INTEL_PQOS "Build and install functionality regarding Intel L3 CAT" OFF) option(NVIDIA_MIG "Build and install functionality regarding NVidia MIG(multi-instance GPU, ampere or newer)" OFF) -option(CPUINFO "Build and install functionality regarding Linux cpuinfo" OFF) +option(PROC_CPUINFO "Build and install functionality regarding Linux cpuinfo" OFF) option(DATA_SOURCES "Build and install all data sources" OFF) option(DS_HWLOC "Build and install data source hwloc (Retrieves hwloc topology information)" OFF) option(DS_MT4G "Build and install data source mt4g (Compute and memory topology of NVidia GPUs)" OFF) diff --git a/README.md b/README.md index 3580acf..153c442 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ cmake .. # build options: # -DINTEL_PQOS=ON - builds with Intel CAT functionality. For that, Intel-specific pqos header/library are necessary. # -DNVIDIA_MIG=ON - Build and install functionality regarding NVidia MIG(multi-instance GPU, ampere or newer). -# -DCPUINFO=ON - Build and install functionality regarding Linux cpuinfo (only x86) -- default ON. +# -DPROC_CPUINFO=ON - Build and install functionality regarding Linux cpuinfo (only x86) -- default ON. # -DDATA_SOURCES=ON - builds all data sources from folder 'data-sources' listed below. Data sources are used to collecting HW-related information, so it only makes sense to compile that on the system where the topology information is queried. # -DDS_HWLOC=ON - builds the hwloc data source for retrieving the CPU topology # -DDS_MT4g=ON - builds the mt4g data source for retrieving GPU compute and memory topology. If turned on, includes hwloc. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 75b29bf..30652c1 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -27,7 +27,7 @@ if(INTEL_PQOS) install(TARGETS matmul DESTINATION bin/examples) endif() -if(CPUINFO) +if(PROC_CPUINFO) add_executable(cpu-frequency cpu-frequency.cpp) install(TARGETS cpu-frequency DESTINATION bin/examples) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2126b5..6b94a1e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ set(SOURCES Component.cpp DataPath.cpp intel_pqos.cpp - cpuinfo.cpp + proc_cpuinfo.cpp nvidia_mig.cpp xml_dump.cpp parsers/hwloc.cpp diff --git a/src/Component.hpp b/src/Component.hpp index a4c4bcd..99038e2 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -563,7 +563,7 @@ class Node : public Component { * Use Delete() or DeleteSubtree() for deleting and deallocating the components. */ ~Node() override = default; -#ifdef CPUINFO +#ifdef PROC_CPUINFO public: int RefreshCpuCoreFrequency(bool keep_history = false); #endif @@ -1021,7 +1021,7 @@ class Core : public Component { ~Core() override = default; private: -#ifdef CPUINFO +#ifdef PROC_CPUINFO public: int RefreshFreq(bool keep_history = false); void SetFreq(double _freq); @@ -1058,7 +1058,7 @@ class Thread : public Component { */ ~Thread() override = default; -#ifdef CPUINFO //defined in cpuinfo.cpp +#ifdef PROC_CPUINFO //defined in proc_cpuinfo.cpp public: int RefreshFreq(bool keep_history = false); double GetFreq(); diff --git a/src/defines.hpp.in b/src/defines.hpp.in index feeaa67..c98d983 100644 --- a/src/defines.hpp.in +++ b/src/defines.hpp.in @@ -2,7 +2,7 @@ #define DEFINES //add cmake-style define, so that when headers are included as an external library, the options/defines used during compilation will be reflected also in the headers -#cmakedefine CPUINFO //in cmake, add -DCPUINFO=OFF to turn off (default on) +#cmakedefine PROC_CPUINFO //in cmake, add -DPROC_CPUINFO=OFF to turn off (default on) #cmakedefine INTEL_PQOS //in cmake, add -DINTEL_PQOS=ON to turn on #cmakedefine NVIDIA_MIG //in cmake, add -DNVIDIA_MIG=ON to turn on diff --git a/src/cpuinfo.cpp b/src/proc_cpuinfo.cpp similarity index 97% rename from src/cpuinfo.cpp rename to src/proc_cpuinfo.cpp index c47bf1f..a16ef0c 100644 --- a/src/cpuinfo.cpp +++ b/src/proc_cpuinfo.cpp @@ -1,8 +1,8 @@ -#ifndef CPUINFO_CPP -#define CPUINFO_CPP +#ifndef PROC_CPUINFO_CPP +#define PROC_CPUINFO_CPP #include "defines.hpp" -#ifdef CPUINFO +#ifdef PROC_CPUINFO #include #include @@ -152,5 +152,5 @@ double Thread::GetFreq() return c->GetFreq(); } -#endif //CPUINFO -#endif //CPUINFO_CPP +#endif //PROC_CPUINFO +#endif //PROC_CPUINFO_CPP diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 495132f..aa4412f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ include_directories(../src) # The include path is not set in the sys-sage target because CMAKE_INCLUDE_CURRENT_DIR is used instead add_subdirectory(ut) -add_executable(test test.cpp topology.cpp datapath.cpp hwloc.cpp mt4g.cpp caps-numa-benchmark.cpp cpuinfo.cpp export.cpp) +add_executable(test test.cpp topology.cpp datapath.cpp hwloc.cpp mt4g.cpp caps-numa-benchmark.cpp proc_cpuinfo.cpp export.cpp) target_link_libraries(test PRIVATE ut sys-sage) target_compile_definitions(test PRIVATE SYS_SAGE_TEST_RESOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources") diff --git a/test/cpuinfo.cpp b/test/proc_cpuinfo.cpp similarity index 94% rename from test/cpuinfo.cpp rename to test/proc_cpuinfo.cpp index 1cd9b22..7014d9b 100644 --- a/test/cpuinfo.cpp +++ b/test/proc_cpuinfo.cpp @@ -4,7 +4,7 @@ using namespace boost::ut; -#if CPUINFO +#if PROC_CPUINFO static suite<"cpuinfo"> _ = [] { From 59723423b0da5fc836fca6299ace23381a8d77ba Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 12 Jul 2024 18:19:16 +0200 Subject: [PATCH 19/47] Added external interfaces --- examples/CMakeLists.txt | 1 + {src => external_interfaces}/intel_pqos.cpp | 0 {src => external_interfaces}/nvidia_mig.cpp | 0 .../parsers/caps-numa-benchmark.cpp | 0 .../parsers/caps-numa-benchmark.hpp | 0 .../parsers/cccbench.cpp | 0 .../parsers/cccbench.hpp | 0 .../parsers/hwloc.cpp | 0 .../parsers/hwloc.hpp | 0 {src => external_interfaces}/parsers/mt4g.cpp | 0 {src => external_interfaces}/parsers/mt4g.hpp | 0 {src => external_interfaces}/proc_cpuinfo.cpp | 0 src/CMakeLists.txt | 25 +++++++++++-------- 13 files changed, 15 insertions(+), 11 deletions(-) rename {src => external_interfaces}/intel_pqos.cpp (100%) rename {src => external_interfaces}/nvidia_mig.cpp (100%) rename {src => external_interfaces}/parsers/caps-numa-benchmark.cpp (100%) rename {src => external_interfaces}/parsers/caps-numa-benchmark.hpp (100%) rename {src => external_interfaces}/parsers/cccbench.cpp (100%) rename {src => external_interfaces}/parsers/cccbench.hpp (100%) rename {src => external_interfaces}/parsers/hwloc.cpp (100%) rename {src => external_interfaces}/parsers/hwloc.hpp (100%) rename {src => external_interfaces}/parsers/mt4g.cpp (100%) rename {src => external_interfaces}/parsers/mt4g.hpp (100%) rename {src => external_interfaces}/proc_cpuinfo.cpp (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 30652c1..1bccd04 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,7 @@ link_libraries(sys-sage sys-sage) include_directories(../src) +include_directories(../external_interfaces) find_package(OpenMP) if (OPENMP_FOUND) diff --git a/src/intel_pqos.cpp b/external_interfaces/intel_pqos.cpp similarity index 100% rename from src/intel_pqos.cpp rename to external_interfaces/intel_pqos.cpp diff --git a/src/nvidia_mig.cpp b/external_interfaces/nvidia_mig.cpp similarity index 100% rename from src/nvidia_mig.cpp rename to external_interfaces/nvidia_mig.cpp diff --git a/src/parsers/caps-numa-benchmark.cpp b/external_interfaces/parsers/caps-numa-benchmark.cpp similarity index 100% rename from src/parsers/caps-numa-benchmark.cpp rename to external_interfaces/parsers/caps-numa-benchmark.cpp diff --git a/src/parsers/caps-numa-benchmark.hpp b/external_interfaces/parsers/caps-numa-benchmark.hpp similarity index 100% rename from src/parsers/caps-numa-benchmark.hpp rename to external_interfaces/parsers/caps-numa-benchmark.hpp diff --git a/src/parsers/cccbench.cpp b/external_interfaces/parsers/cccbench.cpp similarity index 100% rename from src/parsers/cccbench.cpp rename to external_interfaces/parsers/cccbench.cpp diff --git a/src/parsers/cccbench.hpp b/external_interfaces/parsers/cccbench.hpp similarity index 100% rename from src/parsers/cccbench.hpp rename to external_interfaces/parsers/cccbench.hpp diff --git a/src/parsers/hwloc.cpp b/external_interfaces/parsers/hwloc.cpp similarity index 100% rename from src/parsers/hwloc.cpp rename to external_interfaces/parsers/hwloc.cpp diff --git a/src/parsers/hwloc.hpp b/external_interfaces/parsers/hwloc.hpp similarity index 100% rename from src/parsers/hwloc.hpp rename to external_interfaces/parsers/hwloc.hpp diff --git a/src/parsers/mt4g.cpp b/external_interfaces/parsers/mt4g.cpp similarity index 100% rename from src/parsers/mt4g.cpp rename to external_interfaces/parsers/mt4g.cpp diff --git a/src/parsers/mt4g.hpp b/external_interfaces/parsers/mt4g.hpp similarity index 100% rename from src/parsers/mt4g.hpp rename to external_interfaces/parsers/mt4g.hpp diff --git a/src/proc_cpuinfo.cpp b/external_interfaces/proc_cpuinfo.cpp similarity index 100% rename from src/proc_cpuinfo.cpp rename to external_interfaces/proc_cpuinfo.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b94a1e..9ec0bf9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,17 +3,20 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) #defines.hpp header with #cmakedefine configure_file(${PROJECT_SOURCE_DIR}/src/defines.hpp.in ${PROJECT_SOURCE_DIR}/src/defines.hpp) +include_directories(../external_interfaces) +set(EXT_INTF "../external_interfaces") + set(SOURCES Component.cpp DataPath.cpp - intel_pqos.cpp - proc_cpuinfo.cpp - nvidia_mig.cpp xml_dump.cpp - parsers/hwloc.cpp - parsers/caps-numa-benchmark.cpp - parsers/mt4g.cpp - parsers/cccbench.cpp + ${EXT_INTF}/intel_pqos.cpp + ${EXT_INTF}/proc_cpuinfo.cpp + ${EXT_INTF}/nvidia_mig.cpp + ${EXT_INTF}/parsers/hwloc.cpp + ${EXT_INTF}/parsers/caps-numa-benchmark.cpp + ${EXT_INTF}/parsers/mt4g.cpp + ${EXT_INTF}/parsers/cccbench.cpp ) set(HEADERS @@ -22,10 +25,10 @@ set(HEADERS Component.hpp DataPath.hpp xml_dump.hpp - parsers/hwloc.hpp - parsers/caps-numa-benchmark.hpp - parsers/mt4g.hpp - parsers/cccbench.cpp + ${EXT_INTF}/parsers/hwloc.hpp + ${EXT_INTF}/parsers/caps-numa-benchmark.hpp + ${EXT_INTF}/parsers/mt4g.hpp + ${EXT_INTF}/parsers/cccbench.cpp ) add_library(sys-sage SHARED ${SOURCES} ${HEADERS}) From 6afca02737a0977a551aea69f94a6c73316ea15a Mon Sep 17 00:00:00 2001 From: Durganshu Date: Tue, 23 Jul 2024 11:18:56 +0200 Subject: [PATCH 20/47] Updated the documentation of attrib --- src/DataPath.hpp | 75 ++++++++++++++++++++++++++++++++++++++++++++-- src/Topology.hpp | 77 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 145 insertions(+), 7 deletions(-) diff --git a/src/DataPath.hpp b/src/DataPath.hpp index afac45b..887e131 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -159,10 +159,79 @@ class DataPath { void DeleteDataPath(); /** - For storing arbitrary pieces of information or data. key denotes the name of the attribute, - and the value points to the data. + * A map for storing arbitrary pieces of information or data. + * - The `key` denotes the name of the attribute. + * - The `value` points to the data, stored as a `void*`. + * + * This data structure is designed to store a wide variety of data types by + * utilizing pointers to void. Due to its flexibility, it is essential to manage + * the types and memory allocation/deallocation carefully to avoid issues such + * as memory leaks or undefined behavior. + * + * Usage: + * + * 1. Adding a new key-value pair: + * + * ```cpp + * std::string key = "exampleKey"; + * int* value = new int(42); // Dynamically allocate memory for the value + * attrib[key] = static_cast(value); // Store the value in the map + * ``` + * + * 2. Retrieving data from an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* retrievedValue = static_cast(attrib[key]); + * std::cout << "Value: " << *retrievedValue << std::endl; + * } else { + * std::cout << "Key not found." << std::endl; + * } + * ``` + * + * 3. Checking for the existence of a key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * std::cout << "Key exists." << std::endl; + * } else { + * std::cout << "Key does not exist." << std::endl; + * } + * ``` + * + * 4. Removing a key-value pair and freeing memory: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* value = static_cast(attrib[key]); + * delete value; // Free the dynamically allocated memory + * attrib.erase(key); // Remove the key-value pair from the map + * } + * ``` + * + * 5. Updating the value for an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* oldValue = static_cast(attrib[key]); + * delete oldValue; // Free the old value + * int* newValue = new int(100); // Allocate new value + * attrib[key] = static_cast(newValue); // Update the map + * } + * ``` + * + * Note: + * - Proper memory management is crucial when using `void*` pointers. Always ensure + * that dynamically allocated memory is freed when no longer needed. + * - Type safety is not enforced, so it is important to cast pointers to the correct + * type when retrieving values from the map. */ - map attrib; + std::map attrib; + private: Component * source; /**< source component of the datapath */ Component * target; /**< taget component of the datapath */ diff --git a/src/Topology.hpp b/src/Topology.hpp index d1b89a7..2aaba48 100644 --- a/src/Topology.hpp +++ b/src/Topology.hpp @@ -482,10 +482,79 @@ class Component { void Delete(bool withSubtree = true); /** - For storing arbitrary pieces of information or data. key denotes the name of the attribute, - and the value points to the data. - */ - map attrib; + * A map for storing arbitrary pieces of information or data. + * - The `key` denotes the name of the attribute. + * - The `value` points to the data, stored as a `void*`. + * + * This data structure is designed to store a wide variety of data types by + * utilizing pointers to void. Due to its flexibility, it is essential to manage + * the types and memory allocation/deallocation carefully to avoid issues such + * as memory leaks or undefined behavior. + * + * Usage: + * + * 1. Adding a new key-value pair: + * + * ```cpp + * std::string key = "exampleKey"; + * int* value = new int(42); // Dynamically allocate memory for the value + * attrib[key] = static_cast(value); // Store the value in the map + * ``` + * + * 2. Retrieving data from an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* retrievedValue = static_cast(attrib[key]); + * std::cout << "Value: " << *retrievedValue << std::endl; + * } else { + * std::cout << "Key not found." << std::endl; + * } + * ``` + * + * 3. Checking for the existence of a key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * std::cout << "Key exists." << std::endl; + * } else { + * std::cout << "Key does not exist." << std::endl; + * } + * ``` + * + * 4. Removing a key-value pair and freeing memory: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* value = static_cast(attrib[key]); + * delete value; // Free the dynamically allocated memory + * attrib.erase(key); // Remove the key-value pair from the map + * } + * ``` + * + * 5. Updating the value for an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* oldValue = static_cast(attrib[key]); + * delete oldValue; // Free the old value + * int* newValue = new int(100); // Allocate new value + * attrib[key] = static_cast(newValue); // Update the map + * } + * ``` + * + * Note: + * - Proper memory management is crucial when using `void*` pointers. Always ensure + * that dynamically allocated memory is freed when no longer needed. + * - Type safety is not enforced, so it is important to cast pointers to the correct + * type when retrieving values from the map. + */ + std::map attrib; + protected: int id; /**< Numeric ID of the component. There is no requirement for uniqueness of the ID, however it is advised to have unique IDs at least in the realm of parent's children. Some tree search functions, which take the id as a search parameter search for first match, so the user is responsible to manage uniqueness in the realm of the search subtree (or should be aware of the consequences of not doing so). Component's ID is set by the constructor, and is retrieved via int GetId(); */ From 48da76652fabc01d79b00c315ee1723161b4bfd7 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Tue, 23 Jul 2024 12:33:36 +0200 Subject: [PATCH 21/47] Documentation enabled for pre-processor directives --- docs/Doxyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 2624af1..b86e7d3 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -2286,7 +2286,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = NVIDIA_MIG CPUINFO CAT_AWARE # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The From 0bfdaf6dd8c6dd02704aa99f5d9583256d6b9be8 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 25 Jul 2024 11:45:52 +0200 Subject: [PATCH 22/47] Documentation update --- docs/Doxyfile | 2 +- src/Component.hpp | 75 +++++++++++++++++++++++++++++++++++++++++++++-- src/DataPath.hpp | 72 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 143 insertions(+), 6 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 2624af1..ca8b5af 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -2286,7 +2286,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = NVIDIA_MIG PROC_CPUINFO INTEL_PQOS # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/src/Component.hpp b/src/Component.hpp index 99038e2..25a7ceb 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -482,8 +482,76 @@ class Component { void Delete(bool withSubtree = true); /** - For storing arbitrary pieces of information or data. key denotes the name of the attribute, - and the value points to the data. + * A map for storing arbitrary pieces of information or data. + * - The `key` denotes the name of the attribute. + * - The `value` points to the data, stored as a `void*`. + * + * This data structure is designed to store a wide variety of data types by + * utilizing pointers to void. Due to its flexibility, it is essential to manage + * the types and memory allocation/deallocation carefully to avoid issues such + * as memory leaks or undefined behavior. + * + * Usage: + * + * 1. Adding a new key-value pair: + * + * ```cpp + * std::string key = "exampleKey"; + * int* value = new int(42); // Dynamically allocate memory for the value + * attrib[key] = static_cast(value); // Store the value in the map + * ``` + * + * 2. Retrieving data from an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* retrievedValue = static_cast(attrib[key]); + * std::cout << "Value: " << *retrievedValue << std::endl; + * } else { + * std::cout << "Key not found." << std::endl; + * } + * ``` + * + * 3. Checking for the existence of a key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * std::cout << "Key exists." << std::endl; + * } else { + * std::cout << "Key does not exist." << std::endl; + * } + * ``` + * + * 4. Removing a key-value pair and freeing memory: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* value = static_cast(attrib[key]); + * delete value; // Free the dynamically allocated memory + * attrib.erase(key); // Remove the key-value pair from the map + * } + * ``` + * + * 5. Updating the value for an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* oldValue = static_cast(attrib[key]); + * delete oldValue; // Free the old value + * int* newValue = new int(100); // Allocate new value + * attrib[key] = static_cast(newValue); // Update the map + * } + * ``` + * + * Note: + * - Proper memory management is crucial when using `void*` pointers. Always ensure + * that dynamically allocated memory is freed when no longer needed. + * - Type safety is not enforced, so it is important to cast pointers to the correct + * type when retrieving values from the map. */ map attrib; protected: @@ -570,9 +638,10 @@ class Node : public Component { #ifdef INTEL_PQOS //defined in intel_pqos.cpp public: /** - !!! Only if compiled with INTEL_PQOS functionality, only for Intel CPUs !!! \n Creates/updates (bidirectional) data paths between all cores (class Thread) and their L3 cache segment (class Cache). The data paths of type SYS_SAGE_DATAPATH_TYPE_L3CAT contain the COS id (attrib with key "CATcos", value is of type uint64_t*) and the open L3 cache ways (attrib with key "CATL3mask", value is of type uint64_t*) to contain the current settings. \n Each time the method is called, new DataPath objects get created, so the last one is always the most up-to-date. + + Note: This function is defined only when sys-sage is compiled with INTEL_PQOS functionality (only for Intel CPUs). */ int UpdateL3CATCoreCOS(); #endif diff --git a/src/DataPath.hpp b/src/DataPath.hpp index 017bcdc..f3c2755 100644 --- a/src/DataPath.hpp +++ b/src/DataPath.hpp @@ -159,8 +159,76 @@ class DataPath { void DeleteDataPath(); /** - For storing arbitrary pieces of information or data. key denotes the name of the attribute, - and the value points to the data. + * A map for storing arbitrary pieces of information or data. + * - The `key` denotes the name of the attribute. + * - The `value` points to the data, stored as a `void*`. + * + * This data structure is designed to store a wide variety of data types by + * utilizing pointers to void. Due to its flexibility, it is essential to manage + * the types and memory allocation/deallocation carefully to avoid issues such + * as memory leaks or undefined behavior. + * + * Usage: + * + * 1. Adding a new key-value pair: + * + * ```cpp + * std::string key = "exampleKey"; + * int* value = new int(42); // Dynamically allocate memory for the value + * attrib[key] = static_cast(value); // Store the value in the map + * ``` + * + * 2. Retrieving data from an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* retrievedValue = static_cast(attrib[key]); + * std::cout << "Value: " << *retrievedValue << std::endl; + * } else { + * std::cout << "Key not found." << std::endl; + * } + * ``` + * + * 3. Checking for the existence of a key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * std::cout << "Key exists." << std::endl; + * } else { + * std::cout << "Key does not exist." << std::endl; + * } + * ``` + * + * 4. Removing a key-value pair and freeing memory: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* value = static_cast(attrib[key]); + * delete value; // Free the dynamically allocated memory + * attrib.erase(key); // Remove the key-value pair from the map + * } + * ``` + * + * 5. Updating the value for an existing key: + * + * ```cpp + * std::string key = "exampleKey"; + * if (attrib.find(key) != attrib.end()) { + * int* oldValue = static_cast(attrib[key]); + * delete oldValue; // Free the old value + * int* newValue = new int(100); // Allocate new value + * attrib[key] = static_cast(newValue); // Update the map + * } + * ``` + * + * Note: + * - Proper memory management is crucial when using `void*` pointers. Always ensure + * that dynamically allocated memory is freed when no longer needed. + * - Type safety is not enforced, so it is important to cast pointers to the correct + * type when retrieving values from the map. */ map attrib; private: From 0c6686ca048f4fa8551e62abe7c22303e66b5797 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 25 Jul 2024 11:55:18 +0200 Subject: [PATCH 23/47] Minor debug --- test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa4412f..d6cd0b8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,5 @@ include_directories(../src) # The include path is not set in the sys-sage target because CMAKE_INCLUDE_CURRENT_DIR is used instead +include_directories(../external_interfaces) add_subdirectory(ut) add_executable(test test.cpp topology.cpp datapath.cpp hwloc.cpp mt4g.cpp caps-numa-benchmark.cpp proc_cpuinfo.cpp export.cpp) From 1bbb64ab887a97b0451fa547fe1dc24dafc68625 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 25 Jul 2024 12:03:49 +0200 Subject: [PATCH 24/47] Debug in topologytest --- src/Component.cpp | 2 +- test/topology.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Component.cpp b/src/Component.cpp index ef6ed09..4b4296e 100644 --- a/src/Component.cpp +++ b/src/Component.cpp @@ -456,7 +456,7 @@ int Component::CheckComponentTreeConsistency() int errors = 0; for(Component * child : children){ if(child->GetParent() != this){ - std::cerr << "Component " << child->GetComponentType() << " id " << child->GetName() << "has wrong parent" << std::endl; + std::cerr << "Component " << child->GetComponentType() << " id " << child->GetName() << " has wrong parent" << std::endl; errors++; } } diff --git a/test/topology.cpp b/test/topology.cpp index 3871232..24e7a14 100644 --- a/test/topology.cpp +++ b/test/topology.cpp @@ -274,7 +274,7 @@ static suite<"topology"> _ = [] d.InsertChild(&e); d.InsertChild(&f); - expect(that % 3 == a.GetNumThreads()); + expect(that % 3 == a.CountAllSubcomponentsByType(SYS_SAGE_COMPONENT_THREAD)); }; "Linearize subtree"_test = [] From a40aeeda53585f3fb13ee128ab192b57d9526a4d Mon Sep 17 00:00:00 2001 From: Durganshu Date: Sat, 7 Sep 2024 17:25:48 +0200 Subject: [PATCH 25/47] Moved external_interfaces within src --- examples/CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 ++-- .../external_interfaces}/intel_pqos.cpp | 0 .../external_interfaces}/nvidia_mig.cpp | 0 .../external_interfaces}/parsers/caps-numa-benchmark.cpp | 0 .../external_interfaces}/parsers/caps-numa-benchmark.hpp | 0 .../external_interfaces}/parsers/cccbench.cpp | 0 .../external_interfaces}/parsers/cccbench.hpp | 0 .../external_interfaces}/parsers/hwloc.cpp | 0 .../external_interfaces}/parsers/hwloc.hpp | 0 .../external_interfaces}/parsers/mt4g.cpp | 0 .../external_interfaces}/parsers/mt4g.hpp | 0 .../external_interfaces}/proc_cpuinfo.cpp | 0 src/sys-sage.hpp | 8 ++++---- 14 files changed, 7 insertions(+), 7 deletions(-) rename {external_interfaces => src/external_interfaces}/intel_pqos.cpp (100%) rename {external_interfaces => src/external_interfaces}/nvidia_mig.cpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/caps-numa-benchmark.cpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/caps-numa-benchmark.hpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/cccbench.cpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/cccbench.hpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/hwloc.cpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/hwloc.hpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/mt4g.cpp (100%) rename {external_interfaces => src/external_interfaces}/parsers/mt4g.hpp (100%) rename {external_interfaces => src/external_interfaces}/proc_cpuinfo.cpp (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1bccd04..e095a55 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ link_libraries(sys-sage sys-sage) include_directories(../src) -include_directories(../external_interfaces) +include_directories(../src/external_interfaces) find_package(OpenMP) if (OPENMP_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ec0bf9..3fa1724 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,8 +3,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) #defines.hpp header with #cmakedefine configure_file(${PROJECT_SOURCE_DIR}/src/defines.hpp.in ${PROJECT_SOURCE_DIR}/src/defines.hpp) -include_directories(../external_interfaces) -set(EXT_INTF "../external_interfaces") +include_directories(external_interfaces) +set(EXT_INTF "external_interfaces") set(SOURCES Component.cpp diff --git a/external_interfaces/intel_pqos.cpp b/src/external_interfaces/intel_pqos.cpp similarity index 100% rename from external_interfaces/intel_pqos.cpp rename to src/external_interfaces/intel_pqos.cpp diff --git a/external_interfaces/nvidia_mig.cpp b/src/external_interfaces/nvidia_mig.cpp similarity index 100% rename from external_interfaces/nvidia_mig.cpp rename to src/external_interfaces/nvidia_mig.cpp diff --git a/external_interfaces/parsers/caps-numa-benchmark.cpp b/src/external_interfaces/parsers/caps-numa-benchmark.cpp similarity index 100% rename from external_interfaces/parsers/caps-numa-benchmark.cpp rename to src/external_interfaces/parsers/caps-numa-benchmark.cpp diff --git a/external_interfaces/parsers/caps-numa-benchmark.hpp b/src/external_interfaces/parsers/caps-numa-benchmark.hpp similarity index 100% rename from external_interfaces/parsers/caps-numa-benchmark.hpp rename to src/external_interfaces/parsers/caps-numa-benchmark.hpp diff --git a/external_interfaces/parsers/cccbench.cpp b/src/external_interfaces/parsers/cccbench.cpp similarity index 100% rename from external_interfaces/parsers/cccbench.cpp rename to src/external_interfaces/parsers/cccbench.cpp diff --git a/external_interfaces/parsers/cccbench.hpp b/src/external_interfaces/parsers/cccbench.hpp similarity index 100% rename from external_interfaces/parsers/cccbench.hpp rename to src/external_interfaces/parsers/cccbench.hpp diff --git a/external_interfaces/parsers/hwloc.cpp b/src/external_interfaces/parsers/hwloc.cpp similarity index 100% rename from external_interfaces/parsers/hwloc.cpp rename to src/external_interfaces/parsers/hwloc.cpp diff --git a/external_interfaces/parsers/hwloc.hpp b/src/external_interfaces/parsers/hwloc.hpp similarity index 100% rename from external_interfaces/parsers/hwloc.hpp rename to src/external_interfaces/parsers/hwloc.hpp diff --git a/external_interfaces/parsers/mt4g.cpp b/src/external_interfaces/parsers/mt4g.cpp similarity index 100% rename from external_interfaces/parsers/mt4g.cpp rename to src/external_interfaces/parsers/mt4g.cpp diff --git a/external_interfaces/parsers/mt4g.hpp b/src/external_interfaces/parsers/mt4g.hpp similarity index 100% rename from external_interfaces/parsers/mt4g.hpp rename to src/external_interfaces/parsers/mt4g.hpp diff --git a/external_interfaces/proc_cpuinfo.cpp b/src/external_interfaces/proc_cpuinfo.cpp similarity index 100% rename from external_interfaces/proc_cpuinfo.cpp rename to src/external_interfaces/proc_cpuinfo.cpp diff --git a/src/sys-sage.hpp b/src/sys-sage.hpp index cf7a1c2..07a58dc 100644 --- a/src/sys-sage.hpp +++ b/src/sys-sage.hpp @@ -5,9 +5,9 @@ #include "Component.hpp" #include "DataPath.hpp" #include "xml_dump.hpp" -#include "parsers/hwloc.hpp" -#include "parsers/caps-numa-benchmark.hpp" -#include "parsers/mt4g.hpp" -#include "parsers/cccbench.hpp" +#include "external_interfaces/parsers/hwloc.hpp" +#include "external_interfaces/parsers/caps-numa-benchmark.hpp" +#include "external_interfaces/parsers/mt4g.hpp" +#include "external_interfaces/parsers/cccbench.hpp" #endif //SYS_SAGE From 35b66fd24911e4469cf887f12e8c901606e3bf54 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Sat, 7 Sep 2024 17:32:32 +0200 Subject: [PATCH 26/47] Moved parsers to src --- examples/CMakeLists.txt | 3 ++- src/CMakeLists.txt | 16 ++++++++-------- .../parsers/caps-numa-benchmark.cpp | 0 .../parsers/caps-numa-benchmark.hpp | 0 .../parsers/cccbench.cpp | 0 .../parsers/cccbench.hpp | 0 src/{external_interfaces => }/parsers/hwloc.cpp | 0 src/{external_interfaces => }/parsers/hwloc.hpp | 0 src/{external_interfaces => }/parsers/mt4g.cpp | 0 src/{external_interfaces => }/parsers/mt4g.hpp | 0 src/sys-sage.hpp | 8 ++++---- 11 files changed, 14 insertions(+), 13 deletions(-) rename src/{external_interfaces => }/parsers/caps-numa-benchmark.cpp (100%) rename src/{external_interfaces => }/parsers/caps-numa-benchmark.hpp (100%) rename src/{external_interfaces => }/parsers/cccbench.cpp (100%) rename src/{external_interfaces => }/parsers/cccbench.hpp (100%) rename src/{external_interfaces => }/parsers/hwloc.cpp (100%) rename src/{external_interfaces => }/parsers/hwloc.hpp (100%) rename src/{external_interfaces => }/parsers/mt4g.cpp (100%) rename src/{external_interfaces => }/parsers/mt4g.hpp (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e095a55..16a3971 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,8 @@ link_libraries(sys-sage sys-sage) include_directories(../src) -include_directories(../src/external_interfaces) +# include_directories(../src/external_interfaces) +# include_directories(../src/pa) find_package(OpenMP) if (OPENMP_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3fa1724..0d3341e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,10 +13,10 @@ set(SOURCES ${EXT_INTF}/intel_pqos.cpp ${EXT_INTF}/proc_cpuinfo.cpp ${EXT_INTF}/nvidia_mig.cpp - ${EXT_INTF}/parsers/hwloc.cpp - ${EXT_INTF}/parsers/caps-numa-benchmark.cpp - ${EXT_INTF}/parsers/mt4g.cpp - ${EXT_INTF}/parsers/cccbench.cpp + parsers/hwloc.cpp + parsers/caps-numa-benchmark.cpp + parsers/mt4g.cpp + parsers/cccbench.cpp ) set(HEADERS @@ -25,10 +25,10 @@ set(HEADERS Component.hpp DataPath.hpp xml_dump.hpp - ${EXT_INTF}/parsers/hwloc.hpp - ${EXT_INTF}/parsers/caps-numa-benchmark.hpp - ${EXT_INTF}/parsers/mt4g.hpp - ${EXT_INTF}/parsers/cccbench.cpp + parsers/hwloc.hpp + parsers/caps-numa-benchmark.hpp + parsers/mt4g.hpp + parsers/cccbench.cpp ) add_library(sys-sage SHARED ${SOURCES} ${HEADERS}) diff --git a/src/external_interfaces/parsers/caps-numa-benchmark.cpp b/src/parsers/caps-numa-benchmark.cpp similarity index 100% rename from src/external_interfaces/parsers/caps-numa-benchmark.cpp rename to src/parsers/caps-numa-benchmark.cpp diff --git a/src/external_interfaces/parsers/caps-numa-benchmark.hpp b/src/parsers/caps-numa-benchmark.hpp similarity index 100% rename from src/external_interfaces/parsers/caps-numa-benchmark.hpp rename to src/parsers/caps-numa-benchmark.hpp diff --git a/src/external_interfaces/parsers/cccbench.cpp b/src/parsers/cccbench.cpp similarity index 100% rename from src/external_interfaces/parsers/cccbench.cpp rename to src/parsers/cccbench.cpp diff --git a/src/external_interfaces/parsers/cccbench.hpp b/src/parsers/cccbench.hpp similarity index 100% rename from src/external_interfaces/parsers/cccbench.hpp rename to src/parsers/cccbench.hpp diff --git a/src/external_interfaces/parsers/hwloc.cpp b/src/parsers/hwloc.cpp similarity index 100% rename from src/external_interfaces/parsers/hwloc.cpp rename to src/parsers/hwloc.cpp diff --git a/src/external_interfaces/parsers/hwloc.hpp b/src/parsers/hwloc.hpp similarity index 100% rename from src/external_interfaces/parsers/hwloc.hpp rename to src/parsers/hwloc.hpp diff --git a/src/external_interfaces/parsers/mt4g.cpp b/src/parsers/mt4g.cpp similarity index 100% rename from src/external_interfaces/parsers/mt4g.cpp rename to src/parsers/mt4g.cpp diff --git a/src/external_interfaces/parsers/mt4g.hpp b/src/parsers/mt4g.hpp similarity index 100% rename from src/external_interfaces/parsers/mt4g.hpp rename to src/parsers/mt4g.hpp diff --git a/src/sys-sage.hpp b/src/sys-sage.hpp index 07a58dc..cf7a1c2 100644 --- a/src/sys-sage.hpp +++ b/src/sys-sage.hpp @@ -5,9 +5,9 @@ #include "Component.hpp" #include "DataPath.hpp" #include "xml_dump.hpp" -#include "external_interfaces/parsers/hwloc.hpp" -#include "external_interfaces/parsers/caps-numa-benchmark.hpp" -#include "external_interfaces/parsers/mt4g.hpp" -#include "external_interfaces/parsers/cccbench.hpp" +#include "parsers/hwloc.hpp" +#include "parsers/caps-numa-benchmark.hpp" +#include "parsers/mt4g.hpp" +#include "parsers/cccbench.hpp" #endif //SYS_SAGE From de5700b4445f809f047bba2fc765adeb182e325b Mon Sep 17 00:00:00 2001 From: Durganshu Date: Sun, 8 Sep 2024 00:20:09 +0200 Subject: [PATCH 27/47] CI-CD Documentation update --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++---------------- docs/check_docs.sh | 11 +++++++++ 2 files changed, 42 insertions(+), 20 deletions(-) create mode 100755 docs/check_docs.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 329f6e0..21acb95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,41 +3,52 @@ jobs: test: name: Unit Tests uses: ./.github/workflows/test.yml + asan: name: Address Sanitizer needs: test uses: ./.github/workflows/test.yml with: flags: -DTEST_ASAN=OFF - #TODO -DTEST_ASAN=ON + # TODO: Change to -DTEST_ASAN=ON when ready + tsan: name: Thread Sanitizer needs: test uses: ./.github/workflows/test.yml with: flags: -DTEST_TSAN=ON + ubsan: name: Undefined Behaviour Sanitizer needs: test uses: ./.github/workflows/test.yml with: flags: -DTEST_UBSAN=ON - # TODO check documentation CI so that unnecessary files (.cpp, examples/,...) can be left out - # doc: - # name: Documentation - # runs-on: [ubuntu-latest] - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # with: - # submodules: true - # - name: Install Doxygen - # run: sudo apt install doxygen - # - name: Install coverxygen - # run: pip3 install coverxygen - # - name: Generate documentation - # run: cd docs && doxygen Doxyfile - # - name: Generate documentation coverage - # run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ - # - name: Documentation report - # run: cd docs && ./show_undocumented.py doc-coverage.info + # check documentation CI so that unnecessary files (.cpp, examples/,...) can be left out + doc: + name: Documentation + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + + - name: Install Doxygen + run: sudo apt-get install -y doxygen + + - name: Install coverxygen + run: pip3 install coverxygen + + - name: Generate documentation + run: cd docs && doxygen Doxyfile + + - name: Generate documentation coverage + run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ + + - name: Documentation report + run: cd docs && ./show_undocumented.py doc-coverage.info + + - name: Check documentation completeness + run: ./docs/check_docs.sh \ No newline at end of file diff --git a/docs/check_docs.sh b/docs/check_docs.sh new file mode 100755 index 0000000..dd77d86 --- /dev/null +++ b/docs/check_docs.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +cd docs +./show_undocumented.py doc-coverage.info +RESULT=$? +echo "Script exit status: $RESULT" +if [ $RESULT -ne 0 ]; then + echo "Documentation is incomplete. The build will now fail." + exit 1 +fi +echo "Documentation check passed successfully." \ No newline at end of file From ba6be25da59e43cc474559eaaf748b0c85992ab3 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:03:05 +0200 Subject: [PATCH 28/47] Adding a function without any documentation to check CI --- src/Component.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Component.hpp b/src/Component.hpp index f4c0337..b4e06a1 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -69,6 +69,8 @@ class Component { @see GetChild(int _id) */ void InsertChild(Component * child); + + void DocumentationDemo(); /** * 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. From 3e8000f7d2b501064bc6138f97402f085ce54e4e Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:15:34 +0200 Subject: [PATCH 29/47] Modifications in CI/CD --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21acb95..2c470d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ - name: Documentation report - run: cd docs && ./show_undocumented.py doc-coverage.info + run: ./show_undocumented.py doc-coverage.info - name: Check documentation completeness run: ./docs/check_docs.sh \ No newline at end of file From a050b5d72d59461d6bbc03f2949969ac0113f83a Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:18:42 +0200 Subject: [PATCH 30/47] Updated CI/CD --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c470d6..6439bd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ - name: Documentation report - run: ./show_undocumented.py doc-coverage.info + run: cd docs && ./show_undocumented.py doc-coverage.info - name: Check documentation completeness - run: ./docs/check_docs.sh \ No newline at end of file + run: cd docs && ./check_docs.sh \ No newline at end of file From 94a34fb331a7fe2d642c9cbc6f99668482d1e585 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:27:15 +0200 Subject: [PATCH 31/47] Updates --- docs/show_undocumented.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/show_undocumented.py b/docs/show_undocumented.py index 88fc55f..806e3a1 100755 --- a/docs/show_undocumented.py +++ b/docs/show_undocumented.py @@ -12,6 +12,9 @@ exit(-1) cov = json.load(open(sys.argv[1])) + +print(f"Loading coverage file: {sys.argv[1]}") + missing = 0 for file in cov['files']: for sym in cov['files'][file]: From ba5231cfda5988232fa39438463f9315414927d8 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:29:45 +0200 Subject: [PATCH 32/47] docs/show_undocumented.py --- docs/show_undocumented.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/show_undocumented.py b/docs/show_undocumented.py index 806e3a1..21914f2 100755 --- a/docs/show_undocumented.py +++ b/docs/show_undocumented.py @@ -13,6 +13,9 @@ cov = json.load(open(sys.argv[1])) +with open(sys.argv[1], 'r') as f: + print(f.read()) + print(f"Loading coverage file: {sys.argv[1]}") missing = 0 From ca3c3f8c696f662a5ec293f669cccd34ad0c33ac Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:34:56 +0200 Subject: [PATCH 33/47] Harcoding the paths --- .github/workflows/ci.yml | 6 +++--- docs/show_undocumented.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6439bd2..79a4270 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,11 +44,11 @@ jobs: - name: Generate documentation run: cd docs && doxygen Doxyfile - - name: Generate documentation coverage - run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ + - name: Documentation coverage and Report + run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - name: Documentation report - run: cd docs && ./show_undocumented.py doc-coverage.info + run: cd docs && ./show_undocumented.py - name: Check documentation completeness run: cd docs && ./check_docs.sh \ No newline at end of file diff --git a/docs/show_undocumented.py b/docs/show_undocumented.py index 21914f2..549b4c3 100755 --- a/docs/show_undocumented.py +++ b/docs/show_undocumented.py @@ -7,16 +7,17 @@ import sys import json -if len(sys.argv) != 2: - print("Missing input file argument") - exit(-1) +# if len(sys.argv) != 2: +# print("Missing input file argument") +# exit(-1) -cov = json.load(open(sys.argv[1])) +#cov = json.load(open(sys.argv[1])) +cov = json.load(open("doc-coverage.info")) -with open(sys.argv[1], 'r') as f: - print(f.read()) - -print(f"Loading coverage file: {sys.argv[1]}") +# with open(sys.argv[1], 'r') as f: +# print(f.read()) + +# print(f"Loading coverage file: {sys.argv[1]}") missing = 0 for file in cov['files']: From 743def5e8ae33cbd8cbc382fde92dfae38ebe200 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 20:43:23 +0200 Subject: [PATCH 34/47] Update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79a4270..1dac1a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: run: cd docs && doxygen Doxyfile - name: Documentation coverage and Report - run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - name: Documentation report run: cd docs && ./show_undocumented.py From c3a2bf28765e70430f9106f0b64db2ae6dc5619e Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 20:50:39 +0200 Subject: [PATCH 35/47] Updates --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dac1a8..3882243 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,8 @@ jobs: run: cd docs && doxygen Doxyfile - name: Documentation coverage and Report - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py + #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info - name: Documentation report run: cd docs && ./show_undocumented.py From ff770b65df347a6401460ce17bbe9641d04f4453 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 20:52:31 +0200 Subject: [PATCH 36/47] Updates --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3882243..675257b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Documentation coverage and Report #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --prefix */src/ && ./show_undocumented.py - name: Documentation report run: cd docs && ./show_undocumented.py From de76adb0333387c7a6af4a18041c9fbd8d6fa404 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 20:56:04 +0200 Subject: [PATCH 37/47] updated --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 675257b..12a1770 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Documentation coverage and Report #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --prefix */src/ && ./show_undocumented.py + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 && ./show_undocumented.py - name: Documentation report run: cd docs && ./show_undocumented.py From 91bf95fd4e7bf585d91fc098ac2481d5b2ad187b Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 20:59:05 +0200 Subject: [PATCH 38/47] updated v2 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12a1770..fd6c6bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Documentation coverage and Report #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 && ./show_undocumented.py + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace && ./show_undocumented.py - name: Documentation report run: cd docs && ./show_undocumented.py From 697a9de41dc79d10603be88329ceea06af8f7276 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 23:25:13 +0200 Subject: [PATCH 39/47] updates --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd6c6bc..c6bd1ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Documentation coverage and Report #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace && ./show_undocumented.py + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' && ./show_undocumented.py - name: Documentation report run: cd docs && ./show_undocumented.py From fd584f8f4c06685f9fc5e8baf81fcd88eb0b05af Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 23:27:30 +0200 Subject: [PATCH 40/47] updated --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6bd1ae..c4ddb05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Documentation coverage and Report #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' && ./show_undocumented.py + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' - name: Documentation report run: cd docs && ./show_undocumented.py From d243ab04b859faf5e55226090e9c0f77274f1007 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 23:45:54 +0200 Subject: [PATCH 41/47] Final Updates --- .github/workflows/ci.yml | 2 +- src/Component.hpp | 38 ++++++++++++++++++++++++++++++++++++-- src/xml_dump.hpp | 14 ++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4ddb05..2a6f46e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: - name: Documentation coverage and Report #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py - run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' - name: Documentation report run: cd docs && ./show_undocumented.py diff --git a/src/Component.hpp b/src/Component.hpp index b4e06a1..a350c54 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -69,8 +69,6 @@ class Component { @see GetChild(int _id) */ void InsertChild(Component * child); - - void DocumentationDemo(); /** * 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. @@ -636,6 +634,11 @@ class Node : public Component { ~Node() override = default; #ifdef PROC_CPUINFO public: + /** + * @private + * Refreshes the CPU core frequency of the node. + * @param keep_history - If true, the history of the CPU core frequency will be kept. + */ int RefreshCpuCoreFrequency(bool keep_history = false); #endif #ifdef INTEL_PQOS //defined in intel_pqos.cpp @@ -701,6 +704,10 @@ class Memory : public Component { #ifdef NVIDIA_MIG public: + /** + * @private + * Gets the MIG size of the memory element. + */ long long GetMIGSize(string uuid = ""); #endif }; @@ -965,6 +972,10 @@ class Cache : public Component { #ifdef NVIDIA_MIG public: + /** + * @private + * Gets the MIG size of the cache element. + */ long long GetMIGSize(string uuid = ""); #endif }; @@ -1095,8 +1106,22 @@ class Core : public Component { #ifdef PROC_CPUINFO public: + /** + * @private + * Refreshes the frequency of the core. + */ int RefreshFreq(bool keep_history = false); + + /** + * @private + * Sets the frequency of the core. + */ void SetFreq(double _freq); + + /** + * @private + * Gets the frequency of the core. + */ double GetFreq(); private: double freq; @@ -1132,7 +1157,16 @@ class Thread : public Component { #ifdef PROC_CPUINFO //defined in proc_cpuinfo.cpp public: + /** + * @private + * Refreshes the frequency of the thread. + */ int RefreshFreq(bool keep_history = false); + + /** + * @private + * Gets the frequency of the thread. + */ double GetFreq(); #endif diff --git a/src/xml_dump.hpp b/src/xml_dump.hpp index eb8bb2c..52ca4ab 100644 --- a/src/xml_dump.hpp +++ b/src/xml_dump.hpp @@ -6,8 +6,22 @@ #include "Component.hpp" #include "DataPath.hpp" +/** + * @private + * Exports the Component Tree to an XML file. + */ int exportToXml(Component *root, string path = "", std::function search_custom_attrib_key_fcn = NULL, std::function search_custom_complex_attrib_key_fcn = NULL); + +/** + * @private + * For searching default attributes, i.e. those + for a specific key, return the value as a string to be printed in the xml + */ int search_default_attrib_key(string key, void *value, string *ret_value_str); +/** + * @private + * Prints the attributes. + */ int print_attrib(map attrib, xmlNodePtr n); #endif From 1e3cb6cc7c78a43b0b9d0bf650a2957096b2a431 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 23:49:12 +0200 Subject: [PATCH 42/47] Final changes --- .github/workflows/ci.yml | 4 ---- docs/check_docs.sh | 3 +-- docs/show_undocumented.py | 16 ++++++---------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a6f46e..7f81662 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,11 +45,7 @@ jobs: run: cd docs && doxygen Doxyfile - name: Documentation coverage and Report - #run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ && ./show_undocumented.py run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' - - name: Documentation report - run: cd docs && ./show_undocumented.py - - name: Check documentation completeness run: cd docs && ./check_docs.sh \ No newline at end of file diff --git a/docs/check_docs.sh b/docs/check_docs.sh index dd77d86..8e11231 100755 --- a/docs/check_docs.sh +++ b/docs/check_docs.sh @@ -1,7 +1,6 @@ #!/bin/bash -cd docs -./show_undocumented.py doc-coverage.info +./show_undocumented.py RESULT=$? echo "Script exit status: $RESULT" if [ $RESULT -ne 0 ]; then diff --git a/docs/show_undocumented.py b/docs/show_undocumented.py index 549b4c3..17db78e 100755 --- a/docs/show_undocumented.py +++ b/docs/show_undocumented.py @@ -2,22 +2,18 @@ # Shows undocumented symbols from the sys-sage project. # Requires https://github.com/psycofdj/coverxygen, install via: pip3 install coverxygen -# Generate coverage file: python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 +# Generate coverage file: python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' import sys import json -# if len(sys.argv) != 2: -# print("Missing input file argument") -# exit(-1) +if len(sys.argv) != 2: + print("Missing input file argument") + exit(-1) -#cov = json.load(open(sys.argv[1])) -cov = json.load(open("doc-coverage.info")) +cov = json.load(open(sys.argv[1])) -# with open(sys.argv[1], 'r') as f: -# print(f.read()) - -# print(f"Loading coverage file: {sys.argv[1]}") +print(f"Loading coverage file: {sys.argv[1]}") missing = 0 for file in cov['files']: From 383c9cbe857e206f341a521b9d40c7675e59e1de Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 23:50:25 +0200 Subject: [PATCH 43/47] Final changes --- docs/check_docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/check_docs.sh b/docs/check_docs.sh index 8e11231..8d9abfe 100755 --- a/docs/check_docs.sh +++ b/docs/check_docs.sh @@ -1,6 +1,6 @@ #!/bin/bash -./show_undocumented.py +./show_undocumented.py doc-coverage.info RESULT=$? echo "Script exit status: $RESULT" if [ $RESULT -ne 0 ]; then From e57beb9e0245f59353d04ba2813d93365c29e163 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Thu, 19 Sep 2024 23:51:27 +0200 Subject: [PATCH 44/47] Final changes --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f81662..dad62ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Generate documentation run: cd docs && doxygen Doxyfile - - name: Documentation coverage and Report + - name: Documentation coverage run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' - name: Check documentation completeness From 7dc6f9670bbd75ebf023f010320d04fa0880d832 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Wed, 18 Sep 2024 23:18:42 +0200 Subject: [PATCH 45/47] Updated CI/CD to check genrated documentation --- .github/workflows/ci.yml | 9 +++------ docs/check_docs.sh | 1 - docs/show_undocumented.py | 5 ++++- src/Component.hpp | 38 ++++++++++++++++++++++++++++++++++++-- src/xml_dump.hpp | 14 ++++++++++++++ 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c470d6..dad62ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,11 +44,8 @@ jobs: - name: Generate documentation run: cd docs && doxygen Doxyfile - - name: Generate documentation coverage - run: cd docs && python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --prefix */src/ - - - name: Documentation report - run: ./show_undocumented.py doc-coverage.info + - name: Documentation coverage + run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' - name: Check documentation completeness - run: ./docs/check_docs.sh \ No newline at end of file + run: cd docs && ./check_docs.sh \ No newline at end of file diff --git a/docs/check_docs.sh b/docs/check_docs.sh index dd77d86..8d9abfe 100755 --- a/docs/check_docs.sh +++ b/docs/check_docs.sh @@ -1,6 +1,5 @@ #!/bin/bash -cd docs ./show_undocumented.py doc-coverage.info RESULT=$? echo "Script exit status: $RESULT" diff --git a/docs/show_undocumented.py b/docs/show_undocumented.py index 88fc55f..17db78e 100755 --- a/docs/show_undocumented.py +++ b/docs/show_undocumented.py @@ -2,7 +2,7 @@ # Shows undocumented symbols from the sys-sage project. # Requires https://github.com/psycofdj/coverxygen, install via: pip3 install coverxygen -# Generate coverage file: python3 -m coverxygen --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 +# Generate coverage file: python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' import sys import json @@ -12,6 +12,9 @@ exit(-1) cov = json.load(open(sys.argv[1])) + +print(f"Loading coverage file: {sys.argv[1]}") + missing = 0 for file in cov['files']: for sym in cov['files'][file]: diff --git a/src/Component.hpp b/src/Component.hpp index b4e06a1..a350c54 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -69,8 +69,6 @@ class Component { @see GetChild(int _id) */ void InsertChild(Component * child); - - void DocumentationDemo(); /** * 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. @@ -636,6 +634,11 @@ class Node : public Component { ~Node() override = default; #ifdef PROC_CPUINFO public: + /** + * @private + * Refreshes the CPU core frequency of the node. + * @param keep_history - If true, the history of the CPU core frequency will be kept. + */ int RefreshCpuCoreFrequency(bool keep_history = false); #endif #ifdef INTEL_PQOS //defined in intel_pqos.cpp @@ -701,6 +704,10 @@ class Memory : public Component { #ifdef NVIDIA_MIG public: + /** + * @private + * Gets the MIG size of the memory element. + */ long long GetMIGSize(string uuid = ""); #endif }; @@ -965,6 +972,10 @@ class Cache : public Component { #ifdef NVIDIA_MIG public: + /** + * @private + * Gets the MIG size of the cache element. + */ long long GetMIGSize(string uuid = ""); #endif }; @@ -1095,8 +1106,22 @@ class Core : public Component { #ifdef PROC_CPUINFO public: + /** + * @private + * Refreshes the frequency of the core. + */ int RefreshFreq(bool keep_history = false); + + /** + * @private + * Sets the frequency of the core. + */ void SetFreq(double _freq); + + /** + * @private + * Gets the frequency of the core. + */ double GetFreq(); private: double freq; @@ -1132,7 +1157,16 @@ class Thread : public Component { #ifdef PROC_CPUINFO //defined in proc_cpuinfo.cpp public: + /** + * @private + * Refreshes the frequency of the thread. + */ int RefreshFreq(bool keep_history = false); + + /** + * @private + * Gets the frequency of the thread. + */ double GetFreq(); #endif diff --git a/src/xml_dump.hpp b/src/xml_dump.hpp index eb8bb2c..52ca4ab 100644 --- a/src/xml_dump.hpp +++ b/src/xml_dump.hpp @@ -6,8 +6,22 @@ #include "Component.hpp" #include "DataPath.hpp" +/** + * @private + * Exports the Component Tree to an XML file. + */ int exportToXml(Component *root, string path = "", std::function search_custom_attrib_key_fcn = NULL, std::function search_custom_complex_attrib_key_fcn = NULL); + +/** + * @private + * For searching default attributes, i.e. those + for a specific key, return the value as a string to be printed in the xml + */ int search_default_attrib_key(string key, void *value, string *ret_value_str); +/** + * @private + * Prints the attributes. + */ int print_attrib(map attrib, xmlNodePtr n); #endif From d4c28a8ea0c00ba790933ae72d3b74ba7ce64fc5 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Fri, 20 Sep 2024 00:03:42 +0200 Subject: [PATCH 46/47] Added comment in yml file --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dad62ee..a1ab8a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: run: cd docs && doxygen Doxyfile - name: Documentation coverage + # Exclude parsers, external_interfaces, examples, data-sources and .cpp files run: cd docs && python3 -m coverxygen --verbose --xml-dir xml --src-dir ../src/ --output doc-coverage.info --format json-v3 --scope public,protected --kind enum,enumvalue,friend,typedef,function,class,struct,union,define,file,namespace --exclude '.*\/parsers\/.*' --exclude '.*\/external_interfaces\/.*' --exclude '.*\/examples\/.*' --exclude '.*\/data-sources\/.*' --exclude '.*\.cpp$' - name: Check documentation completeness From c710301d6e24701ec26bbc294b5fa834abbaea14 Mon Sep 17 00:00:00 2001 From: Durganshu Date: Sat, 21 Sep 2024 11:01:47 +0200 Subject: [PATCH 47/47] Publicized some of the API calls --- src/Component.hpp | 8 -------- src/xml_dump.hpp | 1 - 2 files changed, 9 deletions(-) diff --git a/src/Component.hpp b/src/Component.hpp index a350c54..8ced774 100644 --- a/src/Component.hpp +++ b/src/Component.hpp @@ -635,7 +635,6 @@ class Node : public Component { #ifdef PROC_CPUINFO public: /** - * @private * Refreshes the CPU core frequency of the node. * @param keep_history - If true, the history of the CPU core frequency will be kept. */ @@ -705,7 +704,6 @@ class Memory : public Component { #ifdef NVIDIA_MIG public: /** - * @private * Gets the MIG size of the memory element. */ long long GetMIGSize(string uuid = ""); @@ -973,7 +971,6 @@ class Cache : public Component { #ifdef NVIDIA_MIG public: /** - * @private * Gets the MIG size of the cache element. */ long long GetMIGSize(string uuid = ""); @@ -1107,19 +1104,16 @@ class Core : public Component { #ifdef PROC_CPUINFO public: /** - * @private * Refreshes the frequency of the core. */ int RefreshFreq(bool keep_history = false); /** - * @private * Sets the frequency of the core. */ void SetFreq(double _freq); /** - * @private * Gets the frequency of the core. */ double GetFreq(); @@ -1158,13 +1152,11 @@ class Thread : public Component { #ifdef PROC_CPUINFO //defined in proc_cpuinfo.cpp public: /** - * @private * Refreshes the frequency of the thread. */ int RefreshFreq(bool keep_history = false); /** - * @private * Gets the frequency of the thread. */ double GetFreq(); diff --git a/src/xml_dump.hpp b/src/xml_dump.hpp index 52ca4ab..0a75d62 100644 --- a/src/xml_dump.hpp +++ b/src/xml_dump.hpp @@ -7,7 +7,6 @@ #include "DataPath.hpp" /** - * @private * Exports the Component Tree to an XML file. */ int exportToXml(Component *root, string path = "", std::function search_custom_attrib_key_fcn = NULL, std::function search_custom_complex_attrib_key_fcn = NULL);