Project
Loading...
Searching...
No Matches
GPUWorkflowSpec.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#ifndef O2_GPU_WORKFLOW_SPEC_H
18#define O2_GPU_WORKFLOW_SPEC_H
19
21#include "Framework/Task.h"
25#include "Algorithm/Parser.h"
26#include <string>
27#include <array>
28#include <vector>
29#include <mutex>
30#include <functional>
31#include <queue>
32
33class TStopwatch;
34namespace fair::mq
35{
36struct RegionInfo;
37enum class State : int32_t;
38} // namespace fair::mq
39namespace o2
40{
41namespace base
42{
43struct GRPGeomRequest;
44} // namespace base
45namespace tpc
46{
47class CalibdEdxContainer;
48struct ClusterGroupHeader;
49class VDriftHelper;
50class CorrectionMapsLoader;
51class DeadChannelMapCreator;
52} // namespace tpc
53
54namespace trd
55{
56class GeometryFlat;
57} // namespace trd
58
59namespace its
60{
61template <int>
62class TimeFrame;
63class ITSTrackingInterface;
64} // namespace its
65
66namespace itsmft
67{
68class TopologyDictionary;
69} // namespace itsmft
70
71namespace dataformats
72{
74} // namespace dataformats
75
76namespace gpu
77{
78struct GPUO2InterfaceConfiguration;
79class GPUDisplayFrontendInterface;
80class CorrectionMapsHelper;
81class TPCFastTransform;
82struct GPUSettingsTF;
83class GPUO2Interface;
84struct TPCPadGainCalib;
85struct TPCZSLinkMapping;
86struct GPUSettingsO2;
87struct GPUSettingsProcessingNNclusterizer;
88class GPUTRDRecoParam;
89class GPUO2InterfaceQA;
90struct GPUTrackingInOutPointers;
91struct GPUTrackingInOutZS;
92struct GPUInterfaceOutputs;
93struct GPUInterfaceInputUpdate;
94namespace gpurecoworkflow_internals
95{
99} // namespace gpurecoworkflow_internals
100
102{
103 public:
104 using CompletionPolicyData = std::vector<framework::InputSpec>;
105
106 struct Config {
107 int32_t itsTriggerType = 0;
108 int32_t lumiScaleMode = 0;
110 bool enableMShape = false;
111 bool enableCTPLumi = false;
113 int32_t tpcDeadMapSources = -1;
114 bool tpcUseMCTimeGain = false; // use time gain calibration for MC (true) or from data (false)
115 bool decompressTPC = false;
117 bool caClusterer = false;
118 bool zsDecoder = false;
119 bool zsOnTheFly = false;
120 bool outputTracks = false;
123 bool outputCAClusters = false;
124 bool outputQA = false;
126 bool processMC = false;
128 bool askDISTSTF = true;
129 bool runTPCTracking = false;
130 bool runTRDTracking = false;
131 bool readTRDtracklets = false;
132 int32_t lumiScaleType = 0; // 0=off, 1=CTP, 2=TPC scalers
133 bool outputErrorQA = false;
134 bool runITSTracking = false;
135 bool itsStaggered = false;
136 bool itsOverrBeamEst = false;
137 bool tpcTriggerHandling = false;
138 bool isITS3 = false;
140
141 // NN clusterizer
142 bool nnLoadFromCCDB = false;
143 bool nnDumpToFile = false;
144 std::vector<std::string> nnEvalMode;
145 };
146
147 GPURecoWorkflowSpec(CompletionPolicyData* policyData, Config const& specconfig, std::vector<int32_t> const& tpcsectors, uint64_t tpcSectorMask, std::shared_ptr<o2::base::GRPGeomRequest>& ggr, std::function<bool(o2::framework::DataProcessingHeader::StartTime)>** gPolicyOrder = nullptr);
149 void init(o2::framework::InitContext& ic) final;
152 void stop() final;
153 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
157
158 void deinitialize();
159
160 private:
161 struct calibObjectStruct {
162 std::unique_ptr<TPCFastTransform> mFastTransform;
163 std::unique_ptr<TPCFastTransform> mFastTransformRef;
164 std::unique_ptr<TPCFastTransform> mFastTransformMShape;
165 std::unique_ptr<o2::tpc::CorrectionMapsLoader> mFastTransformHelper;
166 std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalib;
167 std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainer;
168 };
169
171 void initFunctionTPCCalib(o2::framework::InitContext& ic);
172 void initFunctionITS(o2::framework::InitContext& ic);
174 void finaliseCCDBTPC(o2::framework::ConcreteDataMatcher& matcher, void* obj);
175 void finaliseCCDBITS(o2::framework::ConcreteDataMatcher& matcher, void* obj);
177 template <class T>
178 bool fetchCalibsCCDBTPC(o2::framework::ProcessingContext& pc, T& newCalibObjects, calibObjectStruct& oldCalibObjects);
179 bool fetchCalibsCCDBITS(o2::framework::ProcessingContext& pc);
181 void cleanOldCalibsTPCPtrs(calibObjectStruct& oldCalibObjects);
182
183 void doCalibUpdates(o2::framework::ProcessingContext& pc, calibObjectStruct& oldCalibObjects);
184
185 void doTrackTuneTPC(GPUTrackingInOutPointers& ptrs, char* buffout);
186
187 template <class D, class E, class F, class G, class H, class I, class J, class K>
188 void processInputs(o2::framework::ProcessingContext&, D&, E&, F&, G&, bool&, H&, I&, J&, K&);
189
190 int32_t runMain(o2::framework::ProcessingContext* pc, GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, int32_t threadIndex = 0, GPUInterfaceInputUpdate* inputUpdateCallback = nullptr);
191 int32_t runITSTracking(o2::framework::ProcessingContext& pc);
192
193 int32_t handlePipeline(o2::framework::ProcessingContext& pc, GPUTrackingInOutPointers& ptrs, gpurecoworkflow_internals::GPURecoWorkflowSpec_TPCZSBuffers& tpcZSmeta, o2::gpu::GPUTrackingInOutZS& tpcZS, std::unique_ptr<gpurecoworkflow_internals::GPURecoWorkflow_QueueObject>& context);
194 void RunReceiveThread();
195 void RunWorkerThread(int32_t id);
196 void ExitPipeline();
197 void handlePipelineEndOfStream(o2::framework::EndOfStreamContext& ec);
198 void handlePipelineStop();
199 void initPipeline(o2::framework::InitContext& ic);
200 void enqueuePipelinedJob(GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, gpurecoworkflow_internals::GPURecoWorkflow_QueueObject* context, bool inputFinal);
201 void finalizeInputPipelinedJob(GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, gpurecoworkflow_internals::GPURecoWorkflow_QueueObject* context);
202 void receiveFMQStateCallback(fair::mq::State);
203
204 CompletionPolicyData* mPolicyData;
205 std::function<bool(o2::framework::DataProcessingHeader::StartTime)> mPolicyOrder;
206 std::unique_ptr<GPUO2Interface> mGPUReco;
207 std::unique_ptr<GPUDisplayFrontendInterface> mDisplayFrontend;
208
209 calibObjectStruct mCalibObjects;
210 std::unique_ptr<o2::tpc::DeadChannelMapCreator> mTPCDeadChannelMapCreator;
211 std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainerBufferNew;
212 std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalibBufferNew;
213 std::queue<calibObjectStruct> mOldCalibObjects;
214 std::unique_ptr<TPCZSLinkMapping> mTPCZSLinkMapping;
215 std::unique_ptr<o2::tpc::VDriftHelper> mTPCVDriftHelper;
216 std::unique_ptr<o2::trd::GeometryFlat> mTRDGeometry;
217 std::unique_ptr<GPUTRDRecoParam> mTRDRecoParam;
218 std::unique_ptr<GPUO2InterfaceConfiguration> mConfig;
219 std::unique_ptr<GPUSettingsO2> mConfParam;
220 std::unique_ptr<TStopwatch> mTimer;
221 std::vector<std::array<uint32_t, 4>> mErrorQA;
222 int32_t mQATaskMask = 0;
223 std::unique_ptr<GPUO2InterfaceQA> mQA;
224 std::vector<int32_t> mClusterOutputIds;
225 std::vector<int32_t> mTPCSectors;
226 std::unique_ptr<o2::its::ITSTrackingInterface> mITSTrackingInterface;
227 std::unique_ptr<gpurecoworkflow_internals::GPURecoWorkflowSpec_PipelineInternals> mPipeline;
228 o2::its::TimeFrame<7>* mITSTimeFrame = nullptr;
229 std::vector<fair::mq::RegionInfo> mRegionInfos;
230 const o2::itsmft::TopologyDictionary* mITSDict = nullptr;
231 const o2::dataformats::MeanVertexObject* mMeanVertex;
232 uint64_t mTPCSectorMask = 0;
233 int64_t mCreationForCalib = -1;
234 int32_t mVerbosity = 0;
235 uint32_t mNTFs = 0;
236 uint32_t mNTFDumps = 0;
237 uint32_t mNDebugDumps = 0;
238 uint32_t mNextThreadIndex = 0;
239 bool mUpdateGainMapCCDB = true;
240 std::unique_ptr<o2::gpu::GPUSettingsTF> mTFSettings;
241 std::map<std::string, std::string> nnCCDBSettings;
242
243 Config mSpecConfig;
244 std::shared_ptr<o2::base::GRPGeomRequest> mGGR;
245 bool mGRPGeomUpdated = false;
246 bool mAutoContinuousMaxTimeBin = false;
247 bool mAutoSolenoidBz = false;
248 bool mMatLUTCreated = false;
249 bool mITSGeometryCreated = false;
250 bool mTRDGeometryCreated = false;
251 bool mTRDRecoParamCreated = false;
252 bool mPropagatorInstanceCreated = false;
253 int32_t mTPCCutAtTimeBin = -1;
254};
255
256} // end namespace gpu
257} // end namespace o2
258
259#endif // O2_GPU_WORKFLOW_SPEC_H
Utilities for parsing of data sequences.
std::vector< InputSpec > CompletionPolicyData
o2::framework::Outputs outputs()
std::vector< framework::InputSpec > CompletionPolicyData
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
o2::framework::Inputs inputs()
void run(o2::framework::ProcessingContext &pc) final
void stop() final
This is invoked on stop.
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
o2::framework::Options options()
o2::dataformats::MeanVertexObject MeanVertexObject
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< std::string > nnEvalMode