Skip to content

Commit 267eb57

Browse files
authored
Add a modified version of Intel TBB to OpenModelica (#8685)
* Add a modified version of Intel TBB to OpenModelica - Intel's TBB is used for handling threading functionality for the automatic parallelization of simulation by OpenModelica, a.k.a., _parmodauto_ - It has been modified from its original version. The modified version uses the Boehm GC garbage collector of OpenModelica to perform the low lever thread primitive operations such as launching a new thread from the OS. This creates some complications but it is not optional. To work with simulation code generated by OpenModelica, any tool/library that creates threads has to be modified to go through the garbage collector. * Add a C++ json reader from nlohmann/json. - Taken from https://github.com/nlohmann/json. We should proably have this as part of our 3rdParty. Or any other C++ json parser. For now it is only needed by parmodauto.
1 parent c94e2eb commit 267eb57

File tree

10 files changed

+22154
-50
lines changed

10 files changed

+22154
-50
lines changed

OMCompiler/3rdParty

Submodule 3rdParty updated 1016 files

OMCompiler/Makefile.common

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ $(builddir_man)/man1/
5454
CMAKE := $(CMAKE) -DCMAKE_INSTALL_MESSAGE=LAZY
5555

5656
OMC_IPOPT_ROOT = 3rdParty/Ipopt-3.13.4
57+
OMC_TBB_ROOT = 3rdParty/tbb
58+
5759

5860
ifeq ("$(APP)",".app")
5961
BUILD_DIRS += $(builddir_app)
@@ -214,16 +216,32 @@ opencl_rt_clean:
214216
$(MAKE) -C SimulationRuntime/ParModelica/explicit/openclrt -f $(defaultMakefileTarget) clean OMBUILDDIR=$(OMBUILDDIR)
215217

216218

217-
parmodauto: boehm-gc
218-
ifeq ("$(ENABLE_PARMODAUTO)","yes")
219-
$(MAKE) -C $(OMC_TBB_ROOT)/build_cmake/ install_for_omc
219+
tbb: boehm-gc
220+
mkdir -p $(OMC_TBB_ROOT)/build_cmake
221+
cd $(OMC_TBB_ROOT)/build_cmake && $(CMAKE) .. \
222+
-G $(CMAKE_TARGET) \
223+
-DCMAKE_VERBOSE_MAKEFILE=ON \
224+
-DCMAKE_INSTALL_PREFIX="$(top_builddir)" \
225+
-DCMAKE_INSTALL_LIBDIR="$(builddir_lib_omc)" \
226+
-DCMAKE_INSTALL_INCLUDEDIR="$(builddir_inc)" \
227+
-DCMAKE_INSTALL_DATAROOTDIR="$(builddir_share)" \
228+
-DTBB_BUILD_TESTS=OFF \
229+
-DTBB_BUILD_SHARED=OFF \
230+
-DTBB_BUILD_TBBMALLOC=OFF \
231+
-DTBB_BUILD_TBBMALLOC_PROXY=OFF \
232+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
233+
$(MAKE) -C $(OMC_TBB_ROOT)/build_cmake install
234+
235+
tbb_clean:
236+
if test -f $(OMC_TBB_ROOT)/build_cmake/Makefile; then $(MAKE) -C $(OMC_TBB_ROOT)/build_cmake/ clean; fi
237+
rm -rf $(OMC_TBB_ROOT)/build_cmake
238+
239+
parmodauto: tbb
220240
$(MAKE) -C SimulationRuntime/ParModelica/auto/ -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR)
221-
endif
222241

223-
parmodauto_clean:
242+
parmodauto_clean: tbb_clean
224243
$(MAKE) -C SimulationRuntime/ParModelica/auto/ -f $(defaultMakefileTarget) clean OMBUILDDIR=$(OMBUILDDIR)
225244

226-
227245
breakprocess:
228246
(cd tools/debugging/ && time g++ BreakProcess.cpp -o BreakProcess -static-libgcc)
229247
(cd tools/debugging/ && cp BreakProcess.exe $(builddir_bin))

OMCompiler/Makefile.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ CMAKE_RPATH := CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)"
2929
CMAKE_TARGET = "Unix Makefiles"
3030
OPENCL = @OPENCL@
3131

32-
ENABLE_PARMODAUTO = @ENABLE_PARMODAUTO@
33-
OMC_TBB_ROOT = @OMC_TBB_ROOT@
34-
3532
defaultMakefileTarget = Makefile
3633
MAKEFILE_BOOT = LinkMain.makefile
3734
QMAKE=@QMAKE@

OMCompiler/SimulationRuntime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif()
1010
omc_add_subdirectory(ModelicaExternalC)
1111

