Browse Source

made jit model builder work on Ubuntu 16.04/g++

Former-commit-id: c9473408cc [formerly dca321927e]
Former-commit-id: 1bcd57f6da
tempestpy_adaptions
dehnert 8 years ago
parent
commit
392f56aab5
  1. 6
      CMakeLists.txt
  2. 7
      resources/3rdparty/include_cpptemplate.cmake
  3. 2
      src/builder/jit/Choice.h
  4. 15
      src/builder/jit/ExplicitJitJaniModelBuilder.cpp

6
CMakeLists.txt

@ -131,10 +131,10 @@ if(CMAKE_COMPILER_IS_GNUCC)
# Fix thanks to: https://github.com/freeorion/freeorion/issues/777 # Fix thanks to: https://github.com/freeorion/freeorion/issues/777
add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL) add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -flto -Wall -pedantic -fprefetch-loop-arrays -ffast-math -fno-finite-math-only -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "GCC version must be at least 5.0!")
message(FATAL_ERROR "GCC version must be at least 5.0.")
endif() endif()
# Turn on popcnt instruction if desired (yes by default) # Turn on popcnt instruction if desired (yes by default)
if (STORM_USE_POPCNT) if (STORM_USE_POPCNT)
@ -165,7 +165,7 @@ else(CLANG)
# As CLANG is not set as a variable, we need to set it in case we have not matched another compiler. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
set (CLANG ON) set (CLANG ON)
# Set standard flags for clang # Set standard flags for clang
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -ffast-math -fno-finite-math-only")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto -fprefetch-loop-arrays -ffast-math -fno-finite-math-only")
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)

7
resources/3rdparty/include_cpptemplate.cmake

@ -1,18 +1,19 @@
string(REPLACE " " ";" CMAKE_CXX_FLAGS_AS_LIST ${CMAKE_CXX_FLAGS})
ExternalProject_Add( ExternalProject_Add(
cpptemplate cpptemplate
DOWNLOAD_COMMAND "" DOWNLOAD_COMMAND ""
SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate
PREFIX ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate PREFIX ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND ${CMAKE_CXX_COMPILER} -std=c++14 -stdlib=libc++ -O3 -I${Boost_INCLUDE_DIRS} -I${STORM_3RDPARTY_SOURCE_DIR}/utf8_v2_3_4/source -shared ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp -o ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate/cpptemplate${DYNAMIC_EXT}
BUILD_COMMAND ${CMAKE_CXX_COMPILER} -c ${CMAKE_CXX_FLAGS_AS_LIST} -fPIC -I${Boost_INCLUDE_DIRS} -I${STORM_3RDPARTY_SOURCE_DIR}/utf8_v2_3_4/source ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp -o ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate/cpptemplate${STATIC_EXT}
INSTALL_COMMAND "" INSTALL_COMMAND ""
BUILD_IN_SOURCE 0 BUILD_IN_SOURCE 0
LOG_BUILD ON LOG_BUILD ON
) )
set(CPPTEMPLATE_INCLUDE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate) set(CPPTEMPLATE_INCLUDE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate)
set(CPPTEMPLATE_SHARED_LIBRARY ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate/cpptemplate${DYNAMIC_EXT})
list(APPEND STORM_LINK_LIBRARIES ${CPPTEMPLATE_SHARED_LIBRARY})
set(CPPTEMPLATE_STATIC_LIBRARY ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate/cpptemplate${STATIC_EXT})
list(APPEND STORM_LINK_LIBRARIES ${CPPTEMPLATE_STATIC_LIBRARY})
add_dependencies(resources cpptemplate) add_dependencies(resources cpptemplate)
message(STATUS "StoRM - Linking with cpptemplate") message(STATUS "StoRM - Linking with cpptemplate")

