From d7efb362a269c884d3f47bdb50165618cee41e84 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 20 Sep 2018 10:58:27 +0200 Subject: [PATCH] make the build of flow fully parallelizable so far, the actual specializations of the simulator were compiled into the `libopmsimulators` library and the build of the glue code (`flow.cpp`) thus needed to be deferred until the library was fully built. Since the compilation of the glue code requires a full property hierarchy for handling command line parameters, this arrangement significantly increases the build time for systems with a sufficient number of parallel build processes. ("sufficient" here means 8 or more threads, i.e., a quadcore system with hyperthreading is sufficient provided that it has enough main memory.) the new approach is not to include these objects in `libopmsimulators`, but to directly deal with them in the `flow` binary. this allows all of them and the glue code to be compiled in parallel. compilation time on my machine before this change: ``` > touch ../opm/autodiff/BlackoilModelEbos.hpp; time make -j32 flow 2> /dev/null Scanning dependencies of target opmsimulators [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_gasoil.cpp.o [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_oilwater.cpp.o [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_blackoil.cpp.o [ 2%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_solvent.cpp.o [ 4%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_polymer.cpp.o [ 6%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_energy.cpp.o [ 6%] Building CXX object CMakeFiles/opmsimulators.dir/opm/simulators/flow_ebos_oilwater_polymer.cpp.o [ 6%] Linking CXX static library lib/libopmsimulators.a [ 97%] Built target opmsimulators Scanning dependencies of target flow [100%] Building CXX object CMakeFiles/flow.dir/examples/flow.cpp.o [100%] Linking CXX executable bin/flow [100%] Built target flow real 1m45.692s user 8m47.195s sys 0m11.533s ``` after: ``` > touch ../opm/autodiff/BlackoilModelEbos.hpp; time make -j32 flow 2> /dev/null [ 91%] Built target opmsimulators Scanning dependencies of target flow [ 93%] Building CXX object CMakeFiles/flow.dir/flow/flow.cpp.o [ 95%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_gasoil.cpp.o [ 97%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_oilwater_polymer.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_polymer.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_oilwater.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_solvent.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_blackoil.cpp.o [100%] Building CXX object CMakeFiles/flow.dir/flow/flow_ebos_energy.cpp.o [100%] Linking CXX executable bin/flow [100%] Built target flow real 1m21.597s user 8m49.476s sys 0m10.973s ``` (this corresponds to a ~20% reduction of the time spend on waiting for the compiler.) --- CMakeLists.txt | 19 ++++++++++++++++-- CMakeLists_files.cmake | 20 ------------------- {examples => flow}/flow.cpp | 14 ++++++------- .../flow_ebos_blackoil.cpp | 2 +- .../flow_ebos_blackoil.hpp | 0 {opm/simulators => flow}/flow_ebos_energy.cpp | 2 +- {opm/simulators => flow}/flow_ebos_energy.hpp | 0 {opm/simulators => flow}/flow_ebos_gasoil.cpp | 2 +- {opm/simulators => flow}/flow_ebos_gasoil.hpp | 0 .../flow_ebos_oilwater.cpp | 2 +- .../flow_ebos_oilwater.hpp | 0 .../flow_ebos_oilwater_polymer.cpp | 2 +- .../flow_ebos_oilwater_polymer.hpp | 0 .../simulators => flow}/flow_ebos_polymer.cpp | 2 +- .../simulators => flow}/flow_ebos_polymer.hpp | 0 .../simulators => flow}/flow_ebos_solvent.cpp | 2 +- .../simulators => flow}/flow_ebos_solvent.hpp | 0 17 files changed, 31 insertions(+), 36 deletions(-) rename {examples => flow}/flow.cpp (96%) rename {opm/simulators => flow}/flow_ebos_blackoil.cpp (97%) rename {opm/simulators => flow}/flow_ebos_blackoil.hpp (100%) rename {opm/simulators => flow}/flow_ebos_energy.cpp (97%) rename {opm/simulators => flow}/flow_ebos_energy.hpp (100%) rename {opm/simulators => flow}/flow_ebos_gasoil.cpp (98%) rename {opm/simulators => flow}/flow_ebos_gasoil.hpp (100%) rename {opm/simulators => flow}/flow_ebos_oilwater.cpp (98%) rename {opm/simulators => flow}/flow_ebos_oilwater.hpp (100%) rename {opm/simulators => flow}/flow_ebos_oilwater_polymer.cpp (98%) rename {opm/simulators => flow}/flow_ebos_oilwater_polymer.hpp (100%) rename {opm/simulators => flow}/flow_ebos_polymer.cpp (97%) rename {opm/simulators => flow}/flow_ebos_polymer.hpp (100%) rename {opm/simulators => flow}/flow_ebos_solvent.cpp (97%) rename {opm/simulators => flow}/flow_ebos_solvent.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3c142a4..d5cec9f51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,11 +113,26 @@ if (NOT EIGEN3_FOUND) add_dependencies (opmsimulators Eigen3) endif (NOT EIGEN3_FOUND) - - if (HAVE_OPM_TESTS) include (${CMAKE_CURRENT_SOURCE_DIR}/compareECLFiles.cmake) endif() +opm_add_test(flow + ONLY_COMPILE + ALWAYS_ENABLE + DEPENDS "opmsimulators" + LIBRARIES "opmsimulators" + SOURCES + flow/flow.cpp + flow/flow_ebos_blackoil.cpp + flow/flow_ebos_gasoil.cpp + flow/flow_ebos_oilwater.cpp + flow/flow_ebos_polymer.cpp + flow/flow_ebos_solvent.cpp + flow/flow_ebos_energy.cpp + flow/flow_ebos_oilwater_polymer.cpp) +install(TARGETS flow DESTINATION bin) + include(OpmBashCompletion) opm_add_bash_completion(flow) + diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index a2e81cff1..00b15b060 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -23,17 +23,6 @@ # originally generated with the command: # find opm -name '*.c*' -printf '\t%p\n' | sort list (APPEND MAIN_SOURCE_FILES - # place the flow_ebos_*.cpp files on top of the list because they - # take the longest to compile, and compiling them first speeds up - # parallel builds because it allows the jobserver to do better scheduling - opm/simulators/flow_ebos_blackoil.cpp - opm/simulators/flow_ebos_gasoil.cpp - opm/simulators/flow_ebos_oilwater.cpp - opm/simulators/flow_ebos_polymer.cpp - opm/simulators/flow_ebos_solvent.cpp - opm/simulators/flow_ebos_energy.cpp - opm/simulators/flow_ebos_oilwater_polymer.cpp - opm/autodiff/Compat.cpp opm/autodiff/ExtractParallelGridInformationToISTL.cpp opm/autodiff/NewtonIterationBlackoilCPR.cpp @@ -226,7 +215,6 @@ list (APPEND EXAMPLE_SOURCE_FILES examples/flow_legacy.cpp examples/flow_reorder.cpp examples/flow_sequential.cpp - examples/flow.cpp examples/sim_2p_incomp_ad.cpp examples/sim_2p_comp_reorder.cpp examples/sim_simple.cpp @@ -252,7 +240,6 @@ list (APPEND PROGRAM_SOURCE_FILES examples/sim_2p_incomp.cpp examples/sim_2p_incomp_ad.cpp examples/sim_2p_comp_reorder.cpp - examples/flow.cpp examples/flow_legacy.cpp examples/flow_reorder.cpp examples/flow_sequential.cpp @@ -447,13 +434,6 @@ list (APPEND PUBLIC_HEADER_FILES opm/polymer/TransportSolverTwophaseCompressiblePolymer.hpp opm/polymer/Point2D.hpp opm/polymer/TransportSolverTwophasePolymer.hpp - opm/simulators/flow_ebos_blackoil.hpp - opm/simulators/flow_ebos_gasoil.hpp - opm/simulators/flow_ebos_oilwater.hpp - opm/simulators/flow_ebos_polymer.hpp - opm/simulators/flow_ebos_solvent.hpp - opm/simulators/flow_ebos_energy.hpp - opm/simulators/flow_ebos_oilwater_polymer.hpp opm/simulators/ensureDirectoryExists.hpp opm/simulators/ParallelFileMerger.hpp opm/simulators/SimulatorCompressibleTwophase.hpp diff --git a/examples/flow.cpp b/flow/flow.cpp similarity index 96% rename from examples/flow.cpp rename to flow/flow.cpp index 980bf62bd..fe32fa013 100644 --- a/examples/flow.cpp +++ b/flow/flow.cpp @@ -20,13 +20,13 @@ */ #include "config.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/opm/simulators/flow_ebos_blackoil.cpp b/flow/flow_ebos_blackoil.cpp similarity index 97% rename from opm/simulators/flow_ebos_blackoil.cpp rename to flow/flow_ebos_blackoil.cpp index fa70826e6..c872be8bf 100644 --- a/opm/simulators/flow_ebos_blackoil.cpp +++ b/flow/flow_ebos_blackoil.cpp @@ -19,7 +19,7 @@ // Define making clear that the simulator supports AMG #define FLOW_SUPPORT_AMG 1 -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_blackoil.hpp b/flow/flow_ebos_blackoil.hpp similarity index 100% rename from opm/simulators/flow_ebos_blackoil.hpp rename to flow/flow_ebos_blackoil.hpp diff --git a/opm/simulators/flow_ebos_energy.cpp b/flow/flow_ebos_energy.cpp similarity index 97% rename from opm/simulators/flow_ebos_energy.cpp rename to flow/flow_ebos_energy.cpp index 9dab2415e..df7b283e9 100644 --- a/opm/simulators/flow_ebos_energy.cpp +++ b/flow/flow_ebos_energy.cpp @@ -16,7 +16,7 @@ */ #include "config.h" -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_energy.hpp b/flow/flow_ebos_energy.hpp similarity index 100% rename from opm/simulators/flow_ebos_energy.hpp rename to flow/flow_ebos_energy.hpp diff --git a/opm/simulators/flow_ebos_gasoil.cpp b/flow/flow_ebos_gasoil.cpp similarity index 98% rename from opm/simulators/flow_ebos_gasoil.cpp rename to flow/flow_ebos_gasoil.cpp index 3b0defb32..c52f5a1f4 100644 --- a/opm/simulators/flow_ebos_gasoil.cpp +++ b/flow/flow_ebos_gasoil.cpp @@ -19,7 +19,7 @@ // Define making clear that the simulator supports AMG #define FLOW_SUPPORT_AMG 1 -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_gasoil.hpp b/flow/flow_ebos_gasoil.hpp similarity index 100% rename from opm/simulators/flow_ebos_gasoil.hpp rename to flow/flow_ebos_gasoil.hpp diff --git a/opm/simulators/flow_ebos_oilwater.cpp b/flow/flow_ebos_oilwater.cpp similarity index 98% rename from opm/simulators/flow_ebos_oilwater.cpp rename to flow/flow_ebos_oilwater.cpp index e12d3ebfe..0bf0bb6ad 100644 --- a/opm/simulators/flow_ebos_oilwater.cpp +++ b/flow/flow_ebos_oilwater.cpp @@ -19,7 +19,7 @@ // Define making clear that the simulator supports AMG #define FLOW_SUPPORT_AMG 1 -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_oilwater.hpp b/flow/flow_ebos_oilwater.hpp similarity index 100% rename from opm/simulators/flow_ebos_oilwater.hpp rename to flow/flow_ebos_oilwater.hpp diff --git a/opm/simulators/flow_ebos_oilwater_polymer.cpp b/flow/flow_ebos_oilwater_polymer.cpp similarity index 98% rename from opm/simulators/flow_ebos_oilwater_polymer.cpp rename to flow/flow_ebos_oilwater_polymer.cpp index 71f0d77f7..13e6c7a79 100644 --- a/opm/simulators/flow_ebos_oilwater_polymer.cpp +++ b/flow/flow_ebos_oilwater_polymer.cpp @@ -19,7 +19,7 @@ // Define making clear that the simulator supports AMG #define FLOW_SUPPORT_AMG 1 -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_oilwater_polymer.hpp b/flow/flow_ebos_oilwater_polymer.hpp similarity index 100% rename from opm/simulators/flow_ebos_oilwater_polymer.hpp rename to flow/flow_ebos_oilwater_polymer.hpp diff --git a/opm/simulators/flow_ebos_polymer.cpp b/flow/flow_ebos_polymer.cpp similarity index 97% rename from opm/simulators/flow_ebos_polymer.cpp rename to flow/flow_ebos_polymer.cpp index 395221e3c..6cf2c140f 100644 --- a/opm/simulators/flow_ebos_polymer.cpp +++ b/flow/flow_ebos_polymer.cpp @@ -16,7 +16,7 @@ */ #include "config.h" -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_polymer.hpp b/flow/flow_ebos_polymer.hpp similarity index 100% rename from opm/simulators/flow_ebos_polymer.hpp rename to flow/flow_ebos_polymer.hpp diff --git a/opm/simulators/flow_ebos_solvent.cpp b/flow/flow_ebos_solvent.cpp similarity index 97% rename from opm/simulators/flow_ebos_solvent.cpp rename to flow/flow_ebos_solvent.cpp index c3504d113..d70db6ad3 100644 --- a/opm/simulators/flow_ebos_solvent.cpp +++ b/flow/flow_ebos_solvent.cpp @@ -16,7 +16,7 @@ */ #include "config.h" -#include +#include #include #include diff --git a/opm/simulators/flow_ebos_solvent.hpp b/flow/flow_ebos_solvent.hpp similarity index 100% rename from opm/simulators/flow_ebos_solvent.hpp rename to flow/flow_ebos_solvent.hpp