OpenASIP 2.2
Loading...
Searching...
No Matches
DesignSpaceExplorerPlugin.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2011 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file DesignSpaceExplorerPlugin.cc
26 *
27 * Implementation of DesignSpaceExplorerPlugin class
28 *
29 * @author Jari Mäntyneva 2007 (jari.mantyneva-no.spam-tut.fi)
30 * @author Pekka Jääskeläinen 2011
31 * @note rating: red
32 */
33
34#include <map>
35#include <string>
36
39#include "Exception.hh"
40#include "StringTools.hh"
41
42/**
43 * The constructor of the DesignExplorerPlugin class.
44 *
45 * @param dsdb Design space data base to be used with the plugin.
46 * @name pluginName Name of the plugin.
47 */
51
52
53/**
54 * The destructor.
55 */
58
59
60/**
61 * Sets the plugin name.
62 *
63 * @param pluginName Name of the plugin.
64 */
65void
66DesignSpaceExplorerPlugin::setPluginName(const std::string& pluginName) {
67 pluginName_ = pluginName;
68}
69
70
71/**
72 * Returns the plugin name.
73 *
74 * @return The plugin name as a string.
75 */
76std::string
80
81
82/**
83 * Gives a plugin parameter value.
84 *
85 * @param name The parameter name.
86 * @param value The value to be set for the parameter.
87 */
88void
90 const std::string& name, const std::string& value) {
91 PMIt it = parameters_.find(name);
92 if (it == parameters_.end()) {
93 std::string msg = "Plugin has no parameter named: " + name;
94 throw InstanceNotFound(__FILE__, __LINE__, __func__, msg);
95 }
96 it->second.setValue(value);
97}
98
99/**
100 * Tells whether the plugin has the given parameter defined.
101 *
102 * @param paramName Name of the parameter.
103 * @return True if the given parameter is defined, otherwise false.
104 */
105bool
106DesignSpaceExplorerPlugin::hasParameter(const std::string& paramName) const {
107 return parameters_.find(paramName)->second.isSet();
108}
109
110
111/**
112 * Makes a copy of the parameters of the plugin and returns it.
113 *
114 * @return ParameterMap map of the explorer plugin parameters.
115 */
120
121
122/**
123 * Returns the boolean value of the given parameter if parameter can be
124 * considered as a boolean.
125 *
126 * @param parameter The string to be converted to a boolean value
127 * @return Boolean value of the parameter
128 * @exception IllegalParameters Given parameter could not be considerer as
129 * boolean value
130 */
131bool
132DesignSpaceExplorerPlugin::booleanValue(const std::string& parameter) const {
133 std::string lowCase = StringTools::stringToLower(parameter);
134 if (lowCase == "true" || lowCase == "1") {
135 return true;
136 } else if (lowCase == "false" || lowCase == "0") {
137 return false;
138 } else {
139 throw IllegalParameters(__FILE__, __LINE__, __func__);
140 }
141}
142
143/**
144 * Checks that all compulsory parameters are set for the plugin.
145 */
146void
148 for (PMCIt it = parameters_.begin(); it != parameters_.end(); it++) {
149 if (it->second.isCompulsory() && !it->second.isSet()) {
150 std::string msg = it->second.name() + " parameter is needed.";
151 throw IllegalParameters(__FILE__, __LINE__, __func__, msg);
152 }
153 }
154}
155
156/**
157 * Explores the design space from the starting point machine and returns
158 * best exploring results as configuration IDs.
159 *
160 * Exploring creates new machine configurations (architecture, implementation)
161 * that are ordered so that the best results are first in the result vector.
162 *
163 * @param startPoint Starting point machine configuration for the plugin.
164 * @param maxIter Maximum number of design space points the plugin is allowed to
165 * explore. Default value for maxIter is zero when the iteration number is not
166 * taken into account. In that case the exploration runs indefinetly or stops
167 * at a point defined by the algorithm.
168 * @return Ordered vector of IDs of the best machine configurations where the
169 * target programs can be successfully run. The IDs of the best machine
170 * configurations are first in the result vector. Returns an empty vector if
171 * does not find any possible machine configurations.
172 */
173std::vector<RowID>
175 const RowID&, const unsigned int&) {
176
177 std::vector<RowID> result;
178 return result;
179}
#define __func__
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
std::map< std::string, ExplorerPluginParameter >::iterator PMIt
virtual bool hasParameter(const std::string &paramName) const
virtual void setPluginName(const std::string &pluginName)
virtual std::string name() const
std::map< std::string, ExplorerPluginParameter > ParameterMap
ParameterMap parameters_
Parameters for the plugin.
std::map< std::string, ExplorerPluginParameter >::const_iterator PMCIt
std::string pluginName_
the name of the explorer plugin
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
virtual bool booleanValue(const std::string &parameter) const
virtual void giveParameter(const std::string &name, const std::string &value)
static std::string stringToLower(const std::string &source)