2
src/builder/jit/Choice.h

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <cstdint>
#include "src/builder/jit/Distribution.h" #include "src/builder/jit/Distribution.h"
namespace storm { namespace storm {

15
src/builder/jit/ExplicitJitJaniModelBuilder.cpp

@ -57,10 +57,10 @@ namespace storm {
compilerFlags = settings.getCompilerFlags(); compilerFlags = settings.getCompilerFlags();
} else { } else {
#ifdef LINUX #ifdef LINUX
compilerFlags = "-std=c++11 -fPIC -O3 -shared -funroll-loops -undefined dynamic_lookup";
compilerFlags = "-std=c++14 -fPIC -O3 -shared";
#endif #endif
#ifdef MACOSX #ifdef MACOSX
compilerFlags = "-std=c++11 -stdlib=libc++ -fPIC -O3 -shared -funroll-loops -undefined dynamic_lookup";
compilerFlags = "-std=c++14 -stdlib=libc++ -fPIC -O3 -shared -undefined dynamic_lookup";
#endif #endif
} }
if (settings.isBoostIncludeDirectorySet()) { if (settings.isBoostIncludeDirectorySet()) {
@ -184,8 +184,6 @@ namespace storm {
std::string problem = "Unable to compile empty program with C++ compiler. Is the C++ compiler '" + compiler + "' installed and working?"; std::string problem = "Unable to compile empty program with C++ compiler. Is the C++ compiler '" + compiler + "' installed and working?";
try { try {
std::string emptyProgram = R"( std::string emptyProgram = R"(
#include <cstdint>
int main() { int main() {
return 0; return 0;
} }
@ -252,7 +250,6 @@ namespace storm {
std::string problem = "Unable to compile program using boost. Is boosts's include directory '" + boostIncludeDirectory + "' set correctly?"; std::string problem = "Unable to compile program using boost. Is boosts's include directory '" + boostIncludeDirectory + "' set correctly?";
try { try {
std::string program = R"( std::string program = R"(
#include <cstdint>
#include <boost/optional.hpp> #include <boost/optional.hpp>
int main() { int main() {
@ -264,7 +261,7 @@ namespace storm {
boost::filesystem::path outputFile = temporaryFile; boost::filesystem::path outputFile = temporaryFile;
outputFile += ".out"; outputFile += ".out";
std::string outputFilename = boost::filesystem::absolute(outputFile).string(); std::string outputFilename = boost::filesystem::absolute(outputFile).string();
boost::optional<std::string> error = execute(compiler + " " + temporaryFilename + " -I" + boostIncludeDirectory + " -o " + outputFilename);
boost::optional<std::string> error = execute(compiler + " " + compilerFlags + " " + temporaryFilename + " -I" + boostIncludeDirectory + " -o " + outputFilename);
if (error) { if (error) {
result = false; result = false;
@ -286,7 +283,6 @@ namespace storm {
std::string problem = "Unable to compile program using boost's dll library. Is boosts's include directory '" + boostIncludeDirectory + "' pointing to a boost installation with version at least 1.61?"; std::string problem = "Unable to compile program using boost's dll library. Is boosts's include directory '" + boostIncludeDirectory + "' pointing to a boost installation with version at least 1.61?";
try { try {
std::string program = R"( std::string program = R"(
#include <cstdint>
#include <boost/dll/alias.hpp> #include <boost/dll/alias.hpp>
int main() { int main() {
@ -298,7 +294,7 @@ namespace storm {
boost::filesystem::path outputFile = temporaryFile; boost::filesystem::path outputFile = temporaryFile;
outputFile += ".out"; outputFile += ".out";
std::string outputFilename = boost::filesystem::absolute(outputFile).string(); std::string outputFilename = boost::filesystem::absolute(outputFile).string();
boost::optional<std::string> error = execute(compiler + " " + temporaryFilename + " -I" + boostIncludeDirectory + " -o " + outputFilename);
boost::optional<std::string> error = execute(compiler + " " + compilerFlags + " " + temporaryFilename + " -I" + boostIncludeDirectory + " -o " + outputFilename);
if (error) { if (error) {
result = false; result = false;
@ -320,7 +316,6 @@ namespace storm {
std::string problem = "Unable to compile program using Storm data structures. Is Storm's root directory '" + stormRoot + "' set correctly? Does the directory contain the source subtree under src/ ?"; std::string problem = "Unable to compile program using Storm data structures. Is Storm's root directory '" + stormRoot + "' set correctly? Does the directory contain the source subtree under src/ ?";
try { try {
std::string program = R"( std::string program = R"(
#include <cstdint>
#include "src/builder/RewardModelInformation.h" #include "src/builder/RewardModelInformation.h"
int main() { int main() {
@ -332,7 +327,7 @@ namespace storm {
boost::filesystem::path outputFile = temporaryFile; boost::filesystem::path outputFile = temporaryFile;
outputFile += ".out"; outputFile += ".out";
std::string outputFilename = boost::filesystem::absolute(outputFile).string(); std::string outputFilename = boost::filesystem::absolute(outputFile).string();
boost::optional<std::string> error = execute(compiler + " " + temporaryFilename + " -I" + stormRoot + " -o " + outputFilename);
boost::optional<std::string> error = execute(compiler + " " + compilerFlags + " " + temporaryFilename + " -I" + stormRoot + " -o " + outputFilename);
if (error) { if (error) {
result = false; result = false;

Loading…
Cancel
Save