1212
# omc_add_subdirectory(opc)
13-
# omc_add_subdirectory(ParModelica)
13+
omc_add_subdirectory(ParModelica)
1414
#ADD_SUBDIRECTORY(cpp)
1515
#ADD_SUBDIRECTORY(interactive)
1616

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/ParModelica)
23
omc_add_subdirectory(auto)
34

45

OMCompiler/SimulationRuntime/ParModelica/auto/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.14)
22

33
project(ParModelicaAuto)
4+
set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/auto)
45

56
find_package(Boost REQUIRED COMPONENTS graph chrono)
67

@@ -19,6 +20,11 @@ target_link_libraries(ParModelicaAuto PUBLIC omc::simrt::runtime)
1920
target_link_libraries(ParModelicaAuto PUBLIC omc::3rd::tbb)
2021
target_compile_definitions(ParModelicaAuto PRIVATE USE_FLOW_SCHEDULER)
2122

22-
add_executable(ParModelicaAutoTest)
23-
target_sources(ParModelicaAutoTest PRIVATE test_task_graph.cpp)
24-
target_link_libraries(ParModelicaAutoTest ParModelicaAuto ParModelicaAuto)
23+
# add_executable(ParModelicaAutoTest)
24+
# target_sources(ParModelicaAutoTest PRIVATE test_task_graph.cpp)
25+
# target_link_libraries(ParModelicaAutoTest PRIVATE ParModelicaAuto)
26+
27+
28+
install(TARGETS ParModelicaAuto)
29+
install(FILES om_pm_interface.hpp
30+
TYPE INCLUDE)

OMCompiler/SimulationRuntime/ParModelica/auto/Makefile.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ OPENMODELICA_LIB=$(TOP_BUILDDIR)/lib/@host_short@/omc
77
OPENMODELICA_BIN=$(TOP_BUILDDIR)/bin/
88

99
BOOST_HOME = @BOOSTHOME@
10-
OMC_TBB_ROOT = @OMC_TBB_ROOT@
11-
INCDIRS = -I"../../c" -I$(BOOST_HOME) -I$(OMC_TBB_ROOT)/include -I$(OMCOMPILER_ROOT)/3rdParty/gc/include
10+
INCDIRS = -I"../../c" -I$(BOOST_HOME) -I$(OMCOMPILER_ROOT)/3rdParty/tbb/include -I$(OMCOMPILER_ROOT)/3rdParty/gc/include
1211

1312
CC=@CC@
1413
CXX=@CXX@
@@ -20,9 +19,9 @@ OS_SRCS = pm_posix_timer.cpp
2019
EXEEXT=
2120
DLLEXT=.so
2221

23-
all: transfer
22+
all: install
2423

25-
transfer: libParModelicaAuto.a
24+
install: libParModelicaAuto.a
2625
$(COPY) libParModelicaAuto.a $(OPENMODELICA_LIB)
2726
mkdir -p $(PARMODELICAAUTO_INC)
2827
$(COPY) om_pm_interface.hpp $(PARMODELICAAUTO_INC)

OMCompiler/SimulationRuntime/ParModelica/auto/Makefile.omdev.mingw

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ PARMODELICAAUTO_INC=$(OPENMODELICA_INC)/ParModelica/auto/
66
OPENMODELICA_LIB=$(TOP_BUILDDIR)/lib/omc/
77
OPENMODELICA_BIN=$(TOP_BUILDDIR)/bin/
88

9-
OMC_TBB_ROOT = $(OMCOMPILER_ROOT)/3rdParty/tbb/
109
BOOST_HOME = $(OMDEV)/lib/3rdParty/boost-1_49
11-
INCDIRS = -I"../../c" -I$(BOOST_HOME) -I$(OMC_TBB_ROOT)/include -I$(OMCOMPILER_ROOT)/3rdParty/gc/include
10+
INCDIRS = -I"../../c" -I$(BOOST_HOME) -I$(OMCOMPILER_ROOT)/3rdParty/tbb/include -I$(OMCOMPILER_ROOT)/3rdParty/gc/include
1211

1312
CC=gcc
1413
CXX=g++
@@ -20,13 +19,13 @@ OS_SRCS = pm_win_timer.cpp
2019
EXEEXT=.exe
2120
DLLEXT=.dll
2221

23-
all: transfer
22+
all: install
2423

25-
transfer: libParModelicaAuto.a
24+
install: libParModelicaAuto.a
2625
$(COPY) libParModelicaAuto.a $(OPENMODELICA_LIB)
2726
mkdir -p $(PARMODELICAAUTO_INC)
2827
$(COPY) om_pm_interface.hpp $(PARMODELICAAUTO_INC)
29-
28+
3029
include Makefile.common
3130

3231

0 commit comments

Comments
 (0)