Prepare project to transfer to svn + set poet version with help of

git/textfiles
This commit is contained in:
Max Lübke 2021-02-19 17:12:03 +01:00
parent a5f95c328d
commit 8b9450d3c0
7 changed files with 93 additions and 52 deletions

28
CMake/POET_Scripts.cmake Normal file
View File

@ -0,0 +1,28 @@
# Set or get version
macro(get_POET_version)
if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
find_program(GIT_EXECUTABLE git DOC "git executable")
mark_as_advanced(GIT_EXECUTABLE)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE POET_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --always
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE POET_GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT POET_GIT_BRANCH STREQUAL "master")
set(POET_VERSION "${POET_GIT_BRANCH}/${POET_GIT_VERSION}")
else()
set(POET_VERSION "${POET_GIT_VERSION}")
endif()
elseif(EXISTS ${PROJECT_SOURCE_DIR}/.svn)
file(STRINGS .gitversion POET_VERSION)
else()
set(POET_VERSION "0.1")
endif()
message(STATUS "Configuring POET version ${POET_VERSION}")
endmacro(get_POET_version)

View File

@ -1,7 +1,7 @@
# Version 3.9+ offers new MPI package variables
cmake_minimum_required(VERSION 3.9)
project(POET VERSION 0.1 LANGUAGES CXX C)
project(POET CXX C)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 14)
@ -9,10 +9,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include("CMake/POET_Scripts.cmake")
list(APPEND CMAKE_MODULE_PATH "${POET_SOURCE_DIR}/CMake")
# set(GCC_CXX_FLAGS "-D STRICT_R_HEADERS")
# add_definitions(${GCC_CXX_FLAGS})
# set(GCC_CXX_FLAGS "-D STRICT_R_HEADERS") add_definitions(${GCC_CXX_FLAGS})
find_package(MPI REQUIRED)

View File

