Skip to content

Commit

Permalink
- changed USE_THREADS to USE_PARALLEL_OUTPUT, because otherwise the b…
Browse files Browse the repository at this point in the history
…oost_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
  • Loading branch information
Marcus Walther committed Aug 20, 2014
1 parent b7085cf commit 49aaadd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
10 changes: 6 additions & 4 deletions SimulationRuntime/cpp/CMakeLists.txt
Expand Up @@ -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")
Expand All @@ -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/")
Expand Down Expand Up @@ -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)
Expand All @@ -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})
Expand Down
4 changes: 3 additions & 1 deletion SimulationRuntime/cpp/Core/Utils/extension/CMakeLists.txt
Expand Up @@ -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)
Expand Down
Expand Up @@ -5,7 +5,7 @@
#include <vector>
#endif

#ifdef USE_BOOST_THREAD
#ifdef USE_PARALLEL_OUTPUT
#include <boost/lockfree/queue.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
Expand All @@ -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)
Expand All @@ -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)
{
Expand Down Expand Up @@ -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<boost::tuple<value_type_v*, value_type_dv*, double>* >();
Expand Down Expand Up @@ -213,7 +213,7 @@ struct TextFileWriter
protected:
void writeThread()
{
#ifdef USE_BOOST_THREAD
#ifdef USE_PARALLEL_OUTPUT
boost::tuple<value_type_v*,value_type_dv*,double> *elem;
value_type_v *v_list;
value_type_dv *v2_list;
Expand Down Expand Up @@ -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<boost::tuple<value_type_v*, value_type_dv*, double>* > _queue;
boost::interprocess::interprocess_semaphore _mutex;
boost::interprocess::interprocess_semaphore _nempty;
Expand Down
6 changes: 5 additions & 1 deletion SimulationRuntime/cpp/Makefile
Expand Up @@ -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
Expand Down

0 comments on commit 49aaadd

Please sign in to comment.