Skip to content

Commit 98011e3

Browse files
Merge pull request #38 from caps-tum/develop
Develop
2 parents e92f3ea + c9668f0 commit 98011e3

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

examples/custom_parser_musa/musa_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <vector>
55
#include <map>
66
#include <sstream>
7+
#include <algorithm>
78

89
#include "musa_parser.hpp"
910

src/Component.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ void Numa::SetSize(long long _size) { size = _size;}
650650

651651
long long Memory::GetSize() {return size;}
652652
void Memory::SetSize(long long _size) {size = _size;}
653+
bool Memory::GetIsVolatile() {return is_volatile;}
654+
void Memory::SetIsVolatile(bool _is_volatile) {is_volatile = _is_volatile;}
653655

654656
string Cache::GetCacheName(){return cache_type;}
655657
void Cache::SetCacheName(string _name) { cache_type = _name;}
@@ -699,14 +701,16 @@ Topology::Topology():Component(0, "sys-sage Topology", SYS_SAGE_COMPONENT_TOPOLO
699701
Node::Node(int _id, string _name):Component(_id, _name, SYS_SAGE_COMPONENT_NODE){}
700702
Node::Node(Component * parent, int _id, string _name):Component(parent, _id, _name, SYS_SAGE_COMPONENT_NODE){}
701703

702-
Memory::Memory():Component(0, "Memory", SYS_SAGE_COMPONENT_MEMORY){}
703-
Memory::Memory(Component * parent, int _id, string _name, long long _size):Component(parent, _id, _name, SYS_SAGE_COMPONENT_MEMORY), size(_size){}
704+
Memory::Memory(long long _size, bool _is_volatile):Component(0, "Memory", SYS_SAGE_COMPONENT_MEMORY), size(_size), is_volatile(_is_volatile){}
705+
//Memory::Memory(Component * parent, int _id, string _name, long long _size):Component(parent, _id, _name, SYS_SAGE_COMPONENT_MEMORY), size(_size){}
706+
Memory::Memory(Component * parent, int _id, string _name, long long _size, bool _is_volatile):Component(parent, _id, _name, SYS_SAGE_COMPONENT_MEMORY), size(_size), is_volatile(_is_volatile){}
704707

705-
Storage::Storage():Component(0, "Storage", SYS_SAGE_COMPONENT_STORAGE){}
706-
Storage::Storage(Component * parent):Component(parent, 0, "Storage", SYS_SAGE_COMPONENT_STORAGE){}
707708

708-
Chip::Chip(int _id, string _name, int _type):Component(_id, _name, SYS_SAGE_COMPONENT_CHIP), type(_type) {}
709-
Chip::Chip(Component * parent, int _id, string _name, int _type):Component(parent, _id, _name, SYS_SAGE_COMPONENT_CHIP), type(_type){}
709+
Storage::Storage(long long _size):Component(0, "Storage", SYS_SAGE_COMPONENT_STORAGE), size(_size){}
710+
Storage::Storage(Component * parent, long long _size):Component(parent, 0, "Storage", SYS_SAGE_COMPONENT_STORAGE), size(_size){}
711+
712+
Chip::Chip(int _id, string _name, int _type, string _vendor, string _model):Component(_id, _name, SYS_SAGE_COMPONENT_CHIP), type(_type), vendor(_vendor), model(_model) {}
713+
Chip::Chip(Component * parent, int _id, string _name, int _type, string _vendor, string _model):Component(parent, _id, _name, SYS_SAGE_COMPONENT_CHIP), type(_type), vendor(_vendor), model(_model){}
710714

711715
Cache::Cache(int _id, int _cache_level, long long _cache_size, int _associativity, int _cache_line_size): Component(_id, "Cache", SYS_SAGE_COMPONENT_CACHE), cache_type(to_string(_cache_level)), cache_size(_cache_size), cache_associativity_ways(_associativity), cache_line_size(_cache_line_size){}
712716
Cache::Cache(Component * parent, int _id, string _cache_type, long long _cache_size, int _associativity, int _cache_line_size): Component(parent, _id, "Cache", SYS_SAGE_COMPONENT_CACHE), cache_type(_cache_type), cache_size(_cache_size), cache_associativity_ways(_associativity), cache_line_size(_cache_line_size){}

src/Component.hpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define COMPONENT
33

44
#include <iostream>
5+
#include <type_traits>
56
#include <vector>
67
#include <map>
78
#include <set>
@@ -665,16 +666,20 @@ class Memory : public Component {
665666
@param _id = 0
666667
@param _name = "Memory"
667668
@param componentType=>SYS_SAGE_COMPONENT_MEMORY
669+
@param _size = size/capacity of the memory element, default -1
670+
@param is_volatile = true if the memory is volatile, default false
668671
*/
669-
Memory();
672+
Memory(long long _size = -1, bool is_volatile = false);
670673
/**
671674
Memory constructor with insertion into the Component Tree as the parent 's child (as long as parent is an existing Component). Sets:
672675
@param parent = the parent
673676
@param _id = 0
674677
@param _name = name, default "Memory"
675678
@param componentType=>SYS_SAGE_COMPONENT_MEMORY
679+
@param _size = size/capacity of the memory element, default -1
680+
@param is_volatile = true if the memory is volatile, default false
676681
*/
677-
Memory(Component * parent, int id = 0, string _name = "Memory", long long _size = -1);
682+
Memory(Component * parent, int id = 0, string _name = "Memory", long long _size = -1, bool is_volatile = false);
678683
/**
679684
* @private
680685
* Use Delete() or DeleteSubtree() for deleting and deallocating the components.
@@ -691,6 +696,17 @@ class Memory : public Component {
691696
* @param _size = size
692697
*/
693698
void SetSize(long long _size);
699+
/**
700+
* Retrieves if the memory element is volatile
701+
* @return is_volatile
702+
*
703+
*/
704+
bool GetIsVolatile();
705+
/**
706+
* Sets if the memory element is volatile
707+
* @param _is_volatile = update is_volatile
708+
*/
709+
void SetIsVolatile(bool _is_volatile);
694710
/**
695711
@private
696712
!!Should normally not be used!! Helper function of XML dump generation.
@@ -721,16 +737,18 @@ class Storage : public Component {
721737
@param _id = 0
722738
@param _name = "Storage"
723739
@param componentType=>SYS_SAGE_COMPONENT_STORAGE
740+
@param _size = size/capacity of the storage device, default -1
724741
*/
725-
Storage();
742+
Storage(long long _size = -1);
726743
/**
727744
Storage constructor with insertion into the Component Tree as the parent 's child (as long as parent is an existing Component). Sets:
728745
@param parent = the parent
729746
@param _id = 0
730747
@param _name = "Storage"
731748
@param componentType=>SYS_SAGE_COMPONENT_STORAGE
749+
@param _size = size/capacity of the storage device, default -1
732750
*/
733-
Storage(Component * parent);
751+
Storage(Component * parent, long long _size = -1);
734752
/**
735753
* @private
736754
* Use Delete() or DeleteSubtree() for deleting and deallocating the components.
@@ -769,17 +787,21 @@ class Chip : public Component {
769787
@param _name = name, default "Chip"
770788
@param _type = chip type, default SYS_SAGE_CHIP_TYPE_NONE. Defines which chip we are describing. The options are: SYS_SAGE_CHIP_TYPE_NONE (default/generic), SYS_SAGE_CHIP_TYPE_CPU, SYS_SAGE_CHIP_TYPE_CPU_SOCKET, SYS_SAGE_CHIP_TYPE_GPU.
771789
@param componentType=>SYS_SAGE_COMPONENT_CHIP
790+
@param _vendor = name of the vendor, default ""
791+
@param _model = model name, default ""
772792
*/
773-
Chip(int _id = 0, string _name = "Chip", int _type = SYS_SAGE_CHIP_TYPE_NONE);
793+
Chip(int _id = 0, string _name = "Chip", int _type = SYS_SAGE_CHIP_TYPE_NONE, string _vendor = "", string _model = "");
774794
/**
775795
Chip constructor with insertion into the Component Tree as the parent 's child (as long as parent is an existing Component). Sets:
776796
@param parent = the parent
777797
@param _id = id, default 0
778798
@param _name = name, default "Chip"
779799
@param _type = chip type, default SYS_SAGE_CHIP_TYPE_NONE. Defines which chip we are describing. The options are: SYS_SAGE_CHIP_TYPE_NONE (default/generic), SYS_SAGE_CHIP_TYPE_CPU, SYS_SAGE_CHIP_TYPE_CPU_SOCKET, SYS_SAGE_CHIP_TYPE_GPU.
780800
@param componentType=>SYS_SAGE_COMPONENT_CHIP
801+
@param _vendor = name of the vendor, default ""
802+
@param _model = model name, default ""
781803
*/
782-
Chip(Component * parent, int _id = 0, string _name = "Chip", int _type = SYS_SAGE_CHIP_TYPE_NONE);
804+
Chip(Component * parent, int _id = 0, string _name = "Chip", int _type = SYS_SAGE_CHIP_TYPE_NONE, string _vendor = "", string _model = "");
783805
/**
784806
* @private
785807
* Use Delete() or DeleteSubtree() for deleting and deallocating the components.

src/parsers/mt4g.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <algorithm>
99
#include <tuple>
1010
#include <string>
11+
#include <algorithm>
1112

1213
int parseMt4gTopo(Node* parent, string dataSourcePath, int gpuId, string delim)
1314
{

src/xml_dump.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ int exportToXml(Component* root, string path, std::function<int(string,void*,str
250250
for(Component* cPtr : components)
251251
{
252252
vector<DataPath*>* dpList = cPtr->GetDataPaths(SYS_SAGE_DATAPATH_INCOMING);
253-
vector<DataPath*> printed_dp;
253+
set<DataPath*> printed_dp;
254254

255255
for(DataPath* dpPtr : *dpList)
256256
{
257257
//check if previously processed
258-
if (std::find(printed_dp.begin(), printed_dp.end(), dpPtr) == printed_dp.end())
258+
if (printed_dp.find(dpPtr) == printed_dp.end())
259259
{
260260
xmlNodePtr dp_n = xmlNewNode(NULL, BAD_CAST "datapath");
261261
std::ostringstream src_addr;
@@ -272,7 +272,7 @@ int exportToXml(Component* root, string path, std::function<int(string,void*,str
272272

273273
print_attrib(dpPtr->attrib, dp_n);
274274

275-
printed_dp.push_back(dpPtr);
275+
printed_dp.insert(dpPtr);
276276
}
277277
}
278278
}

0 commit comments

Comments
 (0)