From 49aaadd883929131047a941059a8c939cd7162b3 Mon Sep 17 00:00:00 2001 From: Marcus Walther Date: Wed, 20 Aug 2014 11:45:56 +0000 Subject: [PATCH] - changed USE_THREADS to USE_PARALLEL_OUTPUT, because otherwise the boost_thread library can not be used by HPCOM - some updated for the hpcom testsuite git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21926 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- SimulationRuntime/cpp/CMakeLists.txt | 10 ++++++---- .../cpp/Core/Utils/extension/CMakeLists.txt | 4 +++- .../Core/DataExchange/Policies/TextfileWriter.h | 12 ++++++------ SimulationRuntime/cpp/Makefile | 6 +++++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/SimulationRuntime/cpp/CMakeLists.txt b/SimulationRuntime/cpp/CMakeLists.txt index 0a387855170..193c14af36f 100644 --- a/SimulationRuntime/cpp/CMakeLists.txt +++ b/SimulationRuntime/cpp/CMakeLists.txt @@ -24,7 +24,7 @@ ENDIF(NOT ANALYZATION_MODE) #set(CMAKE_VERBOSE_MAKEFILE ON) option(ANALYZATION_MODE "ANALYZATION_MODE" OFF) -option(USE_THREADS "USE_THREADS" OFF) +option(USE_THREADS "USE_PARALLEL_OUTPUT" OFF) IF(ANALYZATION_MODE) message(STATUS "Using analyzation mode") @@ -33,6 +33,10 @@ ELSE(ANALYZATION_MODE) message(STATUS "Analyzation mode disabled") ENDIF(ANALYZATION_MODE) +IF(USE_PARALLEL_OUTPUT) + add_definitions(-DUSE_PARALLEL_OUTPUT) +ENDIF(USE_PARALLEL_OUTPUT) + # on windows boost,blas,lapack and sundial solvers from omdev is used else the installed versions are used IF( WIN32 ) SET(ENV{BOOST_ROOT} $ENV{OMDEV}"/lib/3rdParty/boost-1_55/") @@ -133,8 +137,7 @@ ELSE(Boost_LOG_FOUND AND Boost_LOG_SETUP_FOUND) message(STATUS "Boost log disabled") ENDIF(Boost_LOG_FOUND AND Boost_LOG_SETUP_FOUND) -IF(USE_THREADS) -find_package(Boost 1.54 COMPONENTS thread atomic) +find_package(Boost COMPONENTS thread atomic) SET(Boost_LIBRARIES_TMP ${Boost_LIBRARIES_TMP} ${Boost_LIBRARIES}) find_package(Threads) IF(Boost_THREAD_FOUND AND Boost_ATOMIC_FOUND) @@ -143,7 +146,6 @@ IF(Boost_THREAD_FOUND AND Boost_ATOMIC_FOUND) ELSE(Boost_THREAD_FOUND AND Boost_ATOMIC_FOUND) message(STATUS "Boost thread disabled") ENDIF(Boost_THREAD_FOUND AND Boost_ATOMIC_FOUND) -ENDIF(USE_THREADS) find_package(Boost COMPONENTS filesystem system serialization program_options REQUIRED) SET(Boost_LIBRARIES_TMP ${Boost_LIBRARIES_TMP} ${Boost_LIBRARIES}) diff --git a/SimulationRuntime/cpp/Core/Utils/extension/CMakeLists.txt b/SimulationRuntime/cpp/Core/Utils/extension/CMakeLists.txt index 7ebe2bdc8c5..42ad64af2ed 100644 --- a/SimulationRuntime/cpp/Core/Utils/extension/CMakeLists.txt +++ b/SimulationRuntime/cpp/Core/Utils/extension/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required (VERSION 2.6) project(${ExtensionUtilitiesName}) -add_library(${ExtensionUtilitiesName} STATIC measure_time.cpp) +add_library(${ExtensionUtilitiesName} SHARED measure_time.cpp) +target_link_libraries (${ExtensionUtilitiesName} ${Boost_LIBRARIES}) + if (UNIX) set_target_properties(${ExtensionUtilitiesName} PROPERTIES COMPILE_FLAGS -fPIC) endif(UNIX) diff --git a/SimulationRuntime/cpp/Include/Core/DataExchange/Policies/TextfileWriter.h b/SimulationRuntime/cpp/Include/Core/DataExchange/Policies/TextfileWriter.h index 5027181672d..c8f8053e5d3 100644 --- a/SimulationRuntime/cpp/Include/Core/DataExchange/Policies/TextfileWriter.h +++ b/SimulationRuntime/cpp/Include/Core/DataExchange/Policies/TextfileWriter.h @@ -5,7 +5,7 @@ #include #endif -#ifdef USE_BOOST_THREAD +#ifdef USE_PARALLEL_OUTPUT #include #include #include @@ -32,7 +32,7 @@ struct TextFileWriter :_curser_position(0) ,_output_path(output_path) ,_file_name(file_name) - #ifdef USE_BOOST_THREAD + #ifdef USE_PARALLEL_OUTPUT ,_queue(0) ,_mutex(1) ,_nempty(10) @@ -45,7 +45,7 @@ struct TextFileWriter } ~TextFileWriter() { - #ifdef USE_BOOST_THREAD + #ifdef USE_PARALLEL_OUTPUT //wait until the writer-thread has written all results while(true) { @@ -164,7 +164,7 @@ struct TextFileWriter void write(value_type_v *v_list, value_type_dv *v2_list,double time) { - #ifdef USE_BOOST_THREAD + #ifdef USE_PARALLEL_OUTPUT if(!_threadRunning) { _queue = std::deque* >(); @@ -213,7 +213,7 @@ struct TextFileWriter protected: void writeThread() { - #ifdef USE_BOOST_THREAD + #ifdef USE_PARALLEL_OUTPUT boost::tuple *elem; value_type_v *v_list; value_type_dv *v2_list; @@ -260,7 +260,7 @@ struct TextFileWriter unsigned int _curser_position; ///< Controls current Curser-Position std::string _output_path; std::string _file_name; - #ifdef USE_BOOST_THREAD + #ifdef USE_PARALLEL_OUTPUT std::deque* > _queue; boost::interprocess::interprocess_semaphore _mutex; boost::interprocess::interprocess_semaphore _nempty; diff --git a/SimulationRuntime/cpp/Makefile b/SimulationRuntime/cpp/Makefile index 5899d73a50f..c5828cdc7c3 100644 --- a/SimulationRuntime/cpp/Makefile +++ b/SimulationRuntime/cpp/Makefile @@ -9,12 +9,16 @@ builddir_lib=$(top_builddir)/build/lib/omc builddir_inc=$(top_builddir)/build/include/omc ANALYZATION_MODE_COMMAND="-DANALYZATION_MODE=ON" +PARALLEL_OUTPUT_COMMAND="-DUSE_PARALLEL_OUTPUT=ON" runtimeCpp: clean ifneq ("$(ANALYZATION_MODE)","true") $(eval ANALYZATION_MODE_COMMAND="") endif - cd ./Build && echo "change to Build" && cmake $(ANALYZATION_MODE_COMMAND) -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH="$(builddir_build)" ../ +ifneq ("$(USE_PARALLEL_OUTPUT)","true") + $(eval PARALLEL_OUTPUT_COMMAND="") +endif + cd ./Build && echo "change to Build" && cmake $(ANALYZATION_MODE_COMMAND) $(PARALLEL_OUTPUT_COMMAND) -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH="$(builddir_build)" ../ $(MAKE) -C Build; install: runtimeCpp