Browse Source

Added ConversionHelper.h to single out the needed no-strict-aliasing target

Replaced a few "auto" variables as GCC4.7 fails to infer the correct type


Former-commit-id: 09a0c8dac9
tempestpy_adaptions
PBerger 11 years ago
parent
commit
edeedd2bed
  1. 11
      CMakeLists.txt
  2. 8
      src/adapters/GmmxxAdapter.h
  3. 2
      src/settings/Argument.h
  4. 10
      src/settings/ArgumentBuilder.h
  5. 2
      src/settings/Option.h
  6. 6
      src/settings/Settings.cpp
  7. 5
      src/utility/ConversionHelper.cpp
  8. 38
      src/utility/ConversionHelper.h

11
CMakeLists.txt

@ -85,6 +85,9 @@ endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}")
# Path to the no-strict-aliasing target
set(CONVERSIONHELPER_TARGET "${PROJECT_SOURCE_DIR}/src/utility/ConversionHelper.cpp")
if(CMAKE_COMPILER_IS_GNUCC)
message(STATUS "Using GCC")
# Set standard flags for GCC
@ -98,12 +101,17 @@ if(CMAKE_COMPILER_IS_GNUCC)
if (USE_POPCNT)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
endif(USE_POPCNT)
# Set the no-strict-aliasing target for GCC
set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
elseif(MSVC)
message(STATUS "Using MSVC")
# required for GMM to compile, ugly error directive in their code
add_definitions(/D_SCL_SECURE_NO_DEPRECATE)
# required as the PRCTL Parser bloats object files (COFF) beyond their maximum size (see http://msdn.microsoft.com/en-us/library/8578y171(v=vs.110).aspx)
add_definitions(/bigobj)
# MSVC does not do strict-aliasing, so no option needed
else(CLANG)
message(STATUS "Using CLANG")
# As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
@ -124,6 +132,9 @@ else(CLANG)
if (USE_POPCNT)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
endif(USE_POPCNT)
# Set the no-strict-aliasing target for Clang
set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
endif()
# Add the binary folder to the search path for include files so that we will find storm-config.h

8
src/adapters/GmmxxAdapter.h

@ -8,9 +8,11 @@
#ifndef STORM_ADAPTERS_GMMXXADAPTER_H_
#define STORM_ADAPTERS_GMMXXADAPTER_H_
#include "src/storage/SparseMatrix.h"
#include <new>
#include "src/storage/SparseMatrix.h"
#include "src/utility/ConversionHelper.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
@ -66,10 +68,10 @@ public:
// Move Row Indications
result->jc.~vectorType_ull_t(); // Call Destructor inplace
new (&result->jc) vectorType_ull_t(std::move(matrix.rowIndications));
new (&result->jc) vectorType_ull_t(std::move(storm::utility::ConversionHelper::toUnsignedLongLong(&matrix.rowIndications)));
// Move Columns Indications
result->ir.~vectorType_ull_t(); // Call Destructor inplace
new (&result->ir) vectorType_ull_t(std::move(matrix.columnIndications));
new (&result->ir) vectorType_ull_t(std::move(storm::utility::ConversionHelper::toUnsignedLongLong(&matrix.columnIndications)));
// And do the same thing with the actual values.
result->pr.~vectorType_T_t(); // Call Destructor inplace
new (&result->pr) vectorType_T_t(std::move(matrix.valueStorage));

2
src/settings/Argument.h

