From 54907ae77eb94711fc8d52e9aab86e8d5bcc6944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Thu, 29 Oct 2020 00:02:49 +0100 Subject: [PATCH] Add mesh database infrastructure The database is just populated with a small 3d cartesian grid which is still inaccessible. This is just a proof of concept: the mesh is build for both `unit_tests` and `mpi_unit_tests`. The optimization resulting from the previous is already noticed even with Release build type. Using `ctest` (old `make test`) one gets the following execution times - without mesh building: 3s - with a simple mesh building: 31s Using the new `test` target one gets the following execution times - without mesh building: 1.3s - with a simple mesh building: 2.7s (the `make test` results are actually obtained using `ninja` since the test is so fast that the majority of the spent time using `make` is spent computing target dependencies) Using `make test` with the new `test` target one gets the following execution times - without mesh building: 1.95s - with a simple mesh building: 3.45s --- tests/CMakeLists.txt | 5 +++++ tests/mpi_test_main.cpp | 26 ++++++++++++++++++++++---- tests/test_MeshDataBase.cpp | 33 +++++++++++++++++++++++++++++++++ tests/test_MeshDataBase.hpp | 23 +++++++++++++++++++++++ tests/test_main.cpp | 27 ++++++++++++++++++++++++++- 5 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 tests/test_MeshDataBase.cpp create mode 100644 tests/test_MeshDataBase.hpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dbaf666c1..4cff6b232 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -89,7 +89,11 @@ add_executable (mpi_unit_tests mpi_test_Messenger.cpp ) +add_library(test_Pugs_MeshDataBase + test_MeshDataBase.cpp) + target_link_libraries (unit_tests + test_Pugs_MeshDataBase PugsLanguage PugsLanguageAST PugsLanguageModules @@ -106,6 +110,7 @@ target_link_libraries (unit_tests ) target_link_libraries (mpi_unit_tests + test_Pugs_MeshDataBase PugsUtils PugsAlgebra PugsMesh diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp index f1140b479..df55a88dc 100644 --- a/tests/mpi_test_main.cpp +++ b/tests/mpi_test_main.cpp @@ -3,9 +3,15 @@ #include <Kokkos_Core.hpp> +#include <mesh/DiamondDualConnectivityManager.hpp> +#include <mesh/DiamondDualMeshManager.hpp> +#include <mesh/MeshDataManager.hpp> +#include <mesh/SynchronizerManager.hpp> #include <utils/Messenger.hpp> #include <utils/pugs_config.hpp> +#include <test_MeshDataBase.hpp> + #include <cstdlib> #include <filesystem> @@ -30,9 +36,6 @@ main(int argc, char* argv[]) if (parallel::rank() != 0) { // Disable outputs for ranks != 0 setenv("GCOV_PREFIX", gcov_prefix.string().c_str(), 1); - - std::cout << "putting gcov infos in " << gcov_prefix.string() << '\n'; - parallel_output /= output_base_name + std::to_string(parallel::rank()); Catch::ConfigData data{session.configData()}; @@ -43,7 +46,13 @@ main(int argc, char* argv[]) if (result == 0) { // Disable outputs from tested classes to the standard output std::cout.setstate(std::ios::badbit); - result = session.run(); + + SynchronizerManager::create(); + MeshDataManager::create(); + DiamondDualConnectivityManager::create(); + DiamondDualMeshManager::create(); + + test_MeshDataBase::create(); if (parallel::rank() == 0) { if (parallel::size() > 1) { @@ -59,6 +68,15 @@ main(int argc, char* argv[]) } } } + + result = session.run(); + + test_MeshDataBase::destroy(); + + DiamondDualMeshManager::destroy(); + DiamondDualConnectivityManager::destroy(); + MeshDataManager::destroy(); + SynchronizerManager::destroy(); } Kokkos::finalize(); diff --git a/tests/test_MeshDataBase.cpp b/tests/test_MeshDataBase.cpp new file mode 100644 index 000000000..971f5cd5b --- /dev/null +++ b/tests/test_MeshDataBase.cpp @@ -0,0 +1,33 @@ +#include <test_MeshDataBase.hpp> +#include <utils/PugsAssert.hpp> + +#include <mesh/CartesianMeshBuilder.hpp> + +const test_MeshDataBase* test_MeshDataBase::m_instance = nullptr; + +test_MeshDataBase::test_MeshDataBase() +{ + std::make_shared<CartesianMeshBuilder>(TinyVector<3>{0, 1, 0}, TinyVector<3>{2, -1, 3}, + TinyVector<3, size_t>{6, 7, 3}); +} + +const test_MeshDataBase& +test_MeshDataBase::get() +{ + return *m_instance; +} + +void +test_MeshDataBase::create() +{ + Assert(m_instance == nullptr); + m_instance = new test_MeshDataBase(); +} + +void +test_MeshDataBase::destroy() +{ + Assert(m_instance != nullptr); + delete m_instance; + m_instance = nullptr; +} diff --git a/tests/test_MeshDataBase.hpp b/tests/test_MeshDataBase.hpp new file mode 100644 index 000000000..d5e84c8e7 --- /dev/null +++ b/tests/test_MeshDataBase.hpp @@ -0,0 +1,23 @@ +#ifndef TEST_MESH_DATA_BASE_HPP +#define TEST_MESH_DATA_BASE_HPP + +#include <mesh/IMesh.hpp> + +#include <memory> + +class test_MeshDataBase +{ + private: + explicit test_MeshDataBase(); + + static const test_MeshDataBase* m_instance; + + public: + static const test_MeshDataBase& get(); + static void create(); + static void destroy(); + + ~test_MeshDataBase() = default; +}; + +#endif // TEST_MESH_DATA_BASE_HPP diff --git a/tests/test_main.cpp b/tests/test_main.cpp index eba6d05d0..2a9b6268f 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -3,9 +3,18 @@ #include <Kokkos_Core.hpp> +#include <mesh/DiamondDualConnectivityManager.hpp> +#include <mesh/DiamondDualMeshManager.hpp> +#include <mesh/MeshDataManager.hpp> +#include <mesh/SynchronizerManager.hpp> +#include <utils/Messenger.hpp> + +#include <test_MeshDataBase.hpp> + int main(int argc, char* argv[]) { + parallel::Messenger::create(argc, argv); Kokkos::initialize({4, -1, -1, true}); Catch::Session session; @@ -14,10 +23,26 @@ main(int argc, char* argv[]) if (result == 0) { // Disable outputs from tested classes to the standard output std::cout.setstate(std::ios::badbit); + + SynchronizerManager::create(); + MeshDataManager::create(); + DiamondDualConnectivityManager::create(); + DiamondDualMeshManager::create(); + + test_MeshDataBase::create(); + result = session.run(); + + test_MeshDataBase::destroy(); + + DiamondDualMeshManager::destroy(); + DiamondDualConnectivityManager::destroy(); + MeshDataManager::destroy(); + SynchronizerManager::destroy(); } Kokkos::finalize(); - + parallel::Messenger::destroy(); + std::cout << "finalizing\n"; return result; } -- GitLab