From ed8124ec65ba551afb061fabb50eb4859e651c2f Mon Sep 17 00:00:00 2001 From: Seung Hyun Kim Date: Fri, 12 Jul 2024 00:22:18 -0500 Subject: [PATCH] files: add system configuration --- backend/src/Configuration/.gitignore | 2 + backend/src/Configuration/Kernels.hpp | 128 +++++++++++++++++ backend/src/Configuration/Logging.hpp | 25 ++++ backend/src/Configuration/Parallel.hpp | 57 ++++++++ backend/src/Configuration/README.md | 14 ++ backend/src/Configuration/Systems.hpp | 130 ++++++++++++++++++ .../CosseratRods/Components/helpers/Types.hpp | 1 + 7 files changed, 357 insertions(+) create mode 100644 backend/src/Configuration/.gitignore create mode 100644 backend/src/Configuration/Kernels.hpp create mode 100644 backend/src/Configuration/Logging.hpp create mode 100644 backend/src/Configuration/Parallel.hpp create mode 100644 backend/src/Configuration/README.md create mode 100644 backend/src/Configuration/Systems.hpp diff --git a/backend/src/Configuration/.gitignore b/backend/src/Configuration/.gitignore new file mode 100644 index 00000000..b058cd4c --- /dev/null +++ b/backend/src/Configuration/.gitignore @@ -0,0 +1,2 @@ +#Parallel.hpp +#Profiling.hpp diff --git a/backend/src/Configuration/Kernels.hpp b/backend/src/Configuration/Kernels.hpp new file mode 100644 index 00000000..87d7683e --- /dev/null +++ b/backend/src/Configuration/Kernels.hpp @@ -0,0 +1,128 @@ +#pragma once + +//****************************************************************************** +/*!\brief Selection of the default backend for quadrature + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_QUADRATURE_BACKEND +#define ELASTICA_COSSERATROD_LIB_QUADRATURE_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for difference + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_DIFFERENCE_BACKEND +#define ELASTICA_COSSERATROD_LIB_DIFFERENCE_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for matvec + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_MATVEC_BACKEND +#define ELASTICA_COSSERATROD_LIB_MATVEC_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for vector-scalar division + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_VECSCALARDIV_BACKEND +#define ELASTICA_COSSERATROD_LIB_VECSCALARDIV_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for vector-scalar multiplication + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_VECSCALARMULT_BACKEND +#define ELASTICA_COSSERATROD_LIB_VECSCALARMULT_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for cross products + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_CROSSPRODUCT_BACKEND +#define ELASTICA_COSSERATROD_LIB_CROSSPRODUCT_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for inv rotate divide + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * - blaze + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_INV_ROTATE_DIVIDE_BACKEND +#define ELASTICA_COSSERATROD_LIB_INV_ROTATE_DIVIDE_BACKEND simd +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default backend for SO3+= + * \ingroup default_config + * + * The following execution policies are available: + * - scalar + * - simd + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_COSSERATROD_LIB_SO3_ADDITION_BACKEND +#define ELASTICA_COSSERATROD_LIB_SO3_ADDITION_BACKEND simd +#endif +//****************************************************************************** diff --git a/backend/src/Configuration/Logging.hpp b/backend/src/Configuration/Logging.hpp new file mode 100644 index 00000000..4ed8a55a --- /dev/null +++ b/backend/src/Configuration/Logging.hpp @@ -0,0 +1,25 @@ +#pragma once + +//****************************************************************************** +/*!\brief Selection of the level of logging. + * \ingroup config logging + * + * This macro selects the level of logging, to effectively filter out logs that + * are not deemed necessary. Any logs below the level chosen are not reported + * while a logging level comprises all higher logging levels. For instance, + * if the set ELASTICA_LOG_LEVEL() is `info`, then logs marked with `debug` are + * not printed, but all errors and warning are also printed to the log file(s). + * The following log levels can be chosen: + * + * - ::elastica::logging::inactive + * - ::elastica::logging::error + * - ::elastica::logging::warning + * - ::elastica::logging::info + * - ::elastica::logging::debug + * + * \see elastica::logging::LoggingLevel + */ +#ifndef ELASTICA_LOG_LEVEL +#define ELASTICA_LOG_LEVEL ::elastica::logging::info +#endif +//****************************************************************************** diff --git a/backend/src/Configuration/Parallel.hpp b/backend/src/Configuration/Parallel.hpp new file mode 100644 index 00000000..ff150a03 --- /dev/null +++ b/backend/src/Configuration/Parallel.hpp @@ -0,0 +1,57 @@ +#pragma once + +//****************************************************************************** +/*!\brief Compilation switch for the (de-)activation of the shared-memory + * parallelization + * \ingroup config parallel + * + * This compilation switch enables/disables the shared-memory parallelization. + * In case the switch is set to 1 (i.e. in case the shared-memory + * parallelization is enabled), \elastica is allowed to execute operations in + * parallel. In case the switch is set to 0 (i.e. parallelization + * is disabled), \elastica is restricted from executing operations in parallel. + * + * Possible settings for the shared-memory parallelization switch: + * - Deactivated: \b 0 + * - Activated : \b 1 (default) + * + * \note It is possible to (de-)activate the shared-memory parallelization via + * command line or by defining this symbol manually before including any + * Blaze header file: + * + * \example + * \code + * g++ ... -DELASTICA_USE_SHARED_MEMORY_PARALLELIZATION=1 ... + * \endcode + * + * \code + * #define ELASTICA_USE_SHARED_MEMORY_PARALLELIZATION 1 + * #include + * \endcode + * + */ +// #ifndef ELASTICA_USE_SHARED_MEMORY_PARALLELIZATION +// #define ELASTICA_USE_SHARED_MEMORY_PARALLELIZATION @ELASTICA_SMP@ +// #endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Compile time hint for number of threads to be used in an elastica + * application + * \ingroup parallel + */ +constexpr std::size_t elastica_threads_hint() { return 2UL; } +//****************************************************************************** + +//****************************************************************************** +/*!\brief Environment variable to set a hint for the number of threads used + * \ingroup parallel + * + * The macro defines the environment variable used to provide hint for the + * number of threads to set for Elastica++ applications. + * For user applications (i.e. when writing your own main-file), this variable + * does not factor in : rather the user can set the number of threads they want + * using the specific parallelism library they employed. + */ +#define ENV_ELASTICA_NUM_THREADS "ELASTICA_NUM_THREADS" + //**************************************************************************** diff --git a/backend/src/Configuration/README.md b/backend/src/Configuration/README.md new file mode 100644 index 00000000..6ec94d0d --- /dev/null +++ b/backend/src/Configuration/README.md @@ -0,0 +1,14 @@ +## Configuration + +Contains all default-settings to make a default `Elastica++` simulation. The type customizations are defined as macros (as +opposed to type-aliases) to avoid including header files and complicating the editing of these files. Any numeric +customizations +(such as setting a threshold) is done using `constexpr` functions. + +These are later included as proper type-aliases inside ModuleSettings (with appropriate type and configuration checking) +. + +### !!NOTE!! +Only edit these when you feel like the default configuration that you want for `Elastica++` differs from the defaults set in +the Github repository. Else prefer making a configuration in the main.cpp file, as this promotes readability and intent +to the poor souls (made to) read(ing) your code. diff --git a/backend/src/Configuration/Systems.hpp b/backend/src/Configuration/Systems.hpp new file mode 100644 index 00000000..2b9c4a65 --- /dev/null +++ b/backend/src/Configuration/Systems.hpp @@ -0,0 +1,130 @@ +#pragma once + +//****************************************************************************** +/*!\brief Selection of the default admissible systems + * \ingroup default_config + * + * This macro selects the default admissible \systems. The purpose of this + * \a typelist is to add tags indicating the admissible \systems in the + * simulation that comprise the degrees of freedom. The following \system tags + * are available: + * + * - elastica::cosserat_rod::CosseratRod + * - elastica::cosserat_rod::CosseratRodWithoutDamping + * - elastica::rigid_body::Sphere + * + * Consult the documentation page of elastica::PhysicalSystemPlugins for more + * information. This can be customized as needed in the client file. + */ +#ifndef ELASTICA_DEFAULT_ADMISSIBLE_PLUGINS_FOR_SYSTEMS +#define ELASTICA_DEFAULT_ADMISSIBLE_PLUGINS_FOR_SYSTEMS \ + tmpl::list +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default policy for adding new systems to Blocks + * within the simulator + * \ingroup default_config + * + * This macro select the default Blocking policy for adding Systems within + * \elastica. The following (simple) blocking policies are available: + * + * - elastica::configuration::RestrictSizeAcrossBlockTypesPolicy + * - elastica::configuration::LooselyRestrictSizeAcrossBlockTypesPolicy + * - elastica::configuration::AlwaysNewAcrossBlockTypesPolicy + * - elastica::configuration::AlwaysSameAcrossBlockTypesPolicy + * + * This can be customized if needed in the client file. More complicated + * policies are also possible by composition + */ +#ifndef ELASTICA_DEFAULT_BLOCKING_POLICY_FOR_SYSTEMS +#define ELASTICA_DEFAULT_BLOCKING_POLICY_FOR_SYSTEMS \ + elastica::configuration::RestrictSizeAcrossBlockTypesPolicy +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the size parameter for the default policy choosen in + * ELASTICA_DEFAULT_BLOCKING_CRITERIA_FOR_SYSTEMS() + * \ingroup default_config + * + * This value specifies the default size parameter for specifying the blocking + * policy. + */ +constexpr std::size_t default_blocking_policy_size() { return 1024UL; } +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default iteration behavior over multiple types of + * \elastica systems + * \ingroup default_config + * + * This macro select the default behavior while iterating over multiple types + * of systems (such as a CosseratRod, Sphere, Capsule) etc. The following + * execution policies are available: + * + * - elastica::configuration::sequential_policy + * - elastica::configuration::parallel_policy + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_DEFAULT_ITERATION_POLICY_ACROSS_SYSTEM_TYPES +#define ELASTICA_DEFAULT_ITERATION_POLICY_ACROSS_SYSTEM_TYPES \ + ::elastica::configuration::sequential_policy +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default iteration behavior over a container of + * \elastica systems + * \ingroup default_config + * + * This macro select the default behavior while iterating over multiple systems + * of the same type. The following execution policies are available: + * + * - elastica::configuration::sequential_policy + * - elastica::configuration::parallel_policy + * - elastica::configuration::hybrid_policy + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_DEFAULT_ITERATION_POLICY_FOR_EACH_SYSTEM_TYPE +#define ELASTICA_DEFAULT_ITERATION_POLICY_FOR_EACH_SYSTEM_TYPE \ + ::elastica::configuration::sequential_policy +#endif +//****************************************************************************** + +//****************************************************************************** +/*!\brief Environment variable to control if potential warnings are shown during + * system initialization + * \ingroup systems + * + * The macro defines the environment variable that is searched for controlling + * the behavior of (potential) warnings when initialization systems in + * Elastica++. By default, potential warnings are enabled. To disable user + * warnings the environment variable can be set to 1, i.e. + * \code + * ELASTICA_NO_SYSTEM_WARN=1 ./ [options] + * \endcode + */ +#define ENV_ELASTICA_NO_SYSTEM_WARN "ELASTICA_NO_SYSTEM_WARN" +//**************************************************************************** + +//****************************************************************************** +/*!\brief Selection of the default index checking behavior within systems module + * \elastica systems + * \ingroup default_config + * + * This macro select the default behavior while slicing/viewing indices within + * a system. The following execution policies are available: + * + * - checked (checks indices) + * - unchecked (does not check indices) + * + * This can be customized if needed in the client file. + */ +#ifndef ELASTICA_DEFAULT_SYSTEM_INDEX_CHECK +#define ELASTICA_DEFAULT_SYSTEM_INDEX_CHECK checked +#endif +//**************************************************************************** diff --git a/backend/src/Systems/CosseratRods/Components/helpers/Types.hpp b/backend/src/Systems/CosseratRods/Components/helpers/Types.hpp index cd5fe4fd..ee7cdbc6 100644 --- a/backend/src/Systems/CosseratRods/Components/helpers/Types.hpp +++ b/backend/src/Systems/CosseratRods/Components/helpers/Types.hpp @@ -3,6 +3,7 @@ //****************************************************************************** // Includes //****************************************************************************** +#include "Systems/common/Components/Types.hpp" namespace elastica {