OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
ResourceBuildDirector Class Reference

#include <ResourceBuildDirector.hh>

Collaboration diagram for ResourceBuildDirector:
Collaboration graph

Public Member Functions

 ResourceBuildDirector ()
 
virtual ~ResourceBuildDirector ()
 
void addBroker (ResourceBroker &broker)
 
void build (const TTAMachine::Machine &machine)
 
void print (std::ostream &target_, unsigned int cycles) const
 
void clear ()
 

Private Attributes

std::vector< ResourceBroker * > brokers_
 Resource brokers. More...
 
ResourceMapper mapper_
 Resource mapper. More...
 

Detailed Description

Handles resource model construction.

Definition at line 51 of file ResourceBuildDirector.hh.

Constructor & Destructor Documentation

◆ ResourceBuildDirector()

ResourceBuildDirector::ResourceBuildDirector ( )

Constructor.

Definition at line 42 of file ResourceBuildDirector.cc.

42  {
43 }

◆ ~ResourceBuildDirector()

ResourceBuildDirector::~ResourceBuildDirector ( )
virtual

Destructor.

Definition at line 48 of file ResourceBuildDirector.cc.

References brokers_, and SequenceTools::deleteAllItems().

Here is the call graph for this function:

Member Function Documentation

◆ addBroker()

void ResourceBuildDirector::addBroker ( ResourceBroker broker)

Add given broker to the list of brokers responsible for resource construction.

The order in which brokers are added is irrelevant.

Parameters
brokerBroker to add.

Definition at line 61 of file ResourceBuildDirector.cc.

61  {
63  throw ObjectAlreadyExists(__FILE__, __LINE__, __func__);
64  } else {
65  brokers_.push_back(&broker);
66  }
67 }

References __func__, brokers_, and ContainerTools::containsValue().

Referenced by SimpleResourceManager::buildResourceModel().

Here is the call graph for this function:

◆ build()

void ResourceBuildDirector::build ( const TTAMachine::Machine machine)

Build a complete resource object model for given target processor.

@machine Machine to build from.

Definition at line 75 of file ResourceBuildDirector.cc.

75  {
76 
77  // build primary resources
78  for (unsigned int i = 0; i < brokers_.size(); i++) {
79  brokers_[i]->buildResources(machine);
81  }
82 
83  // setup dependent and related resource links
84  for (unsigned int i = 0; i < brokers_.size(); i++) {
85  brokers_[i]->setupResourceLinks(mapper_);
86  }
87  for (unsigned int i = 0; i < brokers_.size(); i++) {
88  // broker throws in case problem is found
89  brokers_[i]->validateResources();
90  }
91 }

References ResourceMapper::addResourceMap(), brokers_, machine, and mapper_.

Referenced by SimpleResourceManager::buildResourceModel().

Here is the call graph for this function:

◆ clear()

void ResourceBuildDirector::clear ( )

Clears all resources of the resouce manager so that the RM can be reused.

Definition at line 178 of file ResourceBuildDirector.cc.

178  {
179  for (size_t i = 0; i < brokers_.size(); i++) {
180  brokers_[i]->clear();
181  }
182 }

References brokers_.

Referenced by SimpleResourceManager::clear().

◆ print()

void ResourceBuildDirector::print ( std::ostream &  target_,
unsigned int  cycles 
) const

Print resource manager's contents.

Parameters
target_Output stream to pring (eg. std::cout).
cyclesHow many cycles to print.

@machine Machine to build from.

Definition at line 102 of file ResourceBuildDirector.cc.

103 {
104  std::vector<ResourceBroker::ResourceSet> contents;
105  std::vector<ResourceBroker::ResourceSet::iterator> contentIterators;
106 
107  bool finished = false;
108  unsigned int k = 0;
109  unsigned int minWidth = cycles;
110 
111  // determine minimum width for field, it is constrained by cycle count or broker's name
112  for (std::vector<ResourceBroker*>::const_iterator i = brokers_.begin(); i != brokers_.end(); ++i) {
113 
114  std::string name = (*i)->brokerName();
115 
116  if(name.length() > minWidth) {
117  minWidth = name.length();
118  }
119  }
120  minWidth += 1;
121 
122  // print broker names
123  for (std::vector<ResourceBroker*>::const_iterator i = brokers_.begin(); i != brokers_.end(); ++i) {
124  target_ << std::left << std::setw(minWidth);
125  target_ << (*i)->brokerName();
126  }
127  target_ << std::endl;
128 
129  // print broker reservation tables
130  while (!finished) {
131 
132  finished = true;
133  for (std::vector<ResourceBroker*>::const_iterator i = brokers_.begin(); i != brokers_.end(); ++i) {
134 
136  (*i)->resources(c);
137  ResourceBroker::ResourceSet::iterator j = c.begin();
138 
139  if(k >= c.size()) {
140  target_ << std::left << std::setw(minWidth) << ' ';
141  //<<
142 // std::string(cycles, ' ');
143  continue;
144  }
145 
146  std::advance(j, k);
147 
148  if(j == c.end()) {
149 // target_ << std::left << std::setw(minWidth) <<
150 // std::string(cycles, ' ');
151  continue;
152  }
153 
154  finished = false;
155 
156  std::string table = "";
157  for (unsigned int cycle = 0; cycle < cycles; ++cycle)
158  {
159  if((*j)->isAvailable(cycle)) {
160  table += '-';
161  }
162  else {
163  table += '#';
164  std::cerr << (*j) << " " << (*j)->name() << std::endl;
165  }
166  }
167  target_ << std::left << std::setw(minWidth) << table;
168  }
169  target_ << std::endl;
170  k += 1;
171  }
172 }

References brokers_.

Referenced by SimpleResourceManager::print(), and SimpleResourceManager::toString().

Member Data Documentation

◆ brokers_

std::vector<ResourceBroker*> ResourceBuildDirector::brokers_
private

Resource brokers.

Definition at line 63 of file ResourceBuildDirector.hh.

Referenced by addBroker(), build(), clear(), print(), and ~ResourceBuildDirector().

◆ mapper_

ResourceMapper ResourceBuildDirector::mapper_
private

Resource mapper.

Definition at line 65 of file ResourceBuildDirector.hh.

Referenced by build().


The documentation for this class was generated from the following files:
ResourceBuildDirector::brokers_
std::vector< ResourceBroker * > brokers_
Resource brokers.
Definition: ResourceBuildDirector.hh:63
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
ResourceBuildDirector::mapper_
ResourceMapper mapper_
Resource mapper.
Definition: ResourceBuildDirector.hh:65
ResourceBroker::ResourceSet
std::set< SchedulingResource * > ResourceSet
Definition: ResourceBroker.hh:66
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
__func__
#define __func__
Definition: Application.hh:67
ObjectAlreadyExists
Definition: Exception.hh:1002
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
ResourceMapper::addResourceMap
void addResourceMap(const ResourceBroker &broker)
Definition: ResourceMapper.cc:60