@ -1,4 +1,3 @@
<!--
Time-stamp: "Last modified 2021-02-08 13:46:00 mluebke"
-->
@ -22,7 +21,7 @@ To compile POET you need several software to be installed:
- C/C++ compiler (tested with GCC)
- MPI-Implementation (tested with OpenMPI and MVAPICH)
- R language and environment
- R language and environment
- CMake 3.9+
If documantiation should be build during compilation `doxygen`and `graphviz`
@ -38,31 +37,43 @@ The following R libraries must then be installed:
### Compiling source code
The generation of makefiles is done with CMake. So, running
The generation of makefiles is done with CMake. If you obtain POET from a git repository you should be able to generate Makefiles by running
```
cmake . -B build
```sh
mkdir build && cd build
cmake ..
```
will create the directory `build`. `cd` into it and run `make` to start build
This will create the directory `build` and processes the CMake files and generate Makefiles from it. You're now able to run `make` to start build
process.
If everything went well you'll find the executable at `build/src/poet`.
If POET was obtained from the official SVN repository or the redmine at <https://redmine.cs.uni-potsdam.de/projects/poet> the branch or tag to be used have to be set via
During the generation of Makefiles, various options can be specified via `cmake
-D <option>=<value> [...]`. Currently there are the following available options:
```sh
mkdir build && cd build
cmake -D POET_SET_BRANCH="<BRANCH>" ..
```
- **DHT_Debug**=*boolean* - toggles the output of detailed statistics about DHT
usage (`cmake -D DHT_Debug=ON`). Defaults to *OFF*.
- **BUIL_DOC**=*boolean* - toggles the generation of documantiation during
compilation process. Defaults to *ON*.
where currently available branches/tags are:
- dev
If everything went well you'll find the executable at `build/src/poet`, but it is recommended to install the POET project structure to a desired `CMAKE_INSTALL_PREFIX` with `make install`.
During the generation of Makefiles, various options can be specified via `cmake -D <option>=<value> [...]`. Currently there are the following available options:
- **DHT_Debug**=_boolean_ - toggles the output of detailed statistics about DHT
usage (`cmake -D DHT_Debug=ON`). Defaults to _OFF_.
- **BUILD_DOC**=_boolean_ - toggles the generation of documantiation during
compilation process. Defaults to _ON_.
- _only from svn version:_ **POET_SET_BRANCH**=_string_ - set branch or tag whose code is used
### Example: Build from scratch
Assuming that only the C/C++ compiler, MPI libraries, R runtime environment and
CMake have been installed, POET can be installed as follows:
``` sh
```sh
# start R environment
$ R
@ -88,14 +99,14 @@ recommend to install to hierarchies like `/usr/local/` etc.
The correspondending directory tree would look like this:
``` sh
```sh
.
└── poet/
├── bin/
│ └── poet
├── data/
│ └── SimDol2D.R
├── docs/
├── docs/
│ └── html/
│ ├── index.html
│ └── ...
@ -130,17 +141,17 @@ Run POET by `mpirun ./poet <OPTIONS> <SIMFILE> <OUTPUT_DIRECTORY>` where:
The following parameters can be set:
| Option | Value | Description |
|-------------------------|--------------|-----------------------------------------------------------------|
| **-work-package-size=** | *1..n* | size of work packages (defaults to *5*) |
| **-ignore-result** | | disables store of simulation resuls |
| **-dht** | | enabling DHT usage (defaults to *OFF*) |
| **-dht-nolog** | | disabling applying of logarithm before rounding |
| **-dht-signif=** | *1..n* | set rounding to number of significant digits (defaults to *5*) |
| **-dht-strategy=** | *0-1* | change DHT strategy. **NOT IMPLEMENTED YET** (Defaults to *0*) |
| **-dht-size=** | *1-n* | size of DHT per process involved in byte (defaults to *1 GiB*) |
| **-dht-snaps=** | *0-2* | disable or enable storage of DHT snapshots |
| **-dht-file=** | `<SNAPSHOT>` | initializes DHT with the given snapshot file |
| Option | Value | Description |
| ----------------------- | ------------ | -------------------------------------------------------------- |
| **-work-package-size=** | _1..n_ | size of work packages (defaults to _5_) |
| **-ignore-result** | | disables store of simulation resuls |
| **-dht** | | enabling DHT usage (defaults to _OFF_) |
| **-dht-nolog** | | disabling applying of logarithm before rounding |
| **-dht-signif=** | _1..n_ | set rounding to number of significant digits (defaults to _5_) |
| **-dht-strategy=** | _0-1_ | change DHT strategy. **NOT IMPLEMENTED YET** (Defaults to _0_) |
| **-dht-size=** | _1-n_ | size of DHT per process involved in byte (defaults to _1 GiB_) |
| **-dht-snaps=** | _0-2_ | disable or enable storage of DHT snapshots |
| **-dht-file=** | `<SNAPSHOT>` | initializes DHT with the given snapshot file |
#### Additions to `dht-signif`
@ -148,26 +159,25 @@ Only used if no vector is given in setup file. For individual valuies per column
use R vector `signif_vector` in `SIMFILE`.
#### Additions to `dht-snaps`
Following values can be set:
- *0* = snapshots are disabled
- *1* = only stores snapshot at the end of the simulation with name
`<OUTPUT_DIRECTORY>.dht`
- *2* = stores snapshot at the end and after each iteration iteration
snapshot files are stored in <DIRECTORY>/iter<n>.dht
- _0_ = snapshots are disabled
- _1_ = only stores snapshot at the end of the simulation with name
`<OUTPUT_DIRECTORY>.dht`
- _2_ = stores snapshot at the end and after each iteration iteration
snapshot files are stored in `<DIRECTORY>/iter<n>.dht`
### Example: Running from scratch
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
`<POET_INSTALL_DIR>/bin` and run:
``` sh
```sh
mpirun -n 4 ./poet ../data/SimDol2D.R output
```
After a finished simulation all data generated by POET will be found in the
directory `output`.
@ -176,20 +186,21 @@ 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:
``` sh
```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)
time steps 2)
- ~~**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.~~ At this moment **SimDolKtz.R** is
not supported.
elements), 20 time steps The flow snapshots are **NOT INCLUDED** in project
directory but must be provided separately.~~ At this moment **SimDolKtz.R** is
not supported.
## About the usage of MPI_Wtime()
Implemented time measurement functions uses `MPI_Wtime()`. Some important
informations from the OpenMPI Man Page:

View File

@ -63,7 +63,7 @@ USE_MDFILE_AS_MAINPAGE = @PROJECT_SOURCE_DIR@/./README.md
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = @PROJECT_SOURCE_DIR@/src/util/argh.h
EXCLUDE = @SRC_CODE_DIR@/./util/argh.h
#---------------------------------------------------------------------------
# Project related configuration options

View File

@ -1,8 +1,13 @@
set(SRC_CODE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "directory indicating which source code version is used")
set(SRC_CODE_DIR
${CMAKE_CURRENT_SOURCE_DIR}
CACHE INTERNAL "directory indicating which source code version is used")
get_poet_version()
configure_file(poet.h.in poet.h)
add_executable(poet poet.cpp)
target_include_directories(poet PUBLIC "${PROJECT_CURRENT_BINARY_DIR}")
target_include_directories(poet PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(poet PUBLIC POET_Model POET_Util MPI::MPI_C)
target_compile_definitions(poet PRIVATE OMPI_SKIP_MPICXX)

View File

@ -58,9 +58,7 @@ int main(int argc, char *argv[]) {
}
if (world_rank == 0) {
cout << "Running POET in version " << poet_version_major << "."
<< poet_version_minor << endl
<< endl;
cout << "Running POET in version " << poet_version << endl << endl;
}
/* initialize R runtime */

View File

@ -1,7 +1,6 @@
#ifndef POET_H
#define POET_H
const int poet_version_major = @POET_VERSION_MAJOR@;
const int poet_version_minor = @POET_VERSION_MINOR@;
const char *poet_version = "@POET_VERSION@";
#endif // POET_H