From ad7bff9b2b68f9ff6cc95d0eefb3cdf3117e9a35 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Tue, 18 Sep 2018 14:54:38 +0200 Subject: [PATCH] Add simple embedding for initialize and finalize functions --- src/main.cpp | 47 +++++++++------------------------------ src/utils/CMakeLists.txt | 3 ++- src/utils/PastisUtils.cpp | 12 ++++++++++ src/utils/PastisUtils.hpp | 4 ++++ 4 files changed, 28 insertions(+), 38 deletions(-) create mode 100644 src/utils/PastisUtils.cpp diff --git a/src/main.cpp b/src/main.cpp index 064a38227..941ed40e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,38 +87,11 @@ int main(int argc, char *argv[]) std::cout << ")\n"; std::cout << "-------------------------------------------------------\n"; - Kokkos::initialize(argc, argv); + initialize(argc, argv); Kokkos::DefaultExecutionSpace::print_configuration(std::cout); std::map<std::string, double> method_cost_map; - // { // Basic function based acoustic solver - // Kokkos::Timer timer; - // timer.reset(); - // RawKokkos::AcousticSolver(number); - // method_cost_map["RawKokkos"] = timer.seconds(); - // } - - // { // class for acoustic solver (mesh less) - // Kokkos::Timer timer; - // timer.reset(); - // MeshLessAcousticSolver acoustic_solver(number); - // method_cost_map["MeshLessAcousticSolver"] = timer.seconds(); - // } - - // { // class for acoustic solver - // Kokkos::Timer timer; - // timer.reset(); - // AcousticSolverClass acoustic_solver(number); - // method_cost_map["AcousticSolverClass"] = timer.seconds(); - // } - - // { // class for acoustic solver test - // Kokkos::Timer timer; - // timer.reset(); - // AcousticSolverTest acoustic_solver(number); - // method_cost_map["AcousticSolverTest"] = timer.seconds(); - // } try { if (filename != "") { std::cout << "Reading (gmsh) " << rang::style::underline << filename << rang::style::reset << " ...\n"; @@ -444,7 +417,7 @@ int main(int argc, char *argv[]) std::exit(1); } - Kokkos::finalize(); + finalize(); std::string::size_type size=0; for (const auto& method_cost : method_cost_map) { @@ -453,14 +426,14 @@ int main(int argc, char *argv[]) for (const auto& method_cost : method_cost_map) { std::cout << "* [" - << rang::fgB::cyan - << std::setw(size) << std::left - << method_cost.first - << rang::fg::reset - << "] Execution time: " - << rang::style::bold - << method_cost.second - << rang::style::reset << '\n'; + << rang::fgB::cyan + << std::setw(size) << std::left + << method_cost.first + << rang::fg::reset + << "] Execution time: " + << rang::style::bold + << method_cost.second + << rang::style::reset << '\n'; } return 0; diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index ad047d0ea..3599d7ae8 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -8,6 +8,7 @@ add_library( BacktraceManager.cpp ConsoleManager.cpp FPEManager.cpp + PastisUtils.cpp RevisionInfo.cpp SignalManager.cpp) @@ -35,7 +36,7 @@ add_custom_command(TARGET PastisGitRevison DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision.hpp COMMENT "" ) - + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision.hpp PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different diff --git a/src/utils/PastisUtils.cpp b/src/utils/PastisUtils.cpp new file mode 100644 index 000000000..c86974b81 --- /dev/null +++ b/src/utils/PastisUtils.cpp @@ -0,0 +1,12 @@ +#include <PastisUtils.hpp> +#include <Kokkos_Core.hpp> + +void initialize(int& argc, char* argv[]) +{ + Kokkos::initialize(argc,argv); +} + +void finalize() +{ + Kokkos::finalize(); +} diff --git a/src/utils/PastisUtils.hpp b/src/utils/PastisUtils.hpp index adf12176f..939b76f0b 100644 --- a/src/utils/PastisUtils.hpp +++ b/src/utils/PastisUtils.hpp @@ -26,4 +26,8 @@ void parallel_reduce(const size_t& size, Kokkos::parallel_reduce(label, size, array, value); } +void initialize(int& argc, char* argv[]); + +void finalize(); + #endif // PASTIS_UTILS_HPP -- GitLab