@ -57,7 +57,7 @@ namespace storm {
Argument(Argument const& other) : ArgumentBase(other.argumentName, other.argumentDescription, other.isOptional), argumentType(other.argumentType), defaultValue(other.defaultValue), hasDefaultValue(other.hasDefaultValue) {
this->userValidationFunction.reserve(other.userValidationFunction.size());
for (auto i = 0; i < other.userValidationFunction.size(); ++i) {
for (size_t i = 0; i < other.userValidationFunction.size(); ++i) {
this->userValidationFunction.push_back(userValidationFunction_t(other.userValidationFunction.at(i)));
}
}

10
src/settings/ArgumentBuilder.h

@ -176,19 +176,19 @@ namespace storm {
defaultValue_String(other.defaultValue_String), defaultValue_Integer(other.defaultValue_Integer), defaultValue_UnsignedInteger(other.defaultValue_UnsignedInteger), defaultValue_Double(other.defaultValue_Double), defaultValue_Boolean(other.defaultValue_Boolean),
hasDefaultValue(other.hasDefaultValue) {
// Copy all userFunctions
for (auto i = 0; i < userValidationFunction_String.size(); ++i) {
for (uint_fast64_t i = 0; i < userValidationFunction_String.size(); ++i) {
this->userValidationFunction_String.push_back(storm::settings::Argument<std::string>::userValidationFunction_t(other.userValidationFunction_String.at(i)));
}
for (auto i = 0; i < userValidationFunction_Integer.size(); ++i) {
for (uint_fast64_t i = 0; i < userValidationFunction_Integer.size(); ++i) {
this->userValidationFunction_Integer.push_back(storm::settings::Argument<int_fast64_t>::userValidationFunction_t(other.userValidationFunction_Integer.at(i)));
}
for (auto i = 0; i < userValidationFunction_UnsignedInteger.size(); ++i) {
for (uint_fast64_t i = 0; i < userValidationFunction_UnsignedInteger.size(); ++i) {
this->userValidationFunction_UnsignedInteger.push_back(storm::settings::Argument<uint_fast64_t>::userValidationFunction_t(other.userValidationFunction_UnsignedInteger.at(i)));
}
for (auto i = 0; i < userValidationFunction_Double.size(); ++i) {
for (uint_fast64_t i = 0; i < userValidationFunction_Double.size(); ++i) {
this->userValidationFunction_Double.push_back(storm::settings::Argument<double>::userValidationFunction_t(other.userValidationFunction_Double.at(i)));
}
for (auto i = 0; i < userValidationFunction_Boolean.size(); ++i) {
for (uint_fast64_t i = 0; i < userValidationFunction_Boolean.size(); ++i) {
this->userValidationFunction_Boolean.push_back(storm::settings::Argument<bool>::userValidationFunction_t(other.userValidationFunction_Boolean.at(i)));
}
}

2
src/settings/Option.h

@ -48,7 +48,7 @@ namespace storm {
: longName(longOptionName), shortName(shortOptionName), description(optionDescription), moduleName(moduleName), isRequired(isOptionRequired), hasBeenSet(false) {
// Copy all Arguments
this->arguments.reserve(optionArguments.size());
for (auto i = 0; i < optionArguments.size(); ++i) {
for (uint_fast64_t i = 0; i < optionArguments.size(); ++i) {
// Clone gives a deep copy
this->arguments.push_back(std::shared_ptr<ArgumentBase>(optionArguments.at(i).get()->clone()));
}

6
src/settings/Settings.cpp

@ -92,7 +92,7 @@ bool storm::settings::Settings::checkArgumentSyntaxForOption(std::string const&
return false;
}
for (auto i = 2; i < argvString.size(); ++i) {
for (size_t i = 2; i < argvString.size(); ++i) {
if (!isalpha(argvString.at(i))) {
return false;
}
@ -118,7 +118,7 @@ void storm::settings::Settings::parseCommandLine(int const argc, char const * co
bool optionActive = false;
std::string longOptionName;
std::vector<std::string> argCache;
for (auto i = 0; i <= stringArgv.size(); ++i) {
for (size_t i = 0; i <= stringArgv.size(); ++i) {
if (i == stringArgv.size()) {
if (optionActive) {
this->handleAssignment(longOptionName, argCache);
@ -170,7 +170,7 @@ void storm::settings::Settings::parseCommandLine(int const argc, char const * co
throw storm::exceptions::OptionParserException() << "Option \"" << it->second.get()->getLongName() << "\" is marked as required, but was not set!";
} else {
// Set defaults on optional values
for (auto i = 0; i < it->second.get()->getArgumentCount(); ++i) {
for (uint_fast64_t i = 0; i < it->second.get()->getArgumentCount(); ++i) {
if (it->second.get()->getArgument(i).getHasDefaultValue()) {
it->second.get()->getArgument(i).setFromDefaultValue();
}

5
src/utility/ConversionHelper.cpp

@ -0,0 +1,5 @@
#include "ConversionHelper.h"
std::vector<unsigned long long, std::allocator<unsigned long long>>* storm::utility::ConversionHelper::toUnsignedLongLong(std::vector<uint_fast64_t, std::allocator<uint_fast64_t>>* vectorPtr) {
return reinterpret_cast<std::vector<unsigned long long, std::allocator<unsigned long long>> *>(vectorPtr);
}

38
src/utility/ConversionHelper.h

@ -0,0 +1,38 @@
/*
* ConversionHelper.h
*
* Created on: 14.09.2013
* Author: Philipp Berger
*
* WARNING: This file REQUIRES -no-strict-aliasing!
*/
#ifndef STORM_UTILITY_CONVERSIONHELPER_H_
#define STORM_UTILITY_CONVERSIONHELPER_H_
#include <iostream>
#include <vector>
#include <cstdint>
static_assert(sizeof(unsigned long long) == sizeof(uint_fast64_t), "This program uses the GMM Backend and therefor requires unsigned long long and uint_fast64_t to be of the same size!");
namespace storm {
namespace utility {
class ConversionHelper {
public:
/*!
* Converts a pointer to a std::vector<uint_fast64_t> to std::vector<unsigned long long>
*/
static std::vector<unsigned long long, std::allocator<unsigned long long>>* toUnsignedLongLong(std::vector<uint_fast64_t, std::allocator<uint_fast64_t>>* vectorPtr);
private:
ConversionHelper() {}
ConversionHelper(ConversionHelper& other) {}
~ConversionHelper() {}
};
}
}
#endif // STORM_UTILITY_CONVERSIONHELPER_H_
Loading…
Cancel
Save