Merge branch 'restructure' into 'v0.x'

Refactor build process

See merge request naaice/poet!20
This commit is contained in:
Max Lübke 2024-03-06 12:03:49 +01:00
commit 13e79382fe
38 changed files with 152 additions and 146 deletions

View File

@ -24,7 +24,6 @@ find_package(RRuntime REQUIRED)
add_subdirectory(src)
add_subdirectory(R_lib)
add_subdirectory(app)
add_subdirectory(bench)
# as tug will also pull in doctest as a dependency

View File

@ -1,7 +0,0 @@
configure_file(poet.h.in poet.h)
add_executable(poet poet.cpp)
target_include_directories(poet PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(poet PUBLIC poet_lib MPI::MPI_CXX)
install(TARGETS poet DESTINATION bin)

View File

@ -1,11 +0,0 @@
#ifndef POET_H
#define POET_H
#include "poet/ChemistryModule.hpp"
#include <Rcpp.h>
const char *poet_version = "@POET_VERSION@";
const char *CHEMISTRY_MODULE_NAME = "state_C";
#endif // POET_H

View File

@ -18,7 +18,9 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poet/SimParams.hpp"
#include "Grid.hpp"
#include "SimParams.hpp"
#include <RInside.h>
#include <Rcpp.h>
#include <algorithm>
@ -26,7 +28,6 @@
#include <cstdint>
#include <new>
#include <numeric>
#include <poet/Grid.hpp>
#include <stdexcept>
#include <string>
#include <vector>

View File

@ -21,7 +21,8 @@
#ifndef GRID_H
#define GRID_H
#include "poet/SimParams.hpp"
#include "SimParams.hpp"
#include <RInside.h>
#include <Rcpp.h>
#include <array>

View File

@ -20,11 +20,13 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poet/enums.hpp"
#include "SimParams.hpp"
#include "../Chemistry/enums.hpp"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <poet/SimParams.hpp>
#include <RInside.h>
#include <Rcpp.h>

View File

@ -21,6 +21,12 @@
#ifndef PARSER_H
#define PARSER_H
#include "../DataStructures/DataStructures.hpp"
#include "Macros.hpp"
#include "RInsidePOET.hpp"
#include "argh.hpp" // Argument handler https://github.com/adishavit/argh
#include <cstdint>
#include <optional>
#include <string>
@ -28,10 +34,6 @@
#include <unordered_map>
#include <vector>
#include "DataStructures.hpp"
#include "Macros.hpp"
#include "RInsidePOET.hpp"
#include "argh.hpp" // Argument handler https://github.com/adishavit/argh
#include <RInside.h>
#include <Rcpp.h>
// BSD-licenced

View File

@ -1,13 +1,27 @@
file(GLOB_RECURSE poet_lib_SRC
CONFIGURE_DEPENDS
"*.cpp" "*.c")
add_library(poetlib
Base/Grid.cpp
Base/SimParams.cpp
Chemistry/ChemistryModule.cpp
Chemistry/MasterFunctions.cpp
Chemistry/WorkerFunctions.cpp
Chemistry/SurrogateModels/DHT_Wrapper.cpp
Chemistry/SurrogateModels/DHT.c
Chemistry/SurrogateModels/HashFunctions.cpp
Chemistry/SurrogateModels/InterpolationModule.cpp
Chemistry/SurrogateModels/ProximityHashTable.cpp
DataStructures/Field.cpp
Transport/DiffusionModule.cpp
)
add_library(poet_lib ${poet_lib_SRC})
target_include_directories(poet_lib PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(poet_lib PUBLIC
MPI::MPI_CXX ${MATH_LIBRARY} RRuntime PhreeqcRM tug)
target_link_libraries(poetlib PUBLIC
MPI::MPI_C
${MATH_LIBRARY}
RRuntime
PhreeqcRM
tug
)
target_compile_definitions(poet_lib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX)
target_compile_definitions(poetlib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX)
mark_as_advanced(PHREEQCRM_BUILD_MPI PHREEQCRM_DISABLE_OPENMP)
set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE)
@ -15,11 +29,19 @@ set(PHREEQCRM_DISABLE_OPENMP ON CACHE BOOL "" FORCE)
option(POET_DHT_DEBUG "Build with DHT debug info" OFF)
if(POET_DHT_DEBUG)
target_compile_definitions(poet_lib PRIVATE DHT_STATISTICS)
target_compile_definitions(poetlib PRIVATE DHT_STATISTICS)
endif()
option(POET_PHT_ADDITIONAL_INFO "Enables additional information in the PHT" OFF)
if (POET_PHT_ADDITIONAL_INFO)
target_compile_definitions(poet_lib PRIVATE POET_PHT_ADD)
target_compile_definitions(poetlib PRIVATE POET_PHT_ADD)
endif()
configure_file(poet.hpp.in poet.hpp)
add_executable(poet poet.cpp)
target_link_libraries(poet PRIVATE poetlib MPI::MPI_C RRuntime)
target_include_directories(poet PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
install(TARGETS poet DESTINATION bin)

View File

@ -1,7 +1,9 @@
#include "poet/ChemistryModule.hpp"
#include "PhreeqcRM.h"
#include "poet/DHT_Wrapper.hpp"
#include "poet/Interpolation.hpp"
#include "ChemistryModule.hpp"
#include "SurrogateModels/DHT_Wrapper.hpp"
#include "SurrogateModels/Interpolation.hpp"
#include <PhreeqcRM.h>
#include <algorithm>
#include <cassert>

View File

@ -3,12 +3,13 @@
#ifndef CHEMISTRYMODULE_H_
#define CHEMISTRYMODULE_H_
#include "DHT_Wrapper.hpp"
#include "DataStructures.hpp"
#include "Interpolation.hpp"
#include "IrmResult.h"
#include "PhreeqcRM.h"
#include "SimParams.hpp"
#include "../Base/SimParams.hpp"
#include "../DataStructures/DataStructures.hpp"
#include "SurrogateModels/DHT_Wrapper.hpp"
#include "SurrogateModels/Interpolation.hpp"
#include <IrmResult.h>
#include <PhreeqcRM.h>
#include <array>
#include <cstddef>

View File

@ -1,5 +1,6 @@
#include "PhreeqcRM.h"
#include "poet/ChemistryModule.hpp"
#include "ChemistryModule.hpp"
#include <PhreeqcRM.h>
#include <algorithm>
#include <cstddef>

View File

@ -16,8 +16,9 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "DHT.h"
#include <mpi.h>
#include <poet/DHT.h>
#include <inttypes.h>
#include <math.h>

View File

@ -20,14 +20,7 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poet/DHT_Wrapper.hpp"
#include "poet/HashFunctions.hpp"
#include "poet/Interpolation.hpp"
#include "poet/LookupKey.hpp"
#include "poet/Rounding.hpp"
#include "poet/enums.hpp"
#include "poet/RInsidePOET.hpp"
#include "DHT_Wrapper.hpp"
#include <algorithm>
#include <cassert>
@ -150,10 +143,9 @@ void DHT_Wrapper::fillDHT(const WorkPackage &work_package) {
uint32_t proc, index;
auto &key = dht_results.keys[i];
const auto data =
(with_interp
? outputToInputAndRates(work_package.input[i],
work_package.output[i])
: work_package.output[i]);
(with_interp ? outputToInputAndRates(work_package.input[i],
work_package.output[i])
: work_package.output[i]);
// void *data = (void *)&(work_package[i * this->data_count]);
// fuzz data (round, logarithm etc.)

View File

@ -23,14 +23,14 @@
#ifndef DHT_WRAPPER_H
#define DHT_WRAPPER_H
#include "DataStructures.hpp"
#include "../../Base/RInsidePOET.hpp"
#include "../../Base/SimParams.hpp"
#include "../../DataStructures/DataStructures.hpp"
#include "../enums.hpp"
#include "HashFunctions.hpp"
#include "LookupKey.hpp"
#include "RInsidePOET.hpp"
#include "SimParams.hpp"
#include "enums.hpp"
#include "poet/HashFunctions.hpp"
#include "poet/LookupKey.hpp"
#include "poet/Rounding.hpp"
#include "Rounding.hpp"
#include <array>
#include <cstdint>
#include <limits>

View File

@ -24,7 +24,7 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poet/HashFunctions.hpp"
#include "HashFunctions.hpp"
#if defined(_MSC_VER)

View File

@ -3,13 +3,12 @@
#ifndef INTERPOLATION_H_
#define INTERPOLATION_H_
#include "DHT.h"
#include "../../Base/SimParams.hpp"
#include "../../DataStructures/DataStructures.hpp"
#include "DHT_Wrapper.hpp"
#include "DataStructures.hpp"
#include "LookupKey.hpp"
#include "poet/DHT_Wrapper.hpp"
#include "poet/Rounding.hpp"
#include "poet/SimParams.hpp"
#include "Rounding.hpp"
#include <cassert>
#include <iostream>
#include <list>
@ -17,11 +16,11 @@
#include <mpi.h>
#include <string>
#include <utility>
extern "C" {
#include "poet/DHT.h"
#include "DHT.h"
}
#include "poet/LookupKey.hpp"
#include <cstdint>
#include <functional>
#include <unordered_map>

View File

@ -1,13 +1,15 @@
// Time-stamp: "Last modified 2023-08-16 17:02:31 mluebke"
#include "Interpolation.hpp"
#include "poet/DHT_Wrapper.hpp"
#include "poet/DataStructures.hpp"
#include "poet/HashFunctions.hpp"
#include "poet/Interpolation.hpp"
#include "poet/LookupKey.hpp"
#include "poet/Rounding.hpp"
#include <Rcpp/vector/instantiation.h>
#include "../../DataStructures/DataStructures.hpp"
#include "DHT_Wrapper.hpp"
#include "HashFunctions.hpp"
#include "LookupKey.hpp"
#include "Rounding.hpp"
#include <Rcpp.h>
#include <Rinternals.h>
#include <algorithm>
#include <array>
#include <cassert>
@ -20,8 +22,9 @@
#include <string>
#include <utility>
#include <vector>
extern "C" {
#include "poet/DHT.h"
#include "DHT.h"
}
namespace poet {

View File

@ -3,7 +3,8 @@
#ifndef LOOKUPKEY_H_
#define LOOKUPKEY_H_
#include "poet/HashFunctions.hpp"
#include "HashFunctions.hpp"
#include <cstdint>
#include <cstring>
#include <vector>

View File

@ -1,10 +1,11 @@
// Time-stamp: "Last modified 2023-08-15 14:50:59 mluebke"
#include "Interpolation.hpp"
#include "DHT_Wrapper.hpp"
#include "HashFunctions.hpp"
#include "LookupKey.hpp"
#include "Rounding.hpp"
#include "poet/DHT_Wrapper.hpp"
#include "poet/HashFunctions.hpp"
#include "poet/Interpolation.hpp"
#include "poet/LookupKey.hpp"
#include "poet/Rounding.hpp"
#include <cassert>
#include <cstddef>
#include <cstdint>
@ -12,8 +13,9 @@
#include <memory>
#include <unordered_set>
#include <vector>
extern "C" {
#include "poet/DHT.h"
#include "DHT.h"
}
namespace poet {

View File

@ -1,8 +1,8 @@
// Time-stamp: "Last modified 2023-08-16 14:50:04 mluebke"
#include "poet/ChemistryModule.hpp"
#include "poet/DHT_Wrapper.hpp"
#include "poet/Interpolation.hpp"
#include "ChemistryModule.hpp"
#include "SurrogateModels/DHT_Wrapper.hpp"
#include "SurrogateModels/Interpolation.hpp"
#include <IrmResult.h>
#include <algorithm>

View File

@ -1,21 +0,0 @@
file(GLOB surrogate_models_SRC
CONFIGURE_DEPENDS
"*.cpp" "*.c")
find_library(MATH_LIBRARY m)
add_library(surrogate_models ${surrogate_models_SRC})
target_include_directories(surrogate_models PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(surrogate_models PUBLIC
MPI::MPI_CXX ${MATH_LIBRARY})
target_compile_definitions(surrogate_models PUBLIC OMPI_SKIP_MPICXX)
option(POET_PHT_ADDITIONAL_INFO "Enables additional information in the PHT" OFF)
if (POET_PHT_ADDITIONAL_INFO)
target_compile_definitions(surrogate_models PRIVATE POET_PHT_ADD)
endif()
if(POET_DHT_DEBUG)
target_compile_definitions(surrogate_models PRIVATE DHT_STATISTICS)
endif()

View File

@ -1,7 +1,7 @@
#ifndef DATASTRUCTURES_H_
#define DATASTRUCTURES_H_
#include "enums.hpp"
#include "../Chemistry/enums.hpp"
#include <Rcpp.h>
@ -13,6 +13,7 @@
#include <string>
#include <utility>
#include <vector>
namespace poet {
struct WorkPackage {

View File

@ -1,4 +1,5 @@
#include "poet/DataStructures.hpp"
#include "DataStructures.hpp"
#include <Rcpp.h>
#include <Rinternals.h>
#include <cstddef>

View File

@ -18,15 +18,15 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "DiffusionModule.hpp"
#include "../Base/Macros.hpp"
#include <tug/BoundaryCondition.hpp>
#include <tug/Diffusion.hpp>
#include <Rcpp.h>
#include <algorithm>
#include <cstdint>
#include <poet/DiffusionModule.hpp>
#include <poet/Grid.hpp>
#include <poet/Macros.hpp>
#include <poet/SimParams.hpp>
#include <tug/BoundaryCondition.hpp>
#include <tug/Diffusion.hpp>
#include <array>
#include <cassert>
@ -177,11 +177,11 @@ void DiffusionModule::simulate(double dt) {
t_field = field_2d;
sim_a_transport = MPI_Wtime();
transport_t += sim_a_transport - sim_b_transport;
std::cout << " done in "<< sim_a_transport - sim_b_transport << "sec" << std::endl;
std::cout << " done in " << sim_a_transport - sim_b_transport << "sec"
<< std::endl;
}
void DiffusionModule::end() {

View File

@ -21,16 +21,17 @@
#ifndef DIFFUSION_MODULE_H
#define DIFFUSION_MODULE_H
#include "DataStructures.hpp"
#include "SimParams.hpp"
#include "poet/SimParams.hpp"
#include "../Base/Grid.hpp"
#include "../Base/SimParams.hpp"
#include "../DataStructures/DataStructures.hpp"
#include <tug/BoundaryCondition.hpp>
#include <tug/Diffusion.hpp>
#include <array>
#include <cmath>
#include <cstdint>
#include <poet/Grid.hpp>
#include <string>
#include <tug/BoundaryCondition.hpp>
#include <tug/Diffusion.hpp>
#include <vector>
namespace poet {

View File

@ -18,15 +18,18 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "Base/Grid.hpp"
#include "Base/Macros.hpp"
#include "Base/RInsidePOET.hpp"
#include "Base/SimParams.hpp"
#include "Chemistry/ChemistryModule.hpp"
#include "Transport/DiffusionModule.hpp"
#include <poet.hpp>
#include <Rcpp.h>
#include <cstdint>
#include <cstdlib>
#include <poet/ChemistryModule.hpp>
#include <poet/DiffusionModule.hpp>
#include <poet/Grid.hpp>
#include <poet/Macros.hpp>
#include <poet/RInsidePOET.hpp>
#include <poet/SimParams.hpp>
#include <cstring>
#include <iostream>
@ -34,7 +37,6 @@
#include <vector>
#include <mpi.h>
#include <poet.h>
using namespace std;
using namespace poet;

8
src/poet.hpp.in Normal file
View File

@ -0,0 +1,8 @@
#ifndef POET_H
#define POET_H
static const char *poet_version = "@POET_VERSION@";
static const char *CHEMISTRY_MODULE_NAME = "state_C";
#endif // POET_H

View File

@ -3,7 +3,8 @@ file(GLOB test_SRC
"*.cpp" "*.c")
add_executable(testPOET ${test_SRC})
target_link_libraries(testPOET doctest poet_lib)
target_link_libraries(testPOET doctest poetlib)
target_include_directories(testPOET PRIVATE "${PROJECT_SOURCE_DIR}/src")
get_filename_component(TEST_RInsideSourceFile "RInsidePOET_funcs.R" REALPATH)
configure_file(testDataStructures.hpp.in testDataStructures.hpp)

View File

@ -5,11 +5,12 @@
#include <cstdint>
#include <doctest/doctest.h>
#include <iostream>
#include <poet/DataStructures.hpp>
#include <poet/RInsidePOET.hpp>
#include <string>
#include <vector>
#include <Base/RInsidePOET.hpp>
#include <DataStructures/DataStructures.hpp>
#include "testDataStructures.hpp"
using namespace poet;

View File

@ -1,11 +1,12 @@
#include <Rcpp.h>
#include <cstddef>
#include <doctest/doctest.h>
#include <poet/DataStructures.hpp>
#include <poet/RInsidePOET.hpp>
#include <utility>
#include <vector>
#include <Base/RInsidePOET.hpp>
#include <DataStructures/DataStructures.hpp>
#include "testDataStructures.hpp"
TEST_CASE("NamedVector") {

View File

@ -1,6 +1,6 @@
#include <doctest/doctest.h>
#include "poet/Rounding.hpp"
#include <Chemistry/SurrogateModels/Rounding.hpp>
TEST_CASE("Rounding") {
constexpr int signif = 3;