dehnert 12 years ago
parent
commit
17e0e8165a
  1. 11
      src/parser/DeterministicSparseTransitionParser.cpp
  2. 2
      src/parser/DeterministicSparseTransitionParser.h
  3. 6
      src/parser/NondeterministicSparseTransitionParser.cpp
  4. 13
      src/parser/Parser.cpp
  5. 2
      src/storage/SparseMatrix.h
  6. 38
      src/storm.cpp
  7. 1
      src/utility/Settings.cpp

11
src/parser/DeterministicSparseTransitionParser.cpp

@ -44,7 +44,7 @@ namespace parser {
* @param buf Data to scan. Is expected to be some char array.
* @param maxnode Is set to highest id of all nodes.
*/
uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, int_fast64_t& maxnode, RewardMatrixInformationStruct* rewardMatrixInformation) {
uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, uint_fast64_t& maxnode, RewardMatrixInformationStruct* rewardMatrixInformation) {
bool isRewardMatrix = rewardMatrixInformation != nullptr;
uint_fast64_t nonZeroEntryCount = 0;
@ -58,7 +58,8 @@ uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, int_fast
/*
* Check all transitions for non-zero diagonal entries and deadlock states.
*/
int_fast64_t row, lastRow = -1, col;
int_fast64_t lastRow = -1;
uint_fast64_t row, col;
uint_fast64_t readTransitionCount = 0;
bool rowHadDiagonalEntry = false;
double val;
@ -71,12 +72,12 @@ uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, int_fast
col = checked_strtol(buf, &buf);
if (!isRewardMatrix) {
if (lastRow != row) {
if (lastRow != (int_fast64_t)row) {
if ((lastRow != -1) && (!rowHadDiagonalEntry)) {
++nonZeroEntryCount;
rowHadDiagonalEntry = true;
}
for (int_fast64_t skippedRow = lastRow + 1; skippedRow < row; ++skippedRow) {
for (uint_fast64_t skippedRow = (uint_fast64_t)(lastRow + 1); skippedRow < row; ++skippedRow) {
++nonZeroEntryCount;
}
lastRow = row;
@ -146,7 +147,7 @@ DeterministicSparseTransitionParser::DeterministicSparseTransitionParser(std::st
/*
* Perform first pass, i.e. count entries that are not zero.
*/
int_fast64_t maxStateId;
uint_fast64_t maxStateId;
uint_fast64_t nonZeroEntryCount = this->firstPass(file.data, maxStateId, rewardMatrixInformation);
LOG4CPLUS_INFO(logger, "First pass on " << filename << " shows " << nonZeroEntryCount << " NonZeros.");

2
src/parser/DeterministicSparseTransitionParser.h

@ -26,7 +26,7 @@ class DeterministicSparseTransitionParser : public Parser {
private:
std::shared_ptr<storm::storage::SparseMatrix<double>> matrix;
uint_fast64_t firstPass(char* buf, int_fast64_t &maxnode, RewardMatrixInformationStruct* rewardMatrixInformation);
uint_fast64_t firstPass(char* buf, uint_fast64_t &maxnode, RewardMatrixInformationStruct* rewardMatrixInformation);
};

6
src/parser/NondeterministicSparseTransitionParser.cpp

@ -91,7 +91,7 @@ uint_fast64_t NondeterministicSparseTransitionParser::firstPass(char* buf, uint_
// If we skipped some states, we need to reserve empty rows for all their nondeterministic
// choices.
for (uint_fast64_t i = lastsource + 1; i < source; ++i) {
for (int_fast64_t i = lastsource + 1; i < source; ++i) {
choices += ((*rewardMatrixInformation->nondeterministicChoiceIndices)[i + 1] - (*rewardMatrixInformation->nondeterministicChoiceIndices)[i]);
}
@ -221,7 +221,7 @@ NondeterministicSparseTransitionParser::NondeterministicSparseTransitionParser(s
}
if (isRewardFile) {
if (choices > rewardMatrixInformation->rowCount || maxnode + 1 > rewardMatrixInformation->columnCount) {
if (choices > rewardMatrixInformation->rowCount || (uint_fast64_t)(maxnode + 1) > rewardMatrixInformation->columnCount) {
LOG4CPLUS_ERROR(logger, "Reward matrix size exceeds transition matrix size.");
throw storm::exceptions::WrongFileFormatException() << "Reward matrix size exceeds transition matrix size.";
} else if (choices != rewardMatrixInformation->rowCount) {
@ -278,7 +278,7 @@ NondeterministicSparseTransitionParser::NondeterministicSparseTransitionParser(s
// If we skipped some states, we need to reserve empty rows for all their nondeterministic
// choices.
for (uint_fast64_t i = lastsource + 1; i < source; ++i) {
for (int_fast64_t i = lastsource + 1; i < source; ++i) {
curRow += ((*rewardMatrixInformation->nondeterministicChoiceIndices)[i + 1] - (*rewardMatrixInformation->nondeterministicChoiceIndices)[i]);
}

13
src/parser/Parser.cpp

@ -3,6 +3,7 @@
#include <iostream>
#include <cstring>
#include <string>
#include <cerrno>
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
@ -75,21 +76,21 @@ storm::parser::MappedFile::MappedFile(const char* filename) {
#else
if (stat64(filename, &(this->st)) != 0) {
#endif
LOG4CPLUS_ERROR(logger, "Error in stat(" << filename << ").");
throw exceptions::FileIoException("storm::parser::MappedFile Error in stat()");
LOG4CPLUS_ERROR(logger, "Error in stat(" << filename << "): " << std::strerror(errno));
throw exceptions::FileIoException() << "storm::parser::MappedFile Error in stat(): " << std::strerror(errno);
}
this->file = open(filename, O_RDONLY);
if (this->file < 0) {
LOG4CPLUS_ERROR(logger, "Error in open(" << filename << ").");
throw exceptions::FileIoException("storm::parser::MappedFile Error in open()");
LOG4CPLUS_ERROR(logger, "Error in open(" << filename << "): " << std::strerror(errno));
throw exceptions::FileIoException() << "storm::parser::MappedFile Error in open(): " << std::strerror(errno);
}
this->data = reinterpret_cast<char*>(mmap(NULL, this->st.st_size, PROT_READ, MAP_PRIVATE, this->file, 0));
if (this->data == reinterpret_cast<char*>(-1)) {
close(this->file);
LOG4CPLUS_ERROR(logger, "Error in mmap(" << filename << ").");
throw exceptions::FileIoException("storm::parser::MappedFile Error in mmap()");
LOG4CPLUS_ERROR(logger, "Error in mmap(" << filename << "): " << std::strerror(errno));
throw exceptions::FileIoException() << "storm::parser::MappedFile Error in mmap(): " << std::strerror(errno);
}
this->dataend = this->data + this->st.st_size;
#elif defined WINDOWS

2
src/storage/SparseMatrix.h

@ -770,7 +770,7 @@ public:
T constOne = storm::utility::constGetOne<T>();
// copy diagonal entries to other matrix
for (int i = 0; i < rowCount; ++i) {
for (unsigned int i = 0; i < rowCount; ++i) {
resultDinv->addNextValue(i, i, constOne / resultLU->getValue(i, i));
resultLU->getValue(i, i) = storm::utility::constGetZero<T>();
}

38
src/storm.cpp

@ -44,7 +44,7 @@ log4cplus::Logger logger;
*/
void initializeLogger() {
logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main"));
logger.setLogLevel(log4cplus::INFO_LOG_LEVEL);
logger.setLogLevel(log4cplus::WARN_LOG_LEVEL);
log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender());
consoleLogAppender->setName("mainConsoleAppender");
consoleLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%S} (%r ms) - %b:%L: %m%n")));
@ -111,18 +111,17 @@ bool parseOptions(const int argc, const char* argv[]) {
return false;
}
if (!s->isSet("verbose") && !s->isSet("logfile")) {
logger.setLogLevel(log4cplus::FATAL_LOG_LEVEL);
} else if (!s->isSet("verbose")) {
logger.removeAppender("mainConsoleAppender");
setUpFileLogging();
} else if (!s->isSet("logfile")) {
if (s->isSet("verbose")) {
logger.setLogLevel(log4cplus::INFO_LOG_LEVEL);
LOG4CPLUS_INFO(logger, "Enable verbose mode, log output gets printed to console.");
} else {
}
if (s->isSet("debug")) {
logger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL);
LOG4CPLUS_INFO(logger, "Enable very verbose mode, log output gets printed to console.");
}
if (s->isSet("logfile")) {
setUpFileLogging();
LOG4CPLUS_INFO(logger, "Enable verbose mode, log output gets printed to console.");
}
return true;
}
@ -459,20 +458,27 @@ void testChecking() {
* Main entry point.
*/
int main(const int argc, const char* argv[]) {
printHeader(argc, argv);
initializeLogger();
if (!parseOptions(argc, argv)) {
return 0;
}
setUp();
LOG4CPLUS_INFO(logger, "StoRM was invoked.");
printHeader(argc, argv);
try {
LOG4CPLUS_INFO(logger, "StoRM was invoked.");
testChecking();
testChecking();
cleanUp();
cleanUp();
LOG4CPLUS_INFO(logger, "StoRM quit.");
LOG4CPLUS_INFO(logger, "StoRM quit.");
return 0;
return 0;
} catch (std::exception& e) {
LOG4CPLUS_FATAL(logger, "An exception was thrown but not catched. All we can do now is show it to you and die in peace...");
LOG4CPLUS_FATAL(logger, "\t" << e.what());
}
return 1;
}

1
src/utility/Settings.cpp

@ -131,6 +131,7 @@ void Settings::initDescriptions() {
Settings::desc->add_options()
("help,h", "produce help message")
("verbose,v", "be verbose")
("debug", "be very verbose, intended for debugging")
("logfile,l", bpo::value<std::string>(), "name of the log file")
("configfile,c", bpo::value<std::string>(), "name of config file")
("test-prctl", bpo::value<std::string>(), "name of prctl file")

Loading…
Cancel
Save