File indexing completed on 2025-01-30 09:32:32
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Plugins/FpeMonitoring/FpeMonitor.hpp"
0012 #include "ActsExamples/Framework/IAlgorithm.hpp"
0013 #include "ActsExamples/Framework/IContextDecorator.hpp"
0014 #include "ActsExamples/Framework/IReader.hpp"
0015 #include "ActsExamples/Framework/IWriter.hpp"
0016 #include "ActsExamples/Framework/SequenceElement.hpp"
0017 #include "ActsExamples/Utilities/tbbWrap.hpp"
0018 #include <Acts/Utilities/Logger.hpp>
0019
0020 #include <cstddef>
0021 #include <memory>
0022 #include <optional>
0023 #include <stdexcept>
0024 #include <string>
0025 #include <typeinfo>
0026 #include <unordered_map>
0027 #include <utility>
0028 #include <vector>
0029
0030 #include <tbb/enumerable_thread_specific.h>
0031
0032 namespace ActsExamples {
0033 class DataHandleBase;
0034 class IAlgorithm;
0035 class IContextDecorator;
0036 class IReader;
0037 class IWriter;
0038 class SequenceElement;
0039
0040 using IterationCallback = void (*)();
0041
0042
0043 class FpeFailure : public std::runtime_error {
0044 using std::runtime_error::runtime_error;
0045 };
0046
0047 class SequenceConfigurationException : public std::runtime_error {
0048 public:
0049 SequenceConfigurationException()
0050 : std::runtime_error{"Sequence configuration error"} {}
0051 };
0052
0053
0054
0055
0056
0057
0058 class Sequencer {
0059 public:
0060 struct FpeMask {
0061 std::string file;
0062 std::pair<std::size_t, std::size_t> lines;
0063 Acts::FpeType type;
0064 std::size_t count;
0065 };
0066
0067 struct Config {
0068
0069 std::size_t skip = 0;
0070
0071 std::optional<std::size_t> events = std::nullopt;
0072
0073 Acts::Logging::Level logLevel = Acts::Logging::INFO;
0074
0075
0076 int numThreads = -1;
0077
0078 std::string outputDir;
0079
0080 std::string outputTimingFile = "timing.tsv";
0081
0082
0083 IterationCallback iterationCallback = []() {};
0084
0085
0086 bool runDataFlowChecks = true;
0087
0088 bool trackFpes = true;
0089 std::vector<FpeMask> fpeMasks{};
0090 bool failOnFirstFpe = false;
0091 std::size_t fpeStackTraceLength = 8;
0092 };
0093
0094 Sequencer(const Config &cfg);
0095
0096
0097
0098
0099 void addContextDecorator(std::shared_ptr<IContextDecorator> decorator);
0100
0101
0102
0103
0104 void addReader(std::shared_ptr<IReader> reader);
0105
0106
0107
0108
0109 void addAlgorithm(std::shared_ptr<IAlgorithm> algorithm);
0110
0111
0112
0113
0114 void addElement(const std::shared_ptr<SequenceElement> &element);
0115
0116
0117
0118
0119 void addWriter(std::shared_ptr<IWriter> writer);
0120
0121
0122 void addWhiteboardAlias(const std::string &aliasName,
0123 const std::string &objectName);
0124
0125 Acts::FpeMonitor::Result fpeResult() const;
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 int run();
0154
0155
0156 const Config &config() const { return m_cfg; }
0157
0158 private:
0159
0160 std::vector<std::string> listAlgorithmNames() const;
0161
0162 std::pair<std::size_t, std::size_t> determineEventsRange() const;
0163
0164 std::pair<std::string, std::size_t> fpeMaskCount(
0165 const boost::stacktrace::stacktrace &st, Acts::FpeType type) const;
0166
0167 void fpeReport() const;
0168
0169 struct SequenceElementWithFpeResult {
0170 std::shared_ptr<SequenceElement> sequenceElement;
0171 tbb::enumerable_thread_specific<Acts::FpeMonitor::Result> fpeResult{};
0172 };
0173
0174 Config m_cfg;
0175 tbbWrap::task_arena m_taskArena;
0176 std::vector<std::shared_ptr<IContextDecorator>> m_decorators;
0177 std::vector<std::shared_ptr<IReader>> m_readers;
0178 std::vector<SequenceElementWithFpeResult> m_sequenceElements;
0179 std::unique_ptr<const Acts::Logger> m_logger;
0180
0181 std::unordered_map<std::string, std::string> m_whiteboardObjectAliases;
0182
0183 std::unordered_map<std::string, const DataHandleBase *> m_whiteBoardState;
0184
0185 std::atomic<std::size_t> m_nUnmaskedFpe = 0;
0186
0187 const Acts::Logger &logger() const { return *m_logger; }
0188 };
0189
0190 std::ostream &operator<<(std::ostream &os,
0191 const ActsExamples::Sequencer::FpeMask &m);
0192
0193 }