Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions .cmake/testing.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
find_package(Git QUIET)

if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)

if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Suppress project warning policy for googletest library
Expand Down Expand Up @@ -80,4 +62,4 @@ if(${BUILD_WITH_GCOVR})
)
endif()

add_definitions(-DWITH_TESTS)
add_definitions(-DWITH_TESTS)
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@ endif()
# ************************
set(CODE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)

find_package(Git QUIET)

if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)

if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

include(eigen)

if(BUILD_WITH_MPI)
Expand All @@ -184,6 +202,9 @@ if(BUILD_WITH_TESTS)
include(testing)
endif()

add_library(mstd INTERFACE)
target_include_directories(mstd INTERFACE ${PROJECT_SOURCE_DIR}/external/mstd/include)

add_subdirectory(src)

if(BUILD_WITH_TESTS)
Expand Down
1 change: 1 addition & 0 deletions changes/developer/enhancement.timer.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- add guarded RAII approach for starting and automatically stopping a timings section with its destructor
- use a dedicated enum class for timers to make it less error prone
2 changes: 1 addition & 1 deletion external/mstd
Submodule mstd updated 65 files
+1 −1 .cppcheck.suppress
+24 −0 .devops.toml
+40 −0 .git_template/hooks/prepare-commit-msg
+1 −1 .github/workflows/build.yml
+16 −5 .github/workflows/check-pr-for-release-version.yml
+44 −5 .github/workflows/create-tag.yml
+35 −0 .github/workflows/docs.yml
+60 −0 .github/workflows/static-analysis.yml
+5 −0 .gitignore
+6 −0 .gitmodules
+8 −1 .vscode/settings.json
+80 −0 CHANGELOG.md
+87 −1 CMakeLists.txt
+0 −1 compile_commands.json
+243 −0 docs/Doxyfile
+1 −0 external/devops
+1 −0 external/mp-units
+43 −0 include/mstd/compile.hpp
+52 −6 include/mstd/enum.hpp
+45 −8 include/mstd/error.hpp
+3 −3 include/mstd/functional.hpp
+3 −3 include/mstd/math.hpp
+4 −4 include/mstd/math/power.hpp
+3 −3 include/mstd/pack.hpp
+4 −4 include/mstd/pack/integer_pack.hpp
+6 −6 include/mstd/pack/integer_pack_details.hpp
+3 −3 include/mstd/pack/integer_pack_operations.hpp
+3 −3 include/mstd/pack/ratio_pack.hpp
+3 −3 include/mstd/pack/ratio_pack_details.hpp
+3 −3 include/mstd/pack/ratio_pack_operations.hpp
+13 −3 include/mstd/physics/potentials/lie_potential.hpp
+7 −3 include/mstd/quantity.hpp
+7 −3 include/mstd/quantity/dim.hpp
+7 −3 include/mstd/quantity/dim_details.hpp
+7 −3 include/mstd/quantity/dim_impl.hpp
+7 −3 include/mstd/quantity/dim_operations.hpp
+7 −3 include/mstd/quantity/dim_ratio.hpp
+7 −3 include/mstd/quantity/dim_ratio_details.hpp
+7 −3 include/mstd/quantity/dim_ratio_impl.hpp
+7 −3 include/mstd/quantity/dim_ratio_operations.hpp
+13 −5 include/mstd/quantity/enums.hpp
+7 −4 include/mstd/quantity/quantity.hpp
+7 −3 include/mstd/quantity/quantity_impl.hpp
+7 −3 include/mstd/quantity/unit.hpp
+7 −3 include/mstd/quantity/unit_details.hpp
+7 −3 include/mstd/quantity/unit_impl.hpp
+7 −3 include/mstd/quantity/unit_operations.hpp
+3 −3 include/mstd/ratio.hpp
+28 −0 include/mstd/string.hpp
+64 −0 include/mstd/string/join.hpp
+5 −3 include/mstd/type_traits.hpp
+52 −0 include/mstd/type_traits/enum_traits.hpp
+2 −0 include/mstd/type_traits/math/arithmetic_traits.hpp
+3 −3 include/mstd/type_traits/pack_traits.hpp
+3 −3 include/mstd/type_traits/quantity_traits.hpp
+43 −0 include/mstd/type_traits/ranges_traits.hpp
+3 −3 include/mstd/type_traits/ratio_traits.hpp
+0 −1 scripts/.gitignore
+14 −0 scripts/cppcheck.sh
+5 −0 scripts/init_repo.sh
+37 −5 test/CMakeLists.txt
+22 −0 test/math/test_cpow.cpp
+2 −0 test/quantity/CMakeLists.txt
+42 −0 test/quantity/test_mp-units.cpp
+3 −3 test/quantity/test_utils.hpp
7 changes: 4 additions & 3 deletions include/timings/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <string> // for string
#include <vector> // for vector

#include "timerId.hpp"
#include "timingsSection.hpp" // for TimingsManager
#include "timingsSectionGuard.hpp"

Expand All @@ -48,12 +49,12 @@ namespace timings
class Timer
{
protected:
std::string _name = "DefaultTimings";
TimerId _id = TimerId::DefaultTimings;

std::vector<TimingsSection> _timingDetails;

public:
explicit Timer(const std::string_view);
explicit Timer(TimerId id);
Timer() = default;

[[nodiscard]]
Expand All @@ -75,7 +76,7 @@ namespace timings
* standard setters *
********************/

void setTimerName(const std::string_view name);
void setTimerId(TimerId id);

/********************
* standard getters *
Expand Down
56 changes: 56 additions & 0 deletions include/timings/timerId.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*****************************************************************************
<GPL_HEADER>

PQ
Copyright (C) 2023-now Jakob Gamper

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

<GPL_HEADER>
******************************************************************************/

#ifndef _TIMER_ID_HPP_
#define _TIMER_ID_HPP_

#include <cstdint>
#include <mstd/enum.hpp>
#include <string>

#define TIMER_ID_LIST(X) \
X(DefaultTimings) \
X(EngineOutput) \
X(Constraints) \
X(CellList) \
X(PhysicalData) \
X(Simulation) \
X(Integrator) \
X(Thermostat) \
X(Manostat) \
X(Output) \
X(Potential) \
X(IntraNonBonded) \
X(Virial) \
X(ResetKinetics) \
X(WaterIntraPotential) \
X(WaterInterPotential) \
X(QMEngine) \
X(Setup)

// TODO: fix this in mstd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this comment about the mstd library really be here?
why not create an issue and add the link or write it altogether in the mstd lib?

// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)
MSTD_ENUM(TimerId, std::uint8_t, TIMER_ID_LIST);

std::string toString(TimerId id);

#endif // _TIMER_ID_HPP_
12 changes: 6 additions & 6 deletions src/engine/hessianEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,22 +485,22 @@ void HessianEngine::writeHessianInfo(const HessianMatrix &hessian) const

void HessianEngine::addTimers()
{
_engineOutput.setTimerName("Output");
_engineOutput.setTimerId(TimerId::Output);
_timer.addTimer(_engineOutput.getTimer());

_constraints->setTimerName("Constraints");
_constraints->setTimerId(TimerId::Constraints);
_timer.addTimer(_constraints->getTimer());

_cellList->setTimerName("Cell List");
_cellList->setTimerId(TimerId::CellList);
_timer.addTimer(_cellList->getTimer());

_potential->setTimerName("Potential");
_potential->setTimerId(TimerId::Potential);
_timer.addTimer(_potential->getTimer());

_intraNonBonded->setTimerName("IntraNonBonded");
_intraNonBonded->setTimerId(TimerId::IntraNonBonded);
_timer.addTimer(_intraNonBonded->getTimer());

_physicalData->setTimerName("Physical Data");
_physicalData->setTimerId(TimerId::PhysicalData);
_timer.addTimer(_physicalData->getTimer());
}

Expand Down
30 changes: 15 additions & 15 deletions src/engine/mdEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,49 +77,49 @@ void MDEngine::run()

const auto elapsedTime = double(_timer.calculateElapsedTime()) * 1e-3;

_engineOutput.setTimerName("Output");
_engineOutput.setTimerId(TimerId::Output);
_timer.addTimer(_engineOutput.getTimer());

_thermostat->setTimerName("Thermostat");
_thermostat->setTimerId(TimerId::Thermostat);
_timer.addTimer(_thermostat->getTimer());

_integrator->setTimerName("Integrator");
_integrator->setTimerId(TimerId::Integrator);
_timer.addTimer(_integrator->getTimer());

_constraints->setTimerName("Constraints");
_constraints->setTimerId(TimerId::Constraints);
_timer.addTimer(_constraints->getTimer());

_cellList->setTimerName("Cell List");
_cellList->setTimerId(TimerId::CellList);
_timer.addTimer(_cellList->getTimer());

_potential->setTimerName("Potential");
_potential->setTimerId(TimerId::Potential);
_timer.addTimer(_potential->getTimer());

_intraNonBonded->setTimerName("IntraNonBonded");
_intraNonBonded->setTimerId(TimerId::IntraNonBonded);
_timer.addTimer(_intraNonBonded->getTimer());

_virial->setTimerName("Virial");
_virial->setTimerId(TimerId::Virial);
_timer.addTimer(_virial->getTimer());

_physicalData->setTimerName("Physical Data");
_physicalData->setTimerId(TimerId::PhysicalData);
_timer.addTimer(_physicalData->getTimer());

_manostat->setTimerName("Manostat");
_manostat->setTimerId(TimerId::Manostat);
_timer.addTimer(_manostat->getTimer());

_resetKinetics.setTimerName("Reset Kinetics");
_resetKinetics.setTimerId(TimerId::ResetKinetics);
_timer.addTimer(_resetKinetics.getTimer());

_intraWater->setTimerName("Water Intra Potential");
_intraWater->setTimerId(TimerId::WaterIntraPotential);
_timer.addTimer(_intraWater->getTimer());

_interWater->setTimerName("Water Inter Potential");
_interWater->setTimerId(TimerId::WaterInterPotential);
_timer.addTimer(_interWater->getTimer());

if (Settings::isQMActivated())
{
dynamic_cast<QMCapableEngine *>(this)->getQMRunner()->setTimerName(
"QM Engine"
dynamic_cast<QMCapableEngine *>(this)->getQMRunner()->setTimerId(
TimerId::QMEngine
);
_timer.addTimer(
dynamic_cast<QMCapableEngine *>(this)->getQMRunner()->getTimer()
Expand Down
12 changes: 6 additions & 6 deletions src/engine/optEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,22 @@ void OptEngine::run()

const auto elapsedTime = double(_timer.calculateElapsedTime()) * 1e-3;

_engineOutput.setTimerName("Output");
_engineOutput.setTimerId(TimerId::Output);
_timer.addTimer(_engineOutput.getTimer());

_constraints->setTimerName("Constraints");
_constraints->setTimerId(TimerId::Constraints);
_timer.addTimer(_constraints->getTimer());

_cellList->setTimerName("Cell List");
_cellList->setTimerId(TimerId::CellList);
_timer.addTimer(_cellList->getTimer());

_potential->setTimerName("Potential");
_potential->setTimerId(TimerId::Potential);
_timer.addTimer(_potential->getTimer());

_intraNonBonded->setTimerName("IntraNonBonded");
_intraNonBonded->setTimerId(TimerId::IntraNonBonded);
_timer.addTimer(_intraNonBonded->getTimer());

_physicalData->setTimerName("Physical Data");
_physicalData->setTimerId(TimerId::PhysicalData);
_timer.addTimer(_physicalData->getTimer());

_engineOutput.writeTimingsFile(_timer);
Expand Down
2 changes: 1 addition & 1 deletion src/setup/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ using namespace setup::resetKinetics;
*/
void setup::setupRequestedJob(const std::string& inputFileName, Engine& engine)
{
auto setupTimer = Timer("Setup");
auto setupTimer = Timer(TimerId::Setup);

auto _ = setupTimer.scoped("TotalSetup");

Expand Down
2 changes: 2 additions & 0 deletions src/timings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_library(timings
timer.cpp
timerId.cpp
timingsSection.cpp
timingsSectionGuard.cpp
globalTimer.cpp
Expand All @@ -15,6 +16,7 @@ target_link_libraries(timings
PUBLIC
exceptions
settings
mstd
)

install(TARGETS timings
Expand Down
2 changes: 1 addition & 1 deletion src/timings/globalTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace timings;
* @brief Construct a new Global Timer:: Global Timer object
*
*/
GlobalTimer::GlobalTimer() : _simulationTimer("Simulation")
GlobalTimer::GlobalTimer() : _simulationTimer(TimerId::Simulation)
{
_simulationTimer.startTimingsSection();
}
Expand Down
18 changes: 9 additions & 9 deletions src/timings/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ using namespace customException;
/**
* @brief Construct a new Timer:: Timer object
*
* @param name
* @param id
*/
Timer::Timer(const std::string_view name) : _name(name) {}
Timer::Timer(const TimerId id) : _id(id) {}

/**
* @brief get timings details
Expand Down Expand Up @@ -79,11 +79,11 @@ double Timer::calculateLoopTime() const
*/
void Timer::startTimingsSection()
{
const auto index = findTimingsSectionIndex(_name);
const auto index = findTimingsSectionIndex(getTimerName());

if (index == _timingDetails.size())
{
_timingDetails.emplace_back(_name);
_timingDetails.emplace_back(getTimerName());
_timingDetails.back().beginTimer();
}
else
Expand Down Expand Up @@ -113,7 +113,7 @@ void Timer::startTimingsSection(const std::string_view name)
*/
void Timer::stopTimingsSection()
{
const auto index = findTimingsSectionIndex(_name);
const auto index = findTimingsSectionIndex(getTimerName());

if (index == _timingDetails.size())
throw CustomException("Timer not found");
Expand Down Expand Up @@ -166,11 +166,11 @@ void Timer::sortTimingsSections()
********************/

/**
* @brief set timer name
* @brief set timer id
*
* @param name
* @param id
*/
void Timer::setTimerName(const std::string_view name) { _name = name; }
void Timer::setTimerId(const TimerId id) { _id = id; }

/********************
* standard getters *
Expand All @@ -195,7 +195,7 @@ TimingsSection Timer::getTimingsSection(const std::string_view name) const
*
* @return std::string
*/
std::string Timer::getTimerName() const { return _name; }
std::string Timer::getTimerName() const { return toString(_id); }

/**
* @brief get timer
Expand Down
Loading
Loading