IAP GITLAB

Skip to content
Snippets Groups Projects
Commit d662ea30 authored by Dominik Baack's avatar Dominik Baack Committed by Ralf Ulrich
Browse files

Added first implementations of timeing analytics for processor

parent b4f2653e
No related branches found
No related tags found
No related merge requests found
Showing
with 524 additions and 7 deletions
......@@ -14,8 +14,10 @@
namespace corsika::process {
template <typename TDerived>
struct BoundaryCrossingProcess : public BaseProcess<TDerived> {
class BoundaryCrossingProcess : public BaseProcess<TDerived> {
private:
protected:
public:
/**
* This method is called when a particle crosses the boundary between the nodes
* \p from and \p to.
......
......@@ -24,7 +24,10 @@ namespace corsika::process {
*/
template <typename TDerived>
struct ContinuousProcess : public BaseProcess<TDerived> {
class ContinuousProcess : public BaseProcess<TDerived>{
private:
protected:
public:
// here starts the interface part
// -> enforce TDerived to implement DoContinuous...
......
......@@ -25,7 +25,8 @@ namespace corsika::process {
*/
template <typename TDerived>
struct DecayProcess : BaseProcess<TDerived> {
class DecayProcess : BaseProcess<TDerived> {
public:
using BaseProcess<TDerived>::GetRef;
......
......@@ -25,7 +25,7 @@ namespace corsika::process {
*/
template <typename TDerived>
struct InteractionProcess : public BaseProcess<TDerived> {
class InteractionProcess : public BaseProcess<TDerived> {
using BaseProcess<TDerived>::GetRef;
......
......@@ -25,7 +25,7 @@ namespace corsika::process {
*/
template <typename TDerived>
struct SecondariesProcess : public BaseProcess<TDerived> {
class SecondariesProcess : public BaseProcess<TDerived> {
/// here starts the interface-definition part
// -> enforce TDerived to implement DoSecondaries...
......
......@@ -30,6 +30,8 @@ add_subdirectory (OnShellCheck)
add_subdirectory (InteractionCounter)
add_subdirectory (SwitchProcess)
add_subdirectory (DevTools)
##########################################
# add_custom_target(CORSIKAprocesses)
add_library (CORSIKAprocesses INTERFACE)
......
set (
MODEL_SOURCES
ExecTime.cc
)
set (
MODEL_HEADERS
ExecTime.h
)
set (
MODEL_NAMESPACE
corsika/process/devtools
)
add_library (ProcessDevTools STATIC ${MODEL_SOURCES})
CORSIKA_COPY_HEADERS_TO_NAMESPACE (ProcessDevTools ${MODEL_NAMESPACE} ${MODEL_HEADERS})
set_target_properties (
ProcessDevTools
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
)
# target dependencies on other libraries (also the header onlys)
target_link_libraries (
ProcessDevTools
CORSIKAsetup
)
target_include_directories (
ProcessDevTools
INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include/include>
)
install (
TARGETS ProcessDevTools
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/${MODEL_NAMESPACE}
)
# --------------------
# code unit testing
CORSIKA_ADD_TEST (testExecTime testExecTime.cc)
target_link_libraries (
testExecTime ProcessDevTools
CORSIKAsetup
CORSIKAthirdparty # for catch2
)
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#include <chrono>
#include <iostream>
#include <corsika/process/devtools/ExecTime.h>
namespace corsika::process {
namespace devtools {
template <class T>
void ExecTime<T>::start() {}
template <class T>
void ExecTime<T>::stop() {}
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <chrono>
#include <type_traits>
#include <corsika/process/BoundaryCrossingProcess.h>
#include <corsika/process/ContinuousProcess.h>
#include <corsika/process/DecayProcess.h>
#include <corsika/process/InteractionProcess.h>
#include <corsika/process/SecondariesProcess.h>
#include <corsika/process/StackProcess.h>
namespace corsika::process {
namespace devtools {
template <class T>
class ExecTime : public T {
private:
void start();
void stop();
protected:
public:
float mean();
float min();
float max();
float var();
/// Interface implementation
// Boundary Crossing
template <
typename Particle, typename VTNType,
typename std::enable_if_t<
std::is_base_of<BoundaryCrossingProcess<typename T::TDerived>, T>::type, int> = 0 >
EProcessReturn DoBoundaryCrossing(Particle& p, VTNType const& from,
VTNType const& to) {
return T::DoBoundaryCrossing(p, from, to);
}
// Continous
template <typename Particle, typename Track,
typename std::enable_if_t<
std::is_base_of<ContinuousProcess<typename T::TDerived>, T>::type, int> = 0>
EProcessReturn DoContinuous(Particle& p, Track const& t) const {
return T::DoContinous(p, t);
}
template <typename Particle, typename Track,
typename std::enable_if_t<
std::is_base_of<ContinuousProcess<typename T::TDerived>, T>::type, int> = 0>
units::si::LengthType MaxStepLength(Particle const& p, Track const& track) const {
return T::MaxStepLength(p, track);
}
// Decay
template <typename Particle,
typename std::enable_if_t<
std::is_base_of<DecayProcess<typename T::TDerived>, T>::type, int> = 0>
EProcessReturn DoDecay(Particle& p) {
return T::DoDecay(p);
}
template <typename Particle,
typename std::enable_if_t<
std::is_base_of<DecayProcess<typename T::TDerived>, T>::type, int> = 0>
corsika::units::si::TimeType GetLifetime(Particle& p) {
return T::GetLifetime(p);
}
// Interaction
template <typename Particle,
typename std::enable_if_t<
std::is_base_of<InteractionProcess<typename T::TDerived>, T>::type, int> = 0>
EProcessReturn DoInteraction(Particle& p) {
return T::DoInteraction(p);
}
template <typename TParticle,
typename std::enable_if_t<
std::is_base_of<InteractionProcess<typename T::TDerived>, T>::type, int> = 0>
corsika::units::si::GrammageType GetInteractionLength(TParticle& p) {
return T::GetInteractionLength(p);
}
// Secondaries
template <typename TSecondaries,
typename std::enable_if_t<
std::is_base_of<SecondariesProcess<typename T::TDerived>, T>::type, int> = 0>
inline EProcessReturn DoSecondaries(TSecondaries& sec) {
return T::DoSecondaries(sec);
}
// Stack
template <typename TStack,
typename std::enable_if_t<
std::is_base_of<StackProcess<typename T::TDerived>, T>::type, int> = 0>
inline EProcessReturn DoStack(TStack& stack) {
return T::stack(stack);
}
};
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2019 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
// cpp file
#include <catch2/catch.hpp>
#include <corsika/process/devtools/ExecTime.h>
using namespace corsika::process::devtools;
TEST_CASE("ContinuousProcess interface", "[proccesses][DevTools ExecTime]") {
}
add_subdirectory (Analytics)
add_subdirectory (Dummy)
\ No newline at end of file
add_library (DevTools_Dummy INTERFACE)
set (
DevTools_Dummy_HEADERS
DummyBoundaryCrossingProcess.h
DummyContinuousProcess.h
DummyDecayProcess.h
DummyInteractionProcess.h
DummySecondariesProcess.h
)
set (
DevTools_Dummy_NAMESPACE
corsika/process/devtools
)
CORSIKA_COPY_HEADERS_TO_NAMESPACE (DevTools_Dummy ${DevTools_Dummy_NAMESPACE} ${DevTools_Dummy_HEADERS})
target_include_directories (
DevTools_Dummy
INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include/include>
)
install (
FILES ${DevTools_Dummy_HEADERS}
DESTINATION include/${DevTools_Dummy_NAMESPACE}
)
# --------------------
# code unit testing
CORSIKA_ADD_TEST (TestDummy)
target_link_libraries (
TestDummy
DevTools_Dummy
CORSIKAunits
CORSIKAstackinterface
CORSIKAprocesssequence
CORSIKAsetup
CORSIKAgeometry
CORSIKAenvironment
CORSIKAtesting
)
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <chrono>
#include <thread>
#include <corsika/process/BoundaryCrossingProcess.h>
namespace corsika::process {
namespace devtools {
template <int ISleep>
class DummyBoundaryCrossingProcess : BoundaryCrossingProcess<DummyBoundaryCrossingProcess<ISleep>> {
private:
public:
template <typename Particle, typename VTNType>
EProcessReturn DoBoundaryCrossing(Particle&, VTNType const& from,
VTNType const& to) {
std::this_thread::sleep_for( std::chrono::milliseconds(ISleep) );
return EProcessReturn::eOk;
}
};
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <chrono>
#include <thread>
#include <corsika/process/ContinuousProcess.h>
namespace corsika::process {
namespace devtools {
template <int ISleep>
class DummyContinuousProcess : ContinuousProcess<DummyContinuousProcess<ISleep>> {
private:
public:
template <typename Particle, typename Track>
EProcessReturn DoContinuous(Particle&, Track const&) const {
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return process::EProcessReturn::eOk;
}
template <typename Particle, typename Track>
units::si::LengthType MaxStepLength(Particle const& p, Track const& track) const {
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return units::si::meter * std::numeric_limits<double>::infinity();
}
std::string name() { return "DummyContinuousProcess"; }
};
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <chrono>
#include <thread>
#include <corsika/process/DecayProcess.h>
#include <corsika/units/PhysicalUnits.h>
namespace corsika::process {
namespace devtools {
template <int ISleep>
class DummyDecayProcess : DecayProcess<DummyDecayProcess<ISleep>> {
private:
public:
template <typename Particle>
EProcessReturn DoDecay(Particle&) {
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return process::EProcessReturn::eOk;
}
template <typename Particle>
corsika::units::si::TimeType GetLifetime(Particle& p) {
using namespace corsika::units::si;
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return std::numeric_limits<double>::infinity() * 1_s;
}
};
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <chrono>
#include <thread>
#include <corsika/process/InteractionProcess.h>
namespace corsika::process {
namespace devtools {
template <int ISleep>
class DummyInteractionProcess : InteractionProcess< DummyInteractionProcess<ISleep> > {
private:
public:
template <typename Particle>
EProcessReturn DoInteraction(Particle&)
{
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return process::EProcessReturn::eOk;
}
template <typename TParticle>
corsika::units::si::GrammageType GetInteractionLength(TParticle& p) {
using namespace corsika::units::si;
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return std::numeric_limits<double>::infinity() * (1_g / 1_cm / 1_cm);
}
};
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <chrono>
#include <thread>
#include <corsika/process/SecondariesProcess.h>
namespace corsika::process {
namespace devtools {
template <int ISleep>
class DummySecondariesProcess : SecondariesProcess<DummySecondariesProcess<ISleep>> {
private:
public:
template <typename TSecondaries>
inline EProcessReturn DoSecondaries(TSecondaries&)
{
std::this_thread::sleep_for(
std::chrono::milliseconds(ISleep));
return process::EProcessReturn::eOk;
}
};
} // namespace devtools
} // namespace corsika::process
\ No newline at end of file
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#include <corsika/process/devtools/DummyBoundaryCrossingProcess.h>
#include <corsika/process/devtools/DummyContinuousProcess.h>
#include <corsika/process/devtools/DummyDecayProcess.h>
#include <corsika/process/devtools/DummyInteractionProcess.h>
#include <corsika/process/devtools/DummySecondariesProcess.h>
#include <corsika/process/ProcessReturn.h>
#include <catch2/catch.hpp>
#include <chrono>
using namespace corsika;
using namespace corsika::process;
using namespace corsika::process::devtools;
TEST_CASE("Dummy Processes") {
DummyBoundaryCrossingProcess<1000> dbc;
DummyContinuousProcess<1000> dc;
DummyDecayProcess<1000> dd;
DummyInteractionProcess<1000> di;
DummySecondariesProcess<1000> dse;
int tmp = 0;
SECTION("BoundaryCrossing") {
auto start = std::chrono::steady_clock::now();
REQUIRE(dbc.DoBoundaryCrossing(tmp, 0, 0) == EProcessReturn::eOk);
auto end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
}
SECTION("Continuous") {
auto start = std::chrono::steady_clock::now();
REQUIRE(dc.DoContinuous(tmp, nullptr) == EProcessReturn::eOk);
auto end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
start = std::chrono::steady_clock::now();
REQUIRE(dc.MaxStepLength(nullptr, nullptr) == units::si::meter * std::numeric_limits<double>::infinity());
end = std::chrono::steady_clock::now();
REQUIRE(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() ==
Approx(1000).margin(1));
}
}
......@@ -17,7 +17,7 @@ namespace corsika::process::switch_process {
/**
* This process provides an energy-based switch between two interaction processes P1 and
* P1. For energies below the threshold, P1 is invoked, otherwise P2. Both can be either
* P2. For energies below the threshold, P1 is invoked, otherwise P2. Both can be either
* single interaction processes or multiple ones combined in a ProcessSequence. A
* SwitchProcess itself will always be regarded as a distinct case when assembled into a
* (greater) ProcessSequence.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment