OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
TestApplication Class Reference

#include <TestApplication.hh>

Collaboration diagram for TestApplication:
Collaboration graph

Public Types

typedef double Runtime
 
typedef int ClockCycles
 

Public Member Functions

 TestApplication (const std::string &testApplicationPath)
 
virtual ~TestApplication ()
 
std::vector< std::string > description () const
 
bool hasApplication () const
 
bool hasSetupSimulation () const
 
bool hasSimulateTTASim () const
 
bool hasCorrectOutput () const
 
bool hasVerifySimulation () const
 
bool hasCleanupSimulation () const
 
bool hasFunctionsOfInterest () const
 
bool isValid () const
 
const std::string applicationPath () const
 
void setupSimulation () const
 
std::istream * simulateTTASim () const
 
const std::string correctOutput () const
 
bool verifySimulation () const
 
void cleanupSimulation () const
 
ClockCycles cycleCount () const
 
Runtime maxRuntime () const
 
const std::vector< TCEString > & functionsOfInterest () const
 

Private Attributes

const std::string testApplicationPath_
 Path of the test application directory.
 
Runtime maxRuntime_
 Maximum runtime of the test appication in nano seconds.
 
std::vector< TCEStringfunctionsOfInterest_
 The names of the functions of interest (in terms of cycle count).
 

Static Private Attributes

static const std::string DESCRIPTION_FILE_NAME_ = "description.txt"
 File name of the description text for the application.
 
static const std::string APPLICATION_BASE_FILE_NAME_ = "program"
 Name of the sequential program file. Base name of the file that contains the fully linked program. The actual file name will be formed by appending either .bc or .ll, whichever is found first.
 
static const std::string SETUP_FILE_NAME_ = "setup.sh"
 Name of the file that contains setup script.
 
static const std::string SIMULATE_TTASIM_FILE_NAME_ = "simulate.ttasim"
 Name of the file that runs the simulation.
 
static const std::string CORRECT_OUTPUT_FILE_NAME_
 Name of the correct simulation output file.
 
static const std::string VERIFY_FILE_NAME_ = "verify.sh"
 Name of the verify script file.
 
static const std::string CLEANUP_FILE_NAME_ = "cleanup.sh"
 Name of the clean up file.
 
static const std::string FUNCTIONS_OF_INTEREST_FILE_NAME_
 Name of the file that has a comma separated list of functions of interest for the cycle count measurements in the given app. The exclusive profile of these functions will be used as the cycle count in evaluation.
 
static const std::string MAX_RUNTIME_ = "max_runtime"
 Name of the file that contains maximum runtime.
 
static const int MAX_LINE_LENGTH_ = 512
 Maximum line length in a file.
 

Detailed Description

Class for handling files in test application directory.

Definition at line 47 of file TestApplication.hh.

Member Typedef Documentation

◆ ClockCycles

Definition at line 50 of file TestApplication.hh.

◆ Runtime

typedef double TestApplication::Runtime

Definition at line 49 of file TestApplication.hh.

Constructor & Destructor Documentation

◆ TestApplication()

TestApplication::TestApplication ( const std::string &  testApplicationPath)

Constructor.

Parameters
testApplicationPathPath of the test application directory.

Definition at line 62 of file TestApplication.cc.

63 : testApplicationPath_(testApplicationPath), maxRuntime_(0) {
64 string maxRuntimeFile = testApplicationPath_
67 if (FileSystem::fileExists(maxRuntimeFile)) {
68 char line[MAX_LINE_LENGTH_];
69 FILE* file = fopen(maxRuntimeFile.c_str(), "r");
70 if (fgets(line, MAX_LINE_LENGTH_, file) == NULL)
71 abort();
72 try {
74 } catch (const NumberFormatException& exception) {
75 fclose(file);
76 throw IOException(
77 __FILE__, __LINE__, __func__, exception.errorMessage());
78 }
79 fclose(file);
80 }
81
83 std::ifstream f(
86 std::string str(
87 (std::istreambuf_iterator<char>(f)),
88 std::istreambuf_iterator<char>());
90 }
91}
#define __func__
static double toDouble(const T &source)
std::string errorMessage() const
Definition Exception.cc:123
static const std::string DIRECTORY_SEPARATOR
static bool fileExists(const std::string fileName)
std::vector< TCEString > split(const std::string &delim) const
Definition TCEString.cc:114
static const std::string MAX_RUNTIME_
Name of the file that contains maximum runtime.
const std::string testApplicationPath_
Path of the test application directory.
std::vector< TCEString > functionsOfInterest_
The names of the functions of interest (in terms of cycle count).
static const int MAX_LINE_LENGTH_
Maximum line length in a file.
bool hasFunctionsOfInterest() const
Runtime maxRuntime_
Maximum runtime of the test appication in nano seconds.
static const std::string FUNCTIONS_OF_INTEREST_FILE_NAME_
Name of the file that has a comma separated list of functions of interest for the cycle count measure...

References __func__, FileSystem::DIRECTORY_SEPARATOR, Exception::errorMessage(), FileSystem::fileExists(), FUNCTIONS_OF_INTEREST_FILE_NAME_, functionsOfInterest_, hasFunctionsOfInterest(), MAX_LINE_LENGTH_, MAX_RUNTIME_, maxRuntime_, TCEString::split(), testApplicationPath_, and Conversion::toDouble().

Here is the call graph for this function:

◆ ~TestApplication()

TestApplication::~TestApplication ( )
virtual

Destructor.

Definition at line 96 of file TestApplication.cc.

96 {
97}

Member Function Documentation

◆ applicationPath()

const std::string TestApplication::applicationPath ( ) const

Returns the application path in the test application directory.

If the file 'sequential_program' does not exists returns an empty string.

Returns
The path of the 'sequential_program' file.

Definition at line 335 of file TestApplication.cc.

335 {
336
337 if (hasApplication()) {
338 string applicationBCFile =
341 string applicationLLFile =
344
345 // prioritize the .ll file as it's more portable across
346 // LLVM versions than the bitcode
347 if (FileSystem::fileExists(applicationLLFile)) {
348 return applicationLLFile;
349 }
350 if (FileSystem::fileExists(applicationBCFile)) {
351 return applicationBCFile;
352 }
353
354 }
355 return "";
356}
static const std::string APPLICATION_BASE_FILE_NAME_
Name of the sequential program file. Base name of the file that contains the fully linked program....
bool hasApplication() const

References APPLICATION_BASE_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), hasApplication(), and testApplicationPath_.

Referenced by DesignSpaceExplorer::evaluate(), and SimpleICOptimizer::explore().

Here is the call graph for this function:

◆ cleanupSimulation()

void TestApplication::cleanupSimulation ( ) const

Cleans up the previous simulation run.

Uses 'cleanup.sh' script if it exists.

Definition at line 220 of file TestApplication.cc.

220 {
221 string cleanupFile =
224 if (FileSystem::fileExists(cleanupFile)) {
225 FileSystem::runShellCommand(cleanupFile);
226 }
227}
static bool runShellCommand(const std::string command)
static const std::string CLEANUP_FILE_NAME_
Name of the clean up file.

References CLEANUP_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), FileSystem::runShellCommand(), and testApplicationPath_.

Here is the call graph for this function:

◆ correctOutput()

const std::string TestApplication::correctOutput ( ) const

Returns the correct output from file 'correct_simulation_output' as string.

Returns
Correct output as string.

Definition at line 152 of file TestApplication.cc.

152 {
153
154 string correctOutputFile =
157 if (!FileSystem::fileExists(correctOutputFile)) {
158 return "";
159 }
160 std::string buf;
161 std::string line;
162 std::ifstream in(correctOutputFile.c_str());
163
164 if (std::getline(in,line)) {
165 buf += line;
166 }
167 while(std::getline(in,line)) {
168 buf += "\n";
169 buf += line;
170 }
171 return buf;
172}
static const std::string CORRECT_OUTPUT_FILE_NAME_
Name of the correct simulation output file.

References CORRECT_OUTPUT_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), and testApplicationPath_.

Referenced by DesignSpaceExplorer::evaluate().

Here is the call graph for this function:

◆ cycleCount()

ClockCycles TestApplication::cycleCount ( ) const

◆ description()

std::vector< std::string > TestApplication::description ( ) const

Returns the test application description.

The description is given in the description.txt file of the test application directory.

Returns
The test application description. Returns an empty vector if the desctription.txt file was not found.

Definition at line 109 of file TestApplication.cc.

109 {
110
111 std::vector<string> description;
112 string descriptionFile =
115 if (FileSystem::fileExists(descriptionFile)) {
116 char line[MAX_LINE_LENGTH_];
117 FILE* file = fopen(descriptionFile.c_str(), "r");
118 while (fgets(line, MAX_LINE_LENGTH_, file)) {
119 description.push_back(line);
120 }
121 fclose(file);
122 }
123 return description;
124}
static const std::string DESCRIPTION_FILE_NAME_
File name of the description text for the application.
std::vector< std::string > description() const

References description(), DESCRIPTION_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), MAX_LINE_LENGTH_, and testApplicationPath_.

Referenced by description().

Here is the call graph for this function:

◆ functionsOfInterest()

const std::vector< TCEString > & TestApplication::functionsOfInterest ( ) const
inline

Definition at line 78 of file TestApplication.hh.

78 {
80 }

References functionsOfInterest_.

Referenced by DesignSpaceExplorer::evaluate().

◆ hasApplication()

bool TestApplication::hasApplication ( ) const

Returns true if 'sequential_program' file is in the test application directory.

Definition at line 242 of file TestApplication.cc.

242 {
243
244 string applicationBCFile =
247 string applicationLLFile =
250
251 return FileSystem::fileExists(applicationBCFile) ||
252 FileSystem::fileExists(applicationLLFile);
253}

References APPLICATION_BASE_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), and testApplicationPath_.

Referenced by applicationPath(), and isValid().

Here is the call graph for this function:

◆ hasCleanupSimulation()

bool TestApplication::hasCleanupSimulation ( ) const

Returns true if 'cleanup.sh' file is in the test application directory.

Definition at line 308 of file TestApplication.cc.

308 {
309
310 string cleanupFile =
313 return FileSystem::fileExists(cleanupFile);
314}

References CLEANUP_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), and testApplicationPath_.

Here is the call graph for this function:

◆ hasCorrectOutput()

bool TestApplication::hasCorrectOutput ( ) const

Returns true if 'correct_simulation_output' file is in the test application directory.

Definition at line 284 of file TestApplication.cc.

284 {
285
286 string correctOutputFile =
289 return FileSystem::fileExists(correctOutputFile);
290}

References CORRECT_OUTPUT_FILE_NAME_, FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), and testApplicationPath_.

Referenced by DesignSpaceExplorer::evaluate(), and isValid().

Here is the call graph for this function:

◆ hasFunctionsOfInterest()

bool TestApplication::hasFunctionsOfInterest ( ) const
Returns
true if 'functions_of_interest' file is found in the application directory.

Definition at line 321 of file TestApplication.cc.

321 {
325}
static bool fileIsReadable(const std::string fileName)

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileIsReadable(), FUNCTIONS_OF_INTEREST_FILE_NAME_, and testApplicationPath_.

Referenced by DesignSpaceExplorer::evaluate(), and TestApplication().

Here is the call graph for this function:

◆ hasSetupSimulation()

bool TestApplication::hasSetupSimulation ( ) const

Returns true if 'setup.sh' file is in the test application directory.

Definition at line 259 of file TestApplication.cc.

259 {
260
261 string setupFile =
264 return FileSystem::fileExists(setupFile);
265}
static const std::string SETUP_FILE_NAME_
Name of the file that contains setup script.

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), SETUP_FILE_NAME_, and testApplicationPath_.

Here is the call graph for this function:

◆ hasSimulateTTASim()

bool TestApplication::hasSimulateTTASim ( ) const

Returns true if 'simulate.ttasim' file is in the test application directory.

Definition at line 271 of file TestApplication.cc.

271 {
272
273 string simulateFile =
276 return FileSystem::fileExists(simulateFile);
277}
static const std::string SIMULATE_TTASIM_FILE_NAME_
Name of the file that runs the simulation.

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), SIMULATE_TTASIM_FILE_NAME_, and testApplicationPath_.

Referenced by DesignSpaceExplorer::simulate(), and simulateTTASim().

Here is the call graph for this function:

◆ hasVerifySimulation()

bool TestApplication::hasVerifySimulation ( ) const

Returns true if 'verify.sh' file is in the test application directory.

Definition at line 296 of file TestApplication.cc.

296 {
297
298 string verifyFile =
301 return FileSystem::fileExists(verifyFile);
302}
static const std::string VERIFY_FILE_NAME_
Name of the verify script file.

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), testApplicationPath_, and VERIFY_FILE_NAME_.

Referenced by isValid().

Here is the call graph for this function:

◆ isValid()

bool TestApplication::isValid ( ) const
inline

Definition at line 64 of file TestApplication.hh.

64 {
65 return hasApplication() &&
67 }
bool hasCorrectOutput() const
bool hasVerifySimulation() const

References hasApplication(), hasCorrectOutput(), and hasVerifySimulation().

Referenced by main().

Here is the call graph for this function:

◆ maxRuntime()

TestApplication::Runtime TestApplication::maxRuntime ( ) const

Returns the maximum runtime that is set in file "max_runtime".

Definition at line 233 of file TestApplication.cc.

233 {
234 return maxRuntime_;
235}

References maxRuntime_.

Referenced by FrequencySweepExplorer::fastEnough(), and MinimizeMachine::minimizeMachine().

◆ setupSimulation()

void TestApplication::setupSimulation ( ) const

Set up the simulation run.

Uses 'setup.sh' to set up the simulation run.

Definition at line 180 of file TestApplication.cc.

180 {
181
182 string setupFile =
185 if (FileSystem::fileExists(setupFile)) {
186 FileSystem::runShellCommand(setupFile);
187 }
188}

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), FileSystem::runShellCommand(), SETUP_FILE_NAME_, and testApplicationPath_.

Referenced by DesignSpaceExplorer::simulate().

Here is the call graph for this function:

◆ simulateTTASim()

std::istream * TestApplication::simulateTTASim ( ) const

Returns a istream to 'simulate.ttasim' file.

Client takes responsibility of destroying the stream.

Returns
istream to 'simulate.ttasim' file.

Definition at line 198 of file TestApplication.cc.

198 {
199
200 std::ifstream* ifStream = new std::ifstream;
201 if (!hasSimulateTTASim()) {
202 return ifStream;
203 }
204 delete ifStream;
205 ifStream = NULL;
206
207 string simulateFile =
210 return new std::ifstream(simulateFile.c_str());
211}
bool hasSimulateTTASim() const

References FileSystem::DIRECTORY_SEPARATOR, hasSimulateTTASim(), SIMULATE_TTASIM_FILE_NAME_, and testApplicationPath_.

Referenced by DesignSpaceExplorer::simulate().

Here is the call graph for this function:

◆ verifySimulation()

bool TestApplication::verifySimulation ( ) const

Verifies the previous simulation run.

Uses 'verify.sh' to verify the previous simulation run.

Returns
True if the simulation result was verified as correct.

Definition at line 134 of file TestApplication.cc.

134 {
135
136 string verifyFile =
139
140 if (FileSystem::fileExists(verifyFile)) {
141 return FileSystem::runShellCommand(verifyFile);
142 }
143 return false;
144}

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileExists(), FileSystem::runShellCommand(), testApplicationPath_, and VERIFY_FILE_NAME_.

Here is the call graph for this function:

Member Data Documentation

◆ APPLICATION_BASE_FILE_NAME_

const string TestApplication::APPLICATION_BASE_FILE_NAME_ = "program"
staticprivate

Name of the sequential program file. Base name of the file that contains the fully linked program. The actual file name will be formed by appending either .bc or .ll, whichever is found first.

Definition at line 96 of file TestApplication.hh.

Referenced by applicationPath(), and hasApplication().

◆ CLEANUP_FILE_NAME_

const string TestApplication::CLEANUP_FILE_NAME_ = "cleanup.sh"
staticprivate

Name of the clean up file.

Definition at line 106 of file TestApplication.hh.

Referenced by cleanupSimulation(), and hasCleanupSimulation().

◆ CORRECT_OUTPUT_FILE_NAME_

const string TestApplication::CORRECT_OUTPUT_FILE_NAME_
staticprivate
Initial value:
=
"correct_simulation_output"

Name of the correct simulation output file.

Definition at line 102 of file TestApplication.hh.

Referenced by correctOutput(), and hasCorrectOutput().

◆ DESCRIPTION_FILE_NAME_

const string TestApplication::DESCRIPTION_FILE_NAME_ = "description.txt"
staticprivate

File name of the description text for the application.

Definition at line 91 of file TestApplication.hh.

Referenced by description().

◆ FUNCTIONS_OF_INTEREST_FILE_NAME_

const string TestApplication::FUNCTIONS_OF_INTEREST_FILE_NAME_
staticprivate
Initial value:
=
"functions_of_interest"

Name of the file that has a comma separated list of functions of interest for the cycle count measurements in the given app. The exclusive profile of these functions will be used as the cycle count in evaluation.

Definition at line 111 of file TestApplication.hh.

Referenced by hasFunctionsOfInterest(), and TestApplication().

◆ functionsOfInterest_

std::vector<TCEString> TestApplication::functionsOfInterest_
private

The names of the functions of interest (in terms of cycle count).

Definition at line 88 of file TestApplication.hh.

Referenced by functionsOfInterest(), and TestApplication().

◆ MAX_LINE_LENGTH_

const int TestApplication::MAX_LINE_LENGTH_ = 512
staticprivate

Maximum line length in a file.

Definition at line 115 of file TestApplication.hh.

Referenced by description(), and TestApplication().

◆ MAX_RUNTIME_

const string TestApplication::MAX_RUNTIME_ = "max_runtime"
staticprivate

Name of the file that contains maximum runtime.

Definition at line 113 of file TestApplication.hh.

Referenced by TestApplication().

◆ maxRuntime_

Runtime TestApplication::maxRuntime_
private

Maximum runtime of the test appication in nano seconds.

Definition at line 86 of file TestApplication.hh.

Referenced by maxRuntime(), and TestApplication().

◆ SETUP_FILE_NAME_

const string TestApplication::SETUP_FILE_NAME_ = "setup.sh"
staticprivate

Name of the file that contains setup script.

Definition at line 98 of file TestApplication.hh.

Referenced by hasSetupSimulation(), and setupSimulation().

◆ SIMULATE_TTASIM_FILE_NAME_

const string TestApplication::SIMULATE_TTASIM_FILE_NAME_ = "simulate.ttasim"
staticprivate

Name of the file that runs the simulation.

Definition at line 100 of file TestApplication.hh.

Referenced by hasSimulateTTASim(), and simulateTTASim().

◆ testApplicationPath_

const std::string TestApplication::testApplicationPath_
private

◆ VERIFY_FILE_NAME_

const string TestApplication::VERIFY_FILE_NAME_ = "verify.sh"
staticprivate

Name of the verify script file.

Definition at line 104 of file TestApplication.hh.

Referenced by hasVerifySimulation(), and verifySimulation().


The documentation for this class was generated from the following files: