diff --git a/lgtm.yml b/lgtm.yml deleted file mode 100644 index 362ccf577..000000000 --- a/lgtm.yml +++ /dev/null @@ -1,30 +0,0 @@ -path_classifiers: - test: - - "tests" - library: - - "subprojects" -extraction: - cpp: - prepare: - packages: - - build-essential - - cmake - - python3 - - python3-pip - - openmpi-bin - - libopenmpi-dev - configure: - command: - - BD=$PWD - - SAMRAI_GIT=https://github.com/PHARCHIVE/SAMRAI_export - - SAMRAI_DIR=/opt/work/samrai - - git submodule update --init - - python3 -m pip install pip --upgrade - - python3 -m pip install -r requirements.txt --upgrade - - git clone $SAMRAI_GIT --depth 1 $SAMRAI_DIR -b ubuntu_18_04_openmpi - - cd $SAMRAI_DIR; ./unzip.sh; - - cd $BD; mkdir build; cd build; cmake .. -DSAMRAI_ROOT=$SAMRAI_DIR -DHighFive=OFF -DforceGetPybind=ON - index: - build_command: - - cd build; make - - ctest --output-on-failure diff --git a/src/amr/data/field/coarsening/default_field_coarsener.hpp b/src/amr/data/field/coarsening/default_field_coarsener.hpp index 29b8f517b..1bcd2accc 100644 --- a/src/amr/data/field/coarsening/default_field_coarsener.hpp +++ b/src/amr/data/field/coarsening/default_field_coarsener.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_DEFAULT_FIELD_COARSENER_HPP #define PHARE_DEFAULT_FIELD_COARSENER_HPP + +#include "core/def/mpi.hpp" + #include "core/def.hpp" #include "core/data/grid/gridlayoutdefs.hpp" #include "core/utilities/constants.hpp" diff --git a/src/amr/data/field/coarsening/field_coarsen_index_weight.hpp b/src/amr/data/field/coarsening/field_coarsen_index_weight.hpp index 935e782ac..0c805ea09 100644 --- a/src/amr/data/field/coarsening/field_coarsen_index_weight.hpp +++ b/src/amr/data/field/coarsening/field_coarsen_index_weight.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_FIELD_COARSEN_HPP #define PHARE_FIELD_COARSEN_HPP + +#include "core/def/mpi.hpp" + #include "core/def.hpp" #include "coarsen_weighter.hpp" #include "core/data/grid/gridlayoutdefs.hpp" diff --git a/src/amr/data/field/coarsening/field_coarsen_operator.hpp b/src/amr/data/field/coarsening/field_coarsen_operator.hpp index 535db7393..3d6141f82 100644 --- a/src/amr/data/field/coarsening/field_coarsen_operator.hpp +++ b/src/amr/data/field/coarsening/field_coarsen_operator.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_FIELD_DATA_COARSEN_HPP #define PHARE_FIELD_DATA_COARSEN_HPP + +#include "core/def/mpi.hpp" + #include "amr/data/field/field_data.hpp" #include "amr/data/field/field_geometry.hpp" #include "default_field_coarsener.hpp" diff --git a/src/amr/data/field/coarsening/magnetic_field_coarsener.hpp b/src/amr/data/field/coarsening/magnetic_field_coarsener.hpp index 2e98b59b3..b17fb266f 100644 --- a/src/amr/data/field/coarsening/magnetic_field_coarsener.hpp +++ b/src/amr/data/field/coarsening/magnetic_field_coarsener.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_MAGNETIC_FIELD_COARSENER #define PHARE_MAGNETIC_FIELD_COARSENER + +#include "core/def/mpi.hpp" + #include "core/data/grid/gridlayoutdefs.hpp" #include "core/hybrid/hybrid_quantities.hpp" #include "core/utilities/constants.hpp" diff --git a/src/amr/data/field/field_data.hpp b/src/amr/data/field/field_data.hpp index 1d33586aa..4a15b584c 100644 --- a/src/amr/data/field/field_data.hpp +++ b/src/amr/data/field/field_data.hpp @@ -2,6 +2,9 @@ #define PHARE_SRC_AMR_FIELD_FIELD_DATA_HPP + +#include "core/def/mpi.hpp" + #include #include #include @@ -72,9 +75,9 @@ namespace amr { } - FieldData() = delete; - FieldData(FieldData const&) = delete; - FieldData(FieldData&&) = default; + FieldData() = delete; + FieldData(FieldData const&) = delete; + FieldData(FieldData&&) = default; FieldData& operator=(FieldData const&) = delete; diff --git a/src/amr/data/field/field_data_factory.hpp b/src/amr/data/field/field_data_factory.hpp index a6e77ad5d..3d206de1f 100644 --- a/src/amr/data/field/field_data_factory.hpp +++ b/src/amr/data/field/field_data_factory.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_SRC_AMR_FIELD_FIELD_DATA_FACTORY_HPP #define PHARE_SRC_AMR_FIELD_FIELD_DATA_FACTORY_HPP + +#include "core/def/mpi.hpp" + #include #include #include diff --git a/src/amr/data/field/field_geometry.hpp b/src/amr/data/field/field_geometry.hpp index 53f0f756a..aac3899b6 100644 --- a/src/amr/data/field/field_geometry.hpp +++ b/src/amr/data/field/field_geometry.hpp @@ -4,6 +4,9 @@ #include #include +#include "core/def/mpi.hpp" + + #include "SAMRAI/hier/IntVector.h" #include "core/data/grid/gridlayoutdefs.hpp" #include "core/data/grid/gridlayout.hpp" diff --git a/src/amr/data/field/field_overlap.hpp b/src/amr/data/field/field_overlap.hpp index a38fa5737..69deaa700 100644 --- a/src/amr/data/field/field_overlap.hpp +++ b/src/amr/data/field/field_overlap.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_SRC_AMR_FIELD_FIELD_OVERLAP_HPP #define PHARE_SRC_AMR_FIELD_FIELD_OVERLAP_HPP + +#include "core/def/mpi.hpp" + #include #include #include diff --git a/src/amr/data/field/field_variable.hpp b/src/amr/data/field/field_variable.hpp index 5c615601e..336adbac5 100644 --- a/src/amr/data/field/field_variable.hpp +++ b/src/amr/data/field/field_variable.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_SRC_AMR_FIELD_FIELD_VARIABLE_HPP #define PHARE_SRC_AMR_FIELD_FIELD_VARIABLE_HPP + +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/data/field/field_variable_fill_pattern.hpp b/src/amr/data/field/field_variable_fill_pattern.hpp index f497730ad..ea92dc394 100644 --- a/src/amr/data/field/field_variable_fill_pattern.hpp +++ b/src/amr/data/field/field_variable_fill_pattern.hpp @@ -3,6 +3,8 @@ #include +#include "core/def/mpi.hpp" + #include "SAMRAI/xfer/VariableFillPattern.h" #include "core/utilities/types.hpp" @@ -110,7 +112,10 @@ class FieldFillPattern : public SAMRAI::xfer::VariableFillPattern transformation); } - std::string const& getPatternName() const { return s_name_id; } + std::string const& getPatternName() const + { + return s_name_id; + } private: FieldFillPattern(FieldFillPattern const&) = delete; diff --git a/src/amr/data/field/refine/electric_field_refiner.hpp b/src/amr/data/field/refine/electric_field_refiner.hpp index 4f9f1044e..bac5d0ffc 100644 --- a/src/amr/data/field/refine/electric_field_refiner.hpp +++ b/src/amr/data/field/refine/electric_field_refiner.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_ELECTRIC_FIELD_REFINER_HPP #define PHARE_ELECTRIC_FIELD_REFINER_HPP + +#include "core/def/mpi.hpp" + #include #include "amr/resources_manager/amr_utils.hpp" diff --git a/src/amr/data/field/refine/field_linear_refine.hpp b/src/amr/data/field/refine/field_linear_refine.hpp index ba0eba2ed..23afd1706 100644 --- a/src/amr/data/field/refine/field_linear_refine.hpp +++ b/src/amr/data/field/refine/field_linear_refine.hpp @@ -2,6 +2,9 @@ #define PHARE_FIELD_LINEAR_REFINE_HPP +#include "core/def/mpi.hpp" + + #include "core/def.hpp" #include "core/data/grid/gridlayoutdefs.hpp" #include "core/data/field/field.hpp" diff --git a/src/amr/data/field/refine/field_refine_operator.hpp b/src/amr/data/field/refine/field_refine_operator.hpp index b22804702..d1d445b25 100644 --- a/src/amr/data/field/refine/field_refine_operator.hpp +++ b/src/amr/data/field/refine/field_refine_operator.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_FIELD_REFINE_OPERATOR_HPP #define PHARE_FIELD_REFINE_OPERATOR_HPP + +#include "core/def/mpi.hpp" + #include "core/def.hpp" #include "amr/data/field/field_data.hpp" #include "amr/data/field/field_geometry.hpp" diff --git a/src/amr/data/field/refine/field_refiner.hpp b/src/amr/data/field/refine/field_refiner.hpp index 96c5c7f10..8bf8c44e0 100644 --- a/src/amr/data/field/refine/field_refiner.hpp +++ b/src/amr/data/field/refine/field_refiner.hpp @@ -2,6 +2,9 @@ #define PHARE_FIELD_REFINER_HPP +#include "core/def/mpi.hpp" + + #include "core/data/grid/gridlayoutdefs.hpp" #include "core/data/field/field.hpp" #include "field_linear_refine.hpp" diff --git a/src/amr/data/field/refine/linear_weighter.hpp b/src/amr/data/field/refine/linear_weighter.hpp index d663b9ba2..aa94a476b 100644 --- a/src/amr/data/field/refine/linear_weighter.hpp +++ b/src/amr/data/field/refine/linear_weighter.hpp @@ -2,6 +2,9 @@ #define PHARE_LINEAR_WEIGHTER_HPP +#include "core/def/mpi.hpp" + + #include "core/def.hpp" #include "core/data/grid/gridlayoutdefs.hpp" #include "core/data/field/field.hpp" diff --git a/src/amr/data/field/refine/magnetic_field_refiner.hpp b/src/amr/data/field/refine/magnetic_field_refiner.hpp index 6a9983cb2..435bd75e7 100644 --- a/src/amr/data/field/refine/magnetic_field_refiner.hpp +++ b/src/amr/data/field/refine/magnetic_field_refiner.hpp @@ -1,6 +1,9 @@ #ifndef PHARE_MAGNETIC_FIELD_REFINER_HPP #define PHARE_MAGNETIC_FIELD_REFINER_HPP + +#include "core/def/mpi.hpp" + #include #include "amr/resources_manager/amr_utils.hpp" diff --git a/src/amr/data/field/time_interpolate/field_linear_time_interpolate.hpp b/src/amr/data/field/time_interpolate/field_linear_time_interpolate.hpp index f3009e120..2bc072348 100644 --- a/src/amr/data/field/time_interpolate/field_linear_time_interpolate.hpp +++ b/src/amr/data/field/time_interpolate/field_linear_time_interpolate.hpp @@ -9,6 +9,9 @@ #include "amr/data/field/field_data.hpp" #include "amr/data/field/field_geometry.hpp" +#include "core/def/mpi.hpp" + + #include diff --git a/src/amr/data/particles/particles_data.hpp b/src/amr/data/particles/particles_data.hpp index 0eed00004..2204d1415 100644 --- a/src/amr/data/particles/particles_data.hpp +++ b/src/amr/data/particles/particles_data.hpp @@ -7,6 +7,9 @@ #include #include +#include "core/def/mpi.hpp" + + #include #include #include diff --git a/src/amr/data/particles/particles_data_factory.hpp b/src/amr/data/particles/particles_data_factory.hpp index 308f5a3a7..ac4ff93ce 100644 --- a/src/amr/data/particles/particles_data_factory.hpp +++ b/src/amr/data/particles/particles_data_factory.hpp @@ -3,6 +3,8 @@ #include "particles_data.hpp" +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/data/particles/particles_variable.hpp b/src/amr/data/particles/particles_variable.hpp index 086aaf036..145500c9b 100644 --- a/src/amr/data/particles/particles_variable.hpp +++ b/src/amr/data/particles/particles_variable.hpp @@ -3,6 +3,8 @@ #include "core/data/grid/gridlayout.hpp" // particle ghost width #include "particles_data_factory.hpp" +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/data/particles/refine/particles_data_split.hpp b/src/amr/data/particles/refine/particles_data_split.hpp index 0b1cf015b..763563394 100644 --- a/src/amr/data/particles/refine/particles_data_split.hpp +++ b/src/amr/data/particles/refine/particles_data_split.hpp @@ -2,6 +2,8 @@ #define PHARE_PARTICLES_DATA_SPLIT_HPP +#include "core/def/mpi.hpp" + #include "core/def.hpp" #include "amr/data/particles/particles_data.hpp" #include "amr/resources_manager/amr_utils.hpp" diff --git a/src/amr/messengers/communicator.hpp b/src/amr/messengers/communicator.hpp index e04984a77..485e3d5aa 100644 --- a/src/amr/messengers/communicator.hpp +++ b/src/amr/messengers/communicator.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_QUANTITY_REFINER_HPP #define PHARE_QUANTITY_REFINER_HPP +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp b/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp index e6f3f4dfe..76a49883f 100644 --- a/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp +++ b/src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_HYBRID_HYBRID_MESSENGER_STRATEGY_HPP #define PHARE_HYBRID_HYBRID_MESSENGER_STRATEGY_HPP +#include "core/def/mpi.hpp" + #include "SAMRAI/hier/CoarseFineBoundary.h" #include "SAMRAI/hier/IntVector.h" #include "refiner_pool.hpp" diff --git a/src/amr/messengers/hybrid_messenger_strategy.hpp b/src/amr/messengers/hybrid_messenger_strategy.hpp index af355bb8f..7c1db5ac9 100644 --- a/src/amr/messengers/hybrid_messenger_strategy.hpp +++ b/src/amr/messengers/hybrid_messenger_strategy.hpp @@ -3,6 +3,8 @@ #include "amr/messengers/messenger_info.hpp" +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/messengers/messenger.hpp b/src/amr/messengers/messenger.hpp index 13848815b..2d36a75db 100644 --- a/src/amr/messengers/messenger.hpp +++ b/src/amr/messengers/messenger.hpp @@ -4,6 +4,8 @@ #include +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/messengers/mhd_messenger.hpp b/src/amr/messengers/mhd_messenger.hpp index 980f8c30e..6b97489f9 100644 --- a/src/amr/messengers/mhd_messenger.hpp +++ b/src/amr/messengers/mhd_messenger.hpp @@ -4,6 +4,8 @@ #include #include +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/multiphysics_integrator.hpp b/src/amr/multiphysics_integrator.hpp index 9a7ed10c9..ef315e7a2 100644 --- a/src/amr/multiphysics_integrator.hpp +++ b/src/amr/multiphysics_integrator.hpp @@ -10,6 +10,8 @@ #include +#include "core/def/mpi.hpp" + #include #include diff --git a/src/amr/physical_models/mhd_model.hpp b/src/amr/physical_models/mhd_model.hpp index 8b982514a..2378d790b 100644 --- a/src/amr/physical_models/mhd_model.hpp +++ b/src/amr/physical_models/mhd_model.hpp @@ -3,6 +3,8 @@ #include +#include "core/def/mpi.hpp" + #include diff --git a/src/amr/resources_manager/amr_utils.hpp b/src/amr/resources_manager/amr_utils.hpp index 74899de32..fa26f658e 100644 --- a/src/amr/resources_manager/amr_utils.hpp +++ b/src/amr/resources_manager/amr_utils.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_AMR_UTILS_HPP #define PHARE_AMR_UTILS_HPP +#include "core/def/mpi.hpp" + #include #include #include diff --git a/src/amr/resources_manager/resources_guards.hpp b/src/amr/resources_manager/resources_guards.hpp index dff3f3a02..ffd471b62 100644 --- a/src/amr/resources_manager/resources_guards.hpp +++ b/src/amr/resources_manager/resources_guards.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_AMR_TOOLS_RESOURCES_GUARDS_HPP #define PHARE_AMR_TOOLS_RESOURCES_GUARDS_HPP +#include "core/def/mpi.hpp" + #include "resources_manager_utilities.hpp" #include @@ -64,11 +66,11 @@ namespace amr // We just need the move constructor for using ResourceManager::createResourcesGuards - ResourcesGuard(ResourcesGuard&&) = default; - ResourcesGuard() = delete; - ResourcesGuard(ResourcesGuard const&) = delete; + ResourcesGuard(ResourcesGuard&&) = default; + ResourcesGuard() = delete; + ResourcesGuard(ResourcesGuard const&) = delete; ResourcesGuard& operator=(ResourcesGuard const& source) = delete; - ResourcesGuard& operator=(ResourcesGuard&&) = delete; + ResourcesGuard& operator=(ResourcesGuard&&) = delete; diff --git a/src/amr/resources_manager/resources_manager.hpp b/src/amr/resources_manager/resources_manager.hpp index eadb9c625..5a885cd60 100644 --- a/src/amr/resources_manager/resources_manager.hpp +++ b/src/amr/resources_manager/resources_manager.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_AMR_TOOLS_RESOURCES_MANAGER_HPP #define PHARE_AMR_TOOLS_RESOURCES_MANAGER_HPP +#include "core/def/mpi.hpp" + #include "core/logger.hpp" #include "field_resource.hpp" diff --git a/src/amr/solvers/solver.hpp b/src/amr/solvers/solver.hpp index e406c605a..6f9f26149 100644 --- a/src/amr/solvers/solver.hpp +++ b/src/amr/solvers/solver.hpp @@ -2,6 +2,7 @@ #define PHARE_SOLVER_HPP #include +#include "core/def/mpi.hpp" #include #include @@ -80,8 +81,7 @@ namespace solver * ResourcesManager of the given model, onto the given Patch, at the given time. */ virtual void allocate(IPhysicalModel& model, SAMRAI::hier::Patch& patch, - double const allocateTime) const - = 0; + double const allocateTime) const = 0; diff --git a/src/amr/solvers/solver_ppc.hpp b/src/amr/solvers/solver_ppc.hpp index 007829c86..05248a398 100644 --- a/src/amr/solvers/solver_ppc.hpp +++ b/src/amr/solvers/solver_ppc.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_SOLVER_PPC_HPP #define PHARE_SOLVER_PPC_HPP +#include "core/def/mpi.hpp" + #include diff --git a/src/amr/tagging/hybrid_tagger.hpp b/src/amr/tagging/hybrid_tagger.hpp index 5ac86cdf7..bc1f2cabf 100644 --- a/src/amr/tagging/hybrid_tagger.hpp +++ b/src/amr/tagging/hybrid_tagger.hpp @@ -2,6 +2,9 @@ #ifndef PHARE_HYBRID_TAGGER_HPP #define PHARE_HYBRID_TAGGER_HPP + +#include "core/def/mpi.hpp" + #include "tagger.hpp" #include "hybrid_tagger_strategy.hpp" #include "amr/physical_models/hybrid_model.hpp" diff --git a/src/amr/types/amr_types.hpp b/src/amr/types/amr_types.hpp index 6c5a36392..49eb298a6 100644 --- a/src/amr/types/amr_types.hpp +++ b/src/amr/types/amr_types.hpp @@ -1,6 +1,7 @@ #ifndef PHARE_AMR_TYPES_HPP #define PHARE_AMR_TYPES_HPP +#include "core/def/mpi.hpp" #include "SAMRAI/hier/Patch.h" #include "SAMRAI/hier/PatchHierarchy.h" diff --git a/src/amr/utilities/box/amr_box.hpp b/src/amr/utilities/box/amr_box.hpp index 40e4c9ce6..ce616f922 100644 --- a/src/amr/utilities/box/amr_box.hpp +++ b/src/amr/utilities/box/amr_box.hpp @@ -2,6 +2,9 @@ #define PHARE_AMR_UTILITIES_BOX_BOX_HPP +#include "core/def/mpi.hpp" + + #include "SAMRAI/hier/Box.h" #include "core/utilities/box/box.hpp" #include "core/def.hpp" diff --git a/src/amr/wrappers/hierarchy.hpp b/src/amr/wrappers/hierarchy.hpp index 2c2c1f1f5..241a8931c 100644 --- a/src/amr/wrappers/hierarchy.hpp +++ b/src/amr/wrappers/hierarchy.hpp @@ -3,6 +3,8 @@ #include +#include "core/def/mpi.hpp" + #include #include #include diff --git a/src/amr/wrappers/integrator.hpp b/src/amr/wrappers/integrator.hpp index 9bb7540cb..22d59679b 100644 --- a/src/amr/wrappers/integrator.hpp +++ b/src/amr/wrappers/integrator.hpp @@ -1,6 +1,8 @@ #ifndef INTEGRATOR_HPP #define INTEGRATOR_HPP +#include "core/def/mpi.hpp" + #include #include #include diff --git a/src/core/def/.gitignore b/src/core/def/.gitignore new file mode 100644 index 000000000..e77149496 --- /dev/null +++ b/src/core/def/.gitignore @@ -0,0 +1 @@ +_gen* diff --git a/src/core/def/mpi.hpp b/src/core/def/mpi.hpp new file mode 100644 index 000000000..582f14fbc --- /dev/null +++ b/src/core/def/mpi.hpp @@ -0,0 +1,23 @@ +#ifndef PHARE_CORE_DEF_MPI_HPP +#define PHARE_CORE_DEF_MPI_HPP + + +// DO NOT INCLUDE MPI MANUALLY! USE THIS FILE! + +#if __has_include("core/def/_gen_mpi.hpp") +#include "core/def/_gen_mpi.hpp" +#else +// Not always an issue, but not recommended +#endif + +#include "core/def/pragma_disable.hpp" + +// clang-format off +DISABLE_WARNING(cast-function-type, bad-function-cast, 42) +#include "mpi.h" +ENABLE_WARNING(cast-function-type, bad-function-cast, 42) +// clang-format on + + + +#endif /*PHARE_CORE_DEF_MPI_HPP*/ \ No newline at end of file diff --git a/src/initializer/pragma_disable.hpp b/src/core/def/pragma_disable.hpp similarity index 100% rename from src/initializer/pragma_disable.hpp rename to src/core/def/pragma_disable.hpp diff --git a/src/core/utilities/mpi_utils.hpp b/src/core/utilities/mpi_utils.hpp index 114d7ad69..7285dd4c9 100644 --- a/src/core/utilities/mpi_utils.hpp +++ b/src/core/utilities/mpi_utils.hpp @@ -9,13 +9,8 @@ #include #include -// clang-format off -#include "initializer/pragma_disable.hpp" -DISABLE_WARNING(cast-function-type, bad-function-cast, 42) -#include "mpi.h" -ENABLE_WARNING(cast-function-type, bad-function-cast, 42) -// clang-format on +#include "core/def/mpi.hpp" #include "core/utilities/span.hpp" #include "core/utilities/types.hpp" diff --git a/src/initializer/python_data_provider.hpp b/src/initializer/python_data_provider.hpp index b3dadc2f8..e4f7116be 100644 --- a/src/initializer/python_data_provider.hpp +++ b/src/initializer/python_data_provider.hpp @@ -7,7 +7,7 @@ #include "initializer/data_provider.hpp" -#include "pragma_disable.hpp" +#include "core/def/pragma_disable.hpp" // clang-format off DISABLE_WARNING(shadow, shadow-field-in-constructor-modified, 42) diff --git a/src/phare_amr.hpp b/src/phare_amr.hpp index dcd45ca9b..343ebff35 100644 --- a/src/phare_amr.hpp +++ b/src/phare_amr.hpp @@ -2,6 +2,8 @@ #define PHARE_AMR_INCLUDE_HPP +#include "core/def/mpi.hpp" + #include #include diff --git a/src/python3/cpp_simulator.hpp b/src/python3/cpp_simulator.hpp index c0b04f7ab..faff4e0e3 100644 --- a/src/python3/cpp_simulator.hpp +++ b/src/python3/cpp_simulator.hpp @@ -4,7 +4,7 @@ #include #include -#include "mpi.h" +#include "core/def/mpi.hpp" #include "core/utilities/mpi_utils.hpp" #include "core/data/particles/particle.hpp" diff --git a/tests/amr/data/particles/refine/test_particle_data_refine.cpp b/tests/amr/data/particles/refine/test_particle_data_refine.cpp index 1f016b972..cbae6c3b8 100644 --- a/tests/amr/data/particles/refine/test_particle_data_refine.cpp +++ b/tests/amr/data/particles/refine/test_particle_data_refine.cpp @@ -1,3 +1,6 @@ + +#include "core/def/mpi.hpp" + #include "amr/data/particles/particles_data.hpp" #include "amr/data/particles/particles_variable.hpp" #include "amr/data/particles/refine/particles_data_split.hpp" diff --git a/tests/amr/data/particles/refine/test_particle_data_refine_tag_strategy.hpp b/tests/amr/data/particles/refine/test_particle_data_refine_tag_strategy.hpp index c9e840d13..813740800 100644 --- a/tests/amr/data/particles/refine/test_particle_data_refine_tag_strategy.hpp +++ b/tests/amr/data/particles/refine/test_particle_data_refine_tag_strategy.hpp @@ -1,6 +1,7 @@ #ifndef PHARE_TEST_TAG_STRATEGY_HPP #define PHARE_TEST_TAG_STRATEGY_HPP +#include "core/def/mpi.hpp" #include #include diff --git a/tests/amr/data/particles/refine/test_particledata_refine_basic_hierarchy.hpp b/tests/amr/data/particles/refine/test_particledata_refine_basic_hierarchy.hpp index b97da356f..d2020dd2b 100644 --- a/tests/amr/data/particles/refine/test_particledata_refine_basic_hierarchy.hpp +++ b/tests/amr/data/particles/refine/test_particledata_refine_basic_hierarchy.hpp @@ -1,6 +1,8 @@ #ifndef PHARE_TEST_BASIC_HIERARCHY_HPP #define PHARE_TEST_BASIC_HIERARCHY_HPP +#include "core/def/mpi.hpp" + #include "amr/data/particles/particles_variable.hpp" #include "amr/data/particles/refine/particles_data_split.hpp" diff --git a/tests/amr/data/particles/refine/test_split.cpp b/tests/amr/data/particles/refine/test_split.cpp index 687cd5670..1ab786508 100644 --- a/tests/amr/data/particles/refine/test_split.cpp +++ b/tests/amr/data/particles/refine/test_split.cpp @@ -1,5 +1,7 @@ #include +#include "core/def/mpi.hpp" + #include "core/utilities/types.hpp" #include "amr/data/particles/refine/split.hpp" diff --git a/tests/amr/multiphysics_integrator/test_multiphysics_integrator.cpp b/tests/amr/multiphysics_integrator/test_multiphysics_integrator.cpp index f624a682b..cc8f5334c 100644 --- a/tests/amr/multiphysics_integrator/test_multiphysics_integrator.cpp +++ b/tests/amr/multiphysics_integrator/test_multiphysics_integrator.cpp @@ -1,5 +1,5 @@ -#include +#include "core/def/mpi.hpp" #include "tests/simulator/per_test.hpp" diff --git a/tests/amr/tagging/test_tagging.cpp b/tests/amr/tagging/test_tagging.cpp index 984a005fa..471fba411 100644 --- a/tests/amr/tagging/test_tagging.cpp +++ b/tests/amr/tagging/test_tagging.cpp @@ -1,4 +1,6 @@ +#define OMPI_SKIP_MPICXX 1 + #include #include diff --git a/tests/diagnostic/test-diagnostics_1d.cpp b/tests/diagnostic/test-diagnostics_1d.cpp index 6f3b0db97..222bdf6d9 100644 --- a/tests/diagnostic/test-diagnostics_1d.cpp +++ b/tests/diagnostic/test-diagnostics_1d.cpp @@ -1,5 +1,5 @@ -#include +#include "core/def/mpi.hpp" #include "test_diagnostics.ipp" diff --git a/tests/diagnostic/test-diagnostics_2d.cpp b/tests/diagnostic/test-diagnostics_2d.cpp index c495a2d7d..a06807214 100644 --- a/tests/diagnostic/test-diagnostics_2d.cpp +++ b/tests/diagnostic/test-diagnostics_2d.cpp @@ -1,5 +1,5 @@ -#include +#include "core/def/mpi.hpp" #include "test_diagnostics.ipp" diff --git a/tools/config/CMakeLists.txt b/tools/config/CMakeLists.txt new file mode 100644 index 000000000..6a4cb7ff8 --- /dev/null +++ b/tools/config/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required (VERSION 3.22) + +project(phare_configurator) + +set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +# set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) + + +find_package(MPI REQUIRED) +foreach(LIB ${MPI_LIBRARY}) + get_filename_component(MPI_LIBRARY_PATH ${LIB} DIRECTORY) +endforeach() + +include_directories(${MPI_C_HEADER_DIR}) + +add_executable(${PROJECT_NAME} main.cpp) +target_link_libraries(${PROJECT_NAME} mpi mpi_cxx) +target_link_directories(${PROJECT_NAME} PUBLIC ${MPI_LIBRARY_PATH}) + +## probably should do something to check if mpi_cxx is even available, cause deprecated. +# get_cmake_property(_variableNames VARIABLES) +# list (SORT _variableNames) +# foreach (_variableName ${_variableNames}) +# message(STATUS "${_variableName}=${${_variableName}}") +# endforeach() + diff --git a/tools/config/cmake.sh b/tools/config/cmake.sh new file mode 100755 index 000000000..edae881fd --- /dev/null +++ b/tools/config/cmake.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e +CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" && cd "$CWD" +ROOT_DIR=$(cd ../.. && pwd) +[ -f "${ROOT_DIR}/res/cmake/def.cmake" ] || (echo "Corruption detected" && exit 1) # confirm correct directory + +[ -d build ] || ( + mkdir -p build && cd build + cmake -DCMAKE_BUILD_TYPE=Release .. -G Ninja 2>&1 > /dev/null + ninja && ./phare_configurator +) +python3 config.py diff --git a/tools/config/config.py b/tools/config/config.py new file mode 100644 index 000000000..0f25b585d --- /dev/null +++ b/tools/config/config.py @@ -0,0 +1,45 @@ +import os +from pathlib import Path + +FILE_DIR = Path(__file__).resolve().parent +ROOT_DIR = FILE_DIR.parent.parent +if not os.path.exists(ROOT_DIR / "src" / "core" / "def"): + raise RuntimeError("Corruption detected") +FILES = [f for f in Path(FILE_DIR).glob("build/PHARE_*")] + + +def local_file_format(filename): + return filename[6:-4] + + +def create_file(f): + with open(f, "a") as file: + file.truncate(0) + + +def config_mpi_version(txtfile, h_file): + with open(txtfile) as f: + version = f.readline() + out_buff = "\n" + if "OpenMPI" in version: + out_buff += "// avoids default including mpicxx \n" + out_buff += "#define OMPI_SKIP_MPICXX 1 \n\n" + with open(h_file, "w") as f: + f.write(out_buff) + + +def config_mpi(): + h_file = ROOT_DIR / "src" / "core" / "def" / "_gen_mpi.hpp" + create_file(h_file) + operators = dict(MPI_Get_library_version=config_mpi_version) + for f in FILES: + fn = operators.get(local_file_format(f.name), lambda x, y: 0) + fn(f, h_file) + + +def main(): + config_mpi() + + +if __name__ == "__main__": + main() diff --git a/tools/config/main.cpp b/tools/config/main.cpp new file mode 100644 index 000000000..d3bca3f1e --- /dev/null +++ b/tools/config/main.cpp @@ -0,0 +1,41 @@ +#include "mpi.h" +#include +#include +#include + +void config_mpi() +{ + int initialized; + MPI_Initialized(&initialized); + if (!initialized) + { + throw std::runtime_error("MPI not initialized"); + } + + char version[MPI_MAX_LIBRARY_VERSION_STRING]; + int resultlen = 0; + int ret = MPI_Get_library_version(version, &resultlen); + if (ret != MPI_SUCCESS) + throw std::runtime_error("error calling MPI_Get_library_version"); + + std::ofstream file("PHARE_MPI_Get_library_version.txt", std::ios::out); + if (!file) + throw std::runtime_error("error opening version file"); + file << version << std::endl; +} + +int main(int argc, char** argv) +{ + MPI_Init(&argc, &argv); + try + { + config_mpi(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << std::endl; + MPI_Abort(MPI_COMM_WORLD, 1); + } + MPI_Finalize(); + return 0; +} \ No newline at end of file