From 3464ada1f14a330da587ccf1207715903685c2eb Mon Sep 17 00:00:00 2001 From: straile Date: Wed, 9 Oct 2024 17:33:12 +0200 Subject: [PATCH] Docs: Description of Buid flag --- README.md | 8 ++++++-- src/CMakeLists.txt | 1 + src/poet.cpp | 2 ++ src/poet.hpp.in | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16efc5895..23d873e9a 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,11 @@ following available options: slowed down significantly. Defaults to _OFF_. - **POET_PREPROCESS_BENCHS**=*boolean* - enables the preprocessing of predefined models/benchmarks. Defaults to *ON*. - +- **USE_AI_SURROGATE**=*boolean* - includes the functions of the AI + surrogate model. This relies on the presence of a Python environment + where Keras is installed. + + ### Example: Build from scratch Assuming that only the C/C++ compiler, MPI libraries, R runtime @@ -318,7 +322,7 @@ precision is supported on that platform (e.g., nanoseconds). The AI surrogate can be activated for any benchmark and is by default initiated as a sequential keras model with three hidden layer of depth 48, 96, 24 with relu activation and adam optimizer. All functions in -`ai_surrogate_model.R` can be overridden by adding custom definitions +`ai_surrogate_model_functions.R` can be overridden by adding custom definitions via an R file in the input script. This is done by adding the path to this file in the input script. Simply add the path as an element called `ai_surrogate_input_script` to the `chemistry_setup` list. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ccdcbb04..fc83682b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -119,6 +119,7 @@ target_compile_definitions(POETLib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX) file(READ "${PROJECT_SOURCE_DIR}/R_lib/kin_r_library.R" R_KIN_LIB ) file(READ "${PROJECT_SOURCE_DIR}/R_lib/init_r_lib.R" R_INIT_LIB) +file(READ "${PROJECT_SOURCE_DIR}/R_lib/ai_surrogate_model_functions.R" R_AI_SURROGATE_LIB) configure_file(poet.hpp.in poet.hpp @ONLY) diff --git a/src/poet.cpp b/src/poet.cpp index dee064f34..802f5896c 100644 --- a/src/poet.cpp +++ b/src/poet.cpp @@ -583,6 +583,8 @@ int main(int argc, char *argv[]) { chemistry.masterSetField(init_list.getInitialGrid()); if (run_params.use_ai_surrogate) { + // Load default function implementations + R.parseEvalQ(ai_surrogate_r_library); /* Use dht species for model input and output */ R["ai_surrogate_species"] = init_list.getChemistryInit().dht_species.getNames(); diff --git a/src/poet.hpp.in b/src/poet.hpp.in index a1d89fa14..961ce0121 100644 --- a/src/poet.hpp.in +++ b/src/poet.hpp.in @@ -36,6 +36,8 @@ static const char *poet_version = "@POET_VERSION@"; // using the Raw string literal to avoid escaping the quotes static const inline std::string kin_r_library = R"(@R_KIN_LIB@)"; static const inline std::string init_r_library = R"(@R_INIT_LIB@)"; +static const inline std::string ai_surrogate_r_library = + R"(@R_AI_SURROGATE_LIB@)"; static const inline std::string r_runtime_parameters = "mysetup"; struct RuntimeParameters {