From ff332ab9aaf0d46431fbfaed0d6445085a1d6698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Tue, 9 Feb 2021 19:57:05 +0100 Subject: [PATCH] added CMake install process + rearrange data dir --- CMakeLists.txt | 6 +- README.md | 88 +++++++++++----------- R_lib/CMakeLists.txt | 1 + data/CMakeLists.txt | 1 + data/{chem_problems => }/SimComp2D.R | 0 data/{chem_problems => }/SimCompKtz.R | 0 data/{chem_problems => }/SimDol2D.R | 0 data/{chem_problems => }/SimDolKtz.R | 0 data/{chem_problems => }/mdl_quint_kin.dat | 0 src/CMakeLists.txt | 4 +- src/poet.cpp | 4 +- src/util/CMakeLists.txt | 4 +- 12 files changed, 58 insertions(+), 50 deletions(-) create mode 100644 R_lib/CMakeLists.txt create mode 100644 data/CMakeLists.txt rename data/{chem_problems => }/SimComp2D.R (100%) rename data/{chem_problems => }/SimCompKtz.R (100%) rename data/{chem_problems => }/SimDol2D.R (100%) rename data/{chem_problems => }/SimDolKtz.R (100%) rename data/{chem_problems => }/mdl_quint_kin.dat (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4362d9c9d..1419ee8ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ project(POET VERSION 0.1 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + list(APPEND CMAKE_MODULE_PATH "${POET_SOURCE_DIR}/CMake") # set(GCC_CXX_FLAGS "-D STRICT_R_HEADERS") @@ -18,4 +20,6 @@ find_package(R REQUIRED) find_package(Rcpp REQUIRED) find_package(RInside REQUIRED) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) +add_subdirectory(R_lib) +add_subdirectory(data) diff --git a/README.md b/README.md index 7fc629e5b..fa5f06feb 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ POET is a coupled reactive transport simulator implementing a parallel architecture and a fast distributed hash table. +## External Libraries + +We use external libraries: + +- **argh** - https://github.com/adishavit/argh (BSD license) + ## Installation ### Requirements @@ -65,29 +71,42 @@ $ R $ cd # Build process -$ cmake . -B build -$ cd build -$ make - -# move poet executable into POET project root -$ mv src/poet .. -$ cd .. +$ mkdir build && cd build +$ cmake -DCMAKE_INSTALL_PREFIX=/home//poet .. +$ make -j +$ make install ``` -The executable can now be found in the POET project root. +This will install a POET project structure into `/home//poet` which is +called hereinafter ``. With this version of POET I would not +recommend to install to hierarchies like `/usr/local/` etc. + +The correspondending directory tree would be look like this: + +``` sh +. +└── poet/ + ├── bin/ + │ └── poet + ├── data/ + │ └── SimDol2D.R + └── R_lib/ + ├── kin_r_library.R + └── parallel_r_library.R +``` + +The R libraries will be read in during runtime and the paths are hardcoded +absolute paths inside `poet.cpp`. So, if you consider to move `bin/poet` either +change paths of the R source files and recompile POET or also move `R_lib/*` +according to the binary. ## Running -Before POET is ready to run, a working directory must be created. In this -directory you should find the executable file, the R scripts -`/R_lib/kin_r_library.R` and `/R_lib/parallel_r_library.R` -and the simulation description e.g. `/data/chem_problems/SimDol2D.R`. - Run POET by `mpirun ./poet ` where: - **OPTIONS** - runtime parameters (explained below) - **SIMFILE** - simulation described as R script (currently supported: - `/data/chem_problems/SimDol2D.R`) + `/data/SimDol2D.R`) - **OUTPUT_DIRECTORY** - path, where all output of POET should be stored ### Runtime options @@ -123,29 +142,15 @@ Following values can be set: ### Example: Running from scratch -To continue the above example and start a simulation with `SimDol2D.R`: +We will continue the above example and start a simulation with `SimDol2D.R`, +which is the only simulation supported at this moment. To start the simulation +with 4 processes `cd` into your previously installed POET-dir +`/bin` and run: ``` sh -mkdir WORK_DIR -cp data/chem_problems/SimDol2D.R WORK_DIR -cp R_lib/kin_r_library.R R_lib/parallel_r_library.R WORK_DIR -mv poet WORK_DIR +mpirun -n 4 ./poet ../data/SimDol2D.R output ``` -The correspondending directory tree would be look like this: - -``` sh -. -└── WORK_DIR/ - ├── poet - ├── kin_r_library.R - ├── parallel_r_library.R - └── SimDol2D.R -``` - -Now, to start the simulation with 4 processes `cd` into `WORK_DIR` and run `mpirun -n 4 ./poet -SimDol2D.R output`. - After a finished simulation all data generated by POET will be found in the directory `output`. @@ -153,27 +158,22 @@ You might want to use the DHT to cache previously simulated data points and reuse them in further time-steps. Just append `-dht` to the options of POET to activate the usage of the DHT. The resulting call would look like this: -`mpirun -n 4 ./poet -dht SimDol2D.R output` +``` sh +mpirun -n 4 ./poet -dht SimDol2D.R output +``` ## Examples included (more to come) - **SimDol2D.R** - simple chemistry (Calcite/Dolomite) on a 50x50 2D grid, 20 time steps 2) -- **SimDolKtz.R** - simple chemistry (Calcite/Dolomite) on Ketzin grid (~650k +- ~~ **SimDolKtz.R** - simple chemistry (Calcite/Dolomite) on Ketzin grid (~650k elements), 20 time steps The flow snapshots are **NOT INCLUDED** in project -directory but must be provided separately - +directory but must be provided separately.~~ ## About the usage of MPI_Wtime() -Implemented time measurement functions uses `MPI_Wtime()`. Some important +Implemented time measurement functions use `MPI_Wtime()`. Some important informations from the OpenMPI Man Page: For example, on platforms that support it, the clock_gettime() function will be used to obtain a monotonic clock value with whatever precision is supported on that platform (e.g., nanoseconds). - -## External Libraries - -We use external libraries: - -- **argh** - https://github.com/adishavit/argh (BSD license) diff --git a/R_lib/CMakeLists.txt b/R_lib/CMakeLists.txt new file mode 100644 index 000000000..46896d88e --- /dev/null +++ b/R_lib/CMakeLists.txt @@ -0,0 +1 @@ +install(FILES kin_r_library.R parallel_r_library.R DESTINATION R_lib) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100644 index 000000000..59a6f9255 --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1 @@ +install(FILES SimDol2D.R DESTINATION data) diff --git a/data/chem_problems/SimComp2D.R b/data/SimComp2D.R similarity index 100% rename from data/chem_problems/SimComp2D.R rename to data/SimComp2D.R diff --git a/data/chem_problems/SimCompKtz.R b/data/SimCompKtz.R similarity index 100% rename from data/chem_problems/SimCompKtz.R rename to data/SimCompKtz.R diff --git a/data/chem_problems/SimDol2D.R b/data/SimDol2D.R similarity index 100% rename from data/chem_problems/SimDol2D.R rename to data/SimDol2D.R diff --git a/data/chem_problems/SimDolKtz.R b/data/SimDolKtz.R similarity index 100% rename from data/chem_problems/SimDolKtz.R rename to data/SimDolKtz.R diff --git a/data/chem_problems/mdl_quint_kin.dat b/data/mdl_quint_kin.dat similarity index 100% rename from data/chem_problems/mdl_quint_kin.dat rename to data/mdl_quint_kin.dat diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce3a89413..eccf6df95 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,9 +2,11 @@ configure_file(poet.h.in poet.h) add_executable(poet poet.cpp) target_include_directories(poet PUBLIC "${PROJECT_BINARY_DIR}/src") -target_link_libraries(poet PRIVATE POET_Model POET_Util MPI::MPI_C) +target_link_libraries(poet PUBLIC POET_Model POET_Util MPI::MPI_C) target_compile_definitions(poet PRIVATE OMPI_SKIP_MPICXX) +install(TARGETS poet DESTINATION bin) + add_subdirectory(DHT) add_subdirectory(model) add_subdirectory(util) diff --git a/src/poet.cpp b/src/poet.cpp index 8c57ca079..fb3648b42 100644 --- a/src/poet.cpp +++ b/src/poet.cpp @@ -69,8 +69,8 @@ int main(int argc, char *argv[]) { /*Loading Dependencies*/ std::string r_load_dependencies = "suppressMessages(library(Rmufits));" "suppressMessages(library(RedModRphree));" - "source('kin_r_library.R');" - "source('parallel_r_library.R');"; + "source('../R_lib/kin_r_library.R');" + "source('../R_lib/parallel_r_library.R');"; R.parseEvalQ(r_load_dependencies); SimParams params(world_rank, world_size); diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index fb6b282f5..13cac93e4 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,4 +1,4 @@ add_library(POET_Util RRuntime.cpp SimParams.cpp) target_include_directories(POET_Util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${R_INCLUDE_DIRS}) -target_link_libraries(POET_Util ${R_LIBRARIES}) -target_compile_definitions(POET_Util PUBLIC STRICT_R_HEADERS) \ No newline at end of file +target_link_libraries(POET_Util PUBLIC ${R_LIBRARIES}) +target_compile_definitions(POET_Util PUBLIC STRICT_R_HEADERS)