OpenASIP 2.2
Loading...
Searching...
No Matches
ExplorerCmdLineOptions.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 ExplorerCmdLineOptions.cc
26 *
27 * Declaration of ExplorerCmdLineOptions.
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 <iostream>
35
36//#include "ExplorerConstants.hh"
37#include "CmdLineOptions.hh"
39#include "TCEString.hh"
40#include "tce_config.h"
41
42/// Long switch string for giving an explorer plugin to be used.
43const std::string SWL_PLUGIN_NAME = "explorer_plugin";
44/// Short switch string for giving an explorer plugin to be used.
45const std::string SWS_PLUGIN_NAME = "e";
46/// Long switch string for giving an explorer plugin info.
47const std::string SWL_PLUGIN_INFO = "plugin_info";
48/// Short switch string for giving an explorer plugin info.
49const std::string SWS_PLUGIN_INFO = "p";
50/// Long switch string for giving an explorer plugin to be used.
51const std::string SWL_PLUGIN_PARAM = "plugin_param";
52/// Short switch string for giving an explorer plugin to be used.
53const std::string SWS_PLUGIN_PARAM = "u";
54/// Design space explorer title
55const std::string DSCLI_TITLE = "Design Space Explorer for TTA.";
56/// Long switch string for adding a application directory.
57const std::string SWL_TEST_DIR_ADD = "add_app_dir";
58/// Short switch string for adding a application directory.
59const std::string SWS_TEST_DIR_ADD = "d";
60/// Long switch string for giving a start configuration id.
61const std::string SWL_START_ID = "start";
62/// Short switch string for giving a start configuration id.
63const std::string SWS_START_ID = "s";
64/// Long switch string for number of configurations flag.
65const std::string SWL_CONFIGURATION_SUMMARY = "conf_summary";
66/// Short switch string for number of configurations flag.
67const std::string SWS_CONFIGURATION_SUMMARY = "c";
68/// Switch strings for the pareto set flag.
69const std::string SWL_PARETO_SET = "pareto_set";
70const std::string SWS_PARETO_SET = "t";
71/// Long switch string for number of configurations flag.
72const std::string SWL_CONFIGURATION_COUNT = "conf_count";
73/// Short switch string for number of configurations flag.
74const std::string SWS_CONFIGURATION_COUNT = "n";
75/// Long switch string for writing out configuration files.
76const std::string SWL_CONFIGURATION_WRITE = "write_conf";
77/// Short switch string for writing out configuration files.
78const std::string SWS_CONFIGURATION_WRITE = "w";
79/// Long switch string for removing application paths from dsdb.
80const std::string SWL_TEST_DIR_RM = "rm_app";
81/// Short switch string for removing application paths from dsdb.
82const std::string SWS_TEST_DIR_RM = "r";
83/// Long switch string for listing application paths in the dsdb.
84const std::string SWL_LIST_APPS = "list_apps";
85/// Short switch string for listing loadable plugins.
86const std::string SWS_LIST_APPS = "l";
87/// Long switch string for listing loadable plugins.
88const std::string SWL_LIST_PLUGINS = "list_plugins";
89/// Short switch string for listing application paths in the dsdb.
90const std::string SWS_LIST_PLUGINS = "g";
91
92const std::string SWL_DUMP_BEST = "dump_best";
93const std::string SWL_ADF_OUT_FILE = "adf_out";
94
95/// Short switch string for hdb file.
96const std::string SWS_HDB_FILE = "b";
97/// Long switch string for hdb file.
98const std::string SWL_HDB_FILE = "hdb";
99/// Short switch string for adf file.
100const std::string SWS_ADF_FILE = "a";
101/// Long switch string for adf file.
102const std::string SWL_ADF_FILE = "adf";
103/// Short switch string for idf file.
104const std::string SWS_IDF_FILE = "i";
105/// Long switch string for idf file.
106const std::string SWL_IDF_FILE = "idf";
107/// Short switch string of options to pass to compiler
108const std::string SWS_COMPILER_OPTIONS = "f";
109/// Long switch string of options to pass to compiler
110const std::string SWL_COMPILER_OPTIONS = "compiler_options";
111
112/**
113 * Constructor.
114 *
115 * @todo Use textgenerator in the help texts.
116 */
118 addOption(
121 "Design Space Explorer plugin to be used.",
123 addOption(
126 "Design Space Explorer plugin to print info about.",
128 addOption(
131 "Parameter to the explorer plugin in form 'name=value'.",
133 addOption(
136 "Path(s) of the test application(s) to be added into the DSDB.",
138 addOption(
141 "ID(s) of the test program path(s) to be removed from the DSDB.",
143 addOption(
146 "Starting point configuration ID in the DSDB.",
147 SWS_START_ID));
148 addOption(
151 "Print the summary of machine configurations in the DSDB"
152 "ordered by:\n"
153 " Ordering may be one of the following:\n"
154 " I ordering by configuration Id,\n"
155 " P ordering by application path,\n"
156 " C ordering by cycle count,\n"
157 " E ordering by energy estimate.",
159 addOption(
162 "Print the pareto sets of machine configurations in the DSDB "
163 "with certain value sets:\n"
164 " Value set may be one of the following:\n"
165 " C cycle counts and number of connections.",
167 addOption(
170 "Print the number of machine configurations in the DSDB.",
172 addOption(
175 "Write out the ADF and IDF files from the DSDB with given "
176 "configuration id.",
178 addOption(
181 "List the applications in the DSDB.",
183 addOption(
186 "List loadable plugins.",
188 addOption(
191 "HDB to use with exploration. If not given 'asic_130nm_1.5V.hdb' "
192 "will be used.",
193 SWS_HDB_FILE));
194 addOption(
197 "ADF to add into the DSDB.",
198 SWS_ADF_FILE));
199 addOption(
202 "IDF to add into the DSDB, needs also ADF.",
203 SWS_IDF_FILE));
204 addOption(
207 "Options to pass to the compiler.",
209 addOption(
212 "Set the ADF output filename (use in combination with -w "
213 "or --dump_best).", ""));
214 addOption(
217 "Dump the best configuration produced by the executed exploration "
218 "algorithm.", ""));
219}
220
221/**
222 * Destructor.
223 */
226
227/**
228 * Prints the version of the program.
229 */
230void
232 std::cout << DSCLI_TITLE << " version "
233 << Application::TCEVersionString() << std::endl;
234}
235
236/**
237 * Prints the help menu of the program.
238 *
239 * @todo Implement using ExplorerTextGenerator.
240 */
241void
243 printVersion();
244 std::cout << std::endl
245 << "Usage: explore [options] [dsdb_file]"
246 << std::endl
247 << "Example: -e InitialMachineExplorer "
248 << "-d data/newApplication "
249 << "-u bus_count=5 -u build_idf=true test.dsdb"
250 << std::endl
251 << std::endl
252 << "DSDB file is required always and new is created if not found."
253 << std::endl
254 << "Plugin name, DSDB and at least one application directory "
255 << std::endl
256 << "in the DSDB are required to run exploration, start "
257 << std::endl
258 << "configuration ID is optional."
259 << std::endl
260 << "Any number of parameters that are passed to the used plugin "
261 << "can be given."
262 << std::endl
263 << "Queries can be carried out to the DSDB."
264 << std::endl;
266}
267
268/**
269 * Returns the explorer plugin name.
270 *
271 * @return The explorer plugin name.
272 */
273std::string
277
278/**
279 * Returns the the plugin name which info is to be printed.
280 *
281 * @return The explorer plugin name which info is to be printed.
282 */
283std::string
287
288/**
289 * Returns the number of directories where test applications are located.
290 *
291 * @return The number of test directories.
292 */
293int
297
298/**
299 * By the given index, returns a test application directory name given as
300 * command line parameter.
301 *
302 * @param index The index.
303 * @return Test application directory path in the given index.
304 * @exception OutOfRange If the given index is negative or greater than
305 * the number of test directories given as parameter.
306 */
307std::string
309 if (index < 0 || index >= testApplicationDirectoryCount()) {
310 throw OutOfRange(__FILE__, __LINE__, __func__);
311 }
312
313 return findOption(SWL_TEST_DIR_ADD)->String(index + 1);
314}
315
316/**
317 * Returns the number of parameters given to the explorer plugin.
318 *
319 * @return The number of parameters.
320 */
321int
325
326/**
327 * By the given index, returns a parameter given to the explorer plugin.
328 *
329 * @param index The index.
330 * @return Parameter in the given index.
331 * @exception OutOfRange If the given index is negative or greater than
332 * the number of parameters given to the explorer plugin.
333 */
334std::string
336 if (index < 0 || index >= explorerPluginParameterCount()) {
337 throw OutOfRange(__FILE__, __LINE__, __func__);
338 }
339
340 return findOption(SWL_PLUGIN_PARAM)->String(index + 1);
341}
342
343/**
344 * Returns true if the number of configurations options is set.
345 *
346 * @return True if the option is set.
347 */
348bool
352
353/**
354 * Returns true if the number of configurations options is set.
355 *
356 * @return True if the option is set.
357 */
358bool
362
363/**
364 * Returns true if the number of configurations options is set.
365 *
366 * @return True if the option is set.
367 */
368std::string
372
373/**
374 * Returns the valuing type of the pareto set printing.
375 *
376 * @return Empty if pareto set not wanted.
377 */
378std::string
380 if (!findOption(SWL_PARETO_SET)->isDefined()) {
381 return "";
382 }
384}
385
386
387/**
388 * Returns true if writing out configuration(s) option is used.
389 *
390 * @return True if the option is defined.
391 */
392bool
396
397bool
401
402/**
403 * Returns the number of the write out configuration options given.
404 *
405 * @return Number of given write out options.
406 */
407int
411
412/**
413 * By the given index, returns the configuration id given as an option.
414 *
415 * @param index The index.
416 * @return Configuration id in the given index.
417 * @exception OutOfRange If the given index is negative or greater than
418 * the number configurations.
419 */
420RowID
422 if (index < 0 || index >= numberOfConfigurationsToWrite()) {
423 throw OutOfRange(__FILE__, __LINE__, __func__);
424 }
425
426 return findOption(SWL_CONFIGURATION_WRITE)->integer(index + 1);
427}
428
429/**
430 * Returns true if print applications option is used.
431 *
432 * @return True if the option is defined.
433 */
434bool
438
439/**
440 * Returns true if print applications option is used.
441 *
442 * @return True if the option is defined.
443 */
444bool
448
449/**
450 * Returns the number of test applications to be removed from the DSDB.
451 *
452 * @return The number of expendable applications.
453 */
454int
458
459/**
460 * By the given index, returns the application id given as an option to
461 * remove from DSDB.
462 *
463 * @param index The index.
464 * @return Application id in the given index.
465 * @exception OutOfRange If the given index is negative or greater than
466 * the number of expendable applications.
467 */
468RowID
470 if (index < 0 || index >= applicationIDToRemoveCount()) {
471 throw OutOfRange(__FILE__, __LINE__, __func__);
472 }
473
474 return findOption(SWL_TEST_DIR_RM)->integer(index + 1);
475}
476
477/**
478 * Returns true if at least one HDB file is given as an option.
479 *
480 * @return True if the option is defined.
481 */
482bool
486
487/**
488 * Returns the number of the HDB file options given.
489 *
490 * @return Number of given HDB file options.
491 */
492int
496
497/**
498 * By the given index, returns the HDB file given as an option.
499 *
500 * @param index The index.
501 * @return HDB file string from the given index.
502 * @exception OutOfRange If the given index is negative or greater than
503 * the number given HDB files.
504 */
505std::string
507 if (index < 0 || index >= hdbFileNameCount()) {
508 throw OutOfRange(__FILE__, __LINE__, __func__);
509 }
510
511 return findOption(SWL_HDB_FILE)->String(index + 1);
512}
513
514/**
515 * Returns the ID of the start configuration given as option.
516 *
517 * If start configuration option was not given returns zero.
518 *
519 * @return The ID of given start configuration or zero if the option was not
520 * used.
521 */
522RowID
524
525 if (findOption(SWL_START_ID)->isDefined()) {
527 } else {
528 return 0;
529 }
530}
531
532/**
533 * Returns true if an adf file is given as an option.
534 *
535 * @return True if an adf file is given as an option.
536 */
537bool
541
542bool
546
547/**
548 * Returns true if an idf file is given as an option.
549 *
550 * @return True if an idf file is given as an option.
551 */
552bool
556
557/**
558 * Returns the name of the adf file given as an option.
559 *
560 * Returns an empty string if no adf file was given.
561 *
562 * @return ADF file name.
563 */
564std::string
566 if (adfFile()) {
567 return findOption(SWL_ADF_FILE)->String(1);
568 } else {
569 return "";
570 }
571}
572
573std::string
575 if (adfOutFile()) {
577 } else {
578 return "";
579 }
580}
581
582/**
583 * Returns the name of the idf file given as an option.
584 *
585 * Returns an empty string if no adf file was given.
586 *
587 * @return IDF file name.
588 */
589std::string
591 if (idfFile()) {
592 return findOption(SWL_IDF_FILE)->String(1);
593 } else {
594 return "";
595 }
596}
597
598/**
599 * Returns true if a compiler options are given as an option.
600 *
601 * @return True if a compiler options are given as an option.
602 */
603bool
607
608/**
609 * Returns the string of compiler options given as an option.
610 *
611 * Returns an empty string if no compiler options were given.
612 *
613 * @return compiler options as a string.
614 */
615std::string
617
618 if (!compilerOptions()) return "";
619
620 TCEString optsString;
621 for (int i = 0; i < findOption(SWL_COMPILER_OPTIONS)->listSize(); ++i) {
622 optsString << findOption(SWL_COMPILER_OPTIONS)->String(i + 1) << " ";
623 }
624 return optsString;
625}
#define __func__
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
const std::string SWL_PLUGIN_INFO
Long switch string for giving an explorer plugin info.
const std::string SWS_CONFIGURATION_WRITE
Short switch string for writing out configuration files.
const std::string SWS_ADF_FILE
Short switch string for adf file.
const std::string SWS_HDB_FILE
Short switch string for hdb file.
const std::string SWL_TEST_DIR_ADD
Long switch string for adding a application directory.
const std::string SWL_ADF_OUT_FILE
const std::string SWS_PLUGIN_NAME
Short switch string for giving an explorer plugin to be used.
const std::string SWL_PLUGIN_PARAM
Long switch string for giving an explorer plugin to be used.
const std::string SWL_LIST_PLUGINS
Long switch string for listing loadable plugins.
const std::string SWL_IDF_FILE
Long switch string for idf file.
const std::string SWS_TEST_DIR_ADD
Short switch string for adding a application directory.
const std::string SWS_CONFIGURATION_COUNT
Short switch string for number of configurations flag.
const std::string DSCLI_TITLE
Design space explorer title.
const std::string SWL_CONFIGURATION_COUNT
Long switch string for number of configurations flag.
const std::string SWL_CONFIGURATION_WRITE
Long switch string for writing out configuration files.
const std::string SWS_LIST_APPS
Short switch string for listing loadable plugins.
const std::string SWS_CONFIGURATION_SUMMARY
Short switch string for number of configurations flag.
const std::string SWS_PARETO_SET
const std::string SWS_LIST_PLUGINS
Short switch string for listing application paths in the dsdb.
const std::string SWL_DUMP_BEST
const std::string SWL_ADF_FILE
Long switch string for adf file.
const std::string SWL_PLUGIN_NAME
Long switch string for giving an explorer plugin to be used.
const std::string SWL_PARETO_SET
Switch strings for the pareto set flag.
const std::string SWS_COMPILER_OPTIONS
Short switch string of options to pass to compiler.
const std::string SWL_COMPILER_OPTIONS
Long switch string of options to pass to compiler.
const std::string SWS_IDF_FILE
Short switch string for idf file.
const std::string SWS_PLUGIN_PARAM
Short switch string for giving an explorer plugin to be used.
const std::string SWL_HDB_FILE
Long switch string for hdb file.
const std::string SWL_START_ID
Long switch string for giving a start configuration id.
const std::string SWL_TEST_DIR_RM
Long switch string for removing application paths from dsdb.
const std::string SWS_START_ID
Short switch string for giving a start configuration id.
const std::string SWL_CONFIGURATION_SUMMARY
Long switch string for number of configurations flag.
const std::string SWL_LIST_APPS
Long switch string for listing application paths in the dsdb.
const std::string SWS_TEST_DIR_RM
Short switch string for removing application paths from dsdb.
const std::string SWS_PLUGIN_INFO
Short switch string for giving an explorer plugin info.
static std::string TCEVersionString()
virtual int integer(int index=0) const
virtual int listSize() const
virtual bool isFlagOn() const
virtual std::string String(int index=0) const
virtual void printHelp() const
CmdLineOptionParser * findOption(std::string name) const
void addOption(CmdLineOptionParser *opt)
std::string testApplicationDirectory(int index) const
virtual void printVersion() const
RowID applicationIDToRemove(int index) const
std::string summaryOrdering() const
std::string paretoSetValues() const
std::string explorerPlugin() const
std::string explorerPluginParameter(int index) const
std::string compilerOptionsString() const
RowID configurationToWrite(int index) const
std::string hdbFileName(int index) const
std::string adfOutFileName() const