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"
26#include "Algorithm/Parser.h"
27#include <string>
28#include <array>
29#include <vector>
30#include <mutex>
31#include <functional>
32#include <queue>
33
34class TStopwatch;
35namespace fair::mq
36{
37struct RegionInfo;
38enum class State : int32_t;
39} // namespace fair::mq
40namespace o2
41{
42namespace base
43{
44struct GRPGeomRequest;
45} // namespace base
46namespace tpc
47{
48class CalibdEdxContainer;
49struct ClusterGroupHeader;
50class VDriftHelper;
51class CorrectionMapsLoader;
52class DeadChannelMapCreator;
53} // namespace tpc
54
55namespace trd
56{
57class GeometryFlat;
58} // namespace trd
59
60namespace its
61{
62template <int>
63class TimeFrame;
64class ITSTrackingInterface;
65} // namespace its
66
67namespace itsmft
68{
69class TopologyDictionary;
70} // namespace itsmft
71
72namespace dataformats
73{
75} // namespace dataformats
76
77namespace gpu
78{
79struct GPUO2InterfaceConfiguration;
80class GPUDisplayFrontendInterface;
81class CorrectionMapsHelper;
82class TPCFastTransformPOD;
83struct GPUSettingsTF;
84class GPUO2Interface;
85struct TPCPadGainCalib;
86struct TPCZSLinkMapping;
87struct GPUSettingsO2;
88struct GPUSettingsProcessingNNclusterizer;
89class GPUTRDRecoParam;
90class GPUO2InterfaceQA;
91struct GPUTrackingInOutPointers;
92struct GPUTrackingInOutZS;
93struct GPUInterfaceOutputs;
94struct GPUInterfaceInputUpdate;
95namespace gpurecoworkflow_internals
96{
100} // namespace gpurecoworkflow_internals
101
103{
104 public:
105 using CompletionPolicyData = std::vector<framework::InputSpec>;
106
107 struct Config {
108 int32_t itsTriggerType = 0;
109 bool enableCTPLumi = false;
111 int32_t tpcDeadMapSources = -1;
112 bool tpcUseMCTimeGain = false; // use time gain calibration for MC (true) or from data (false)
113 bool decompressTPC = false;
115 bool caClusterer = false;
116 bool zsDecoder = false;
117 bool zsOnTheFly = false;
118 bool outputTracks = false;
121 bool outputCAClusters = false;
122 bool outputQA = false;
124 bool processMC = false;
126 bool askDISTSTF = true;
127 bool runTPCTracking = false;
128 bool runTRDTracking = false;
129 bool readTRDtracklets = false;
130 bool outputErrorQA = false;
131 bool runITSTracking = false;
132 bool itsStaggered = false;
133 bool itsOverrBeamEst = false;
134 bool tpcTriggerHandling = false;
135 bool isITS3 = false;
137
138 // NN clusterizer
139 bool nnLoadFromCCDB = false;
140 bool nnDumpToFile = false;
141 std::vector<std::string> nnEvalMode;
142 };
143
144 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);
146 void init(o2::framework::InitContext& ic) final;
149 void stop() final;
150 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
154
155 void deinitialize();
156
157 private:
158 struct calibObjectStruct {
159 std::vector<char> mUpdatedTransformBuffer;
160 std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalib;
161 std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainer;
162 float mInstLumiCTP{-1};
164 };
165
167 void initFunctionTPCCalib(o2::framework::InitContext& ic);
168 void initFunctionITS(o2::framework::InitContext& ic);
170 void finaliseCCDBTPC(o2::framework::ConcreteDataMatcher& matcher, void* obj);
171 void finaliseCCDBITS(o2::framework::ConcreteDataMatcher& matcher, void* obj);
173 template <class T>
174 bool fetchCalibsCCDBTPC(o2::framework::ProcessingContext& pc, T& newCalibObjects, calibObjectStruct& oldCalibObjects);
175 bool fetchCalibsCCDBITS(o2::framework::ProcessingContext& pc);
177 void cleanOldCalibsTPCPtrs(calibObjectStruct& oldCalibObjects);
178
179 void doCalibUpdates(o2::framework::ProcessingContext& pc, calibObjectStruct& oldCalibObjects);
180
181 void doTrackTuneTPC(GPUTrackingInOutPointers& ptrs, char* buffout);
182
183 template <class D, class E, class F, class G, class H, class I, class J, class K>
184 void processInputs(o2::framework::ProcessingContext&, D&, E&, F&, G&, bool&, H&, I&, J&, K&);
185
186 int32_t runMain(o2::framework::ProcessingContext* pc, GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, int32_t threadIndex = 0, GPUInterfaceInputUpdate* inputUpdateCallback = nullptr);
187 int32_t runITSTracking(o2::framework::ProcessingContext& pc);
188
189 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);
190 void RunReceiveThread();
191 void RunWorkerThread(int32_t id);
192 void ExitPipeline();
193 void handlePipelineEndOfStream(o2::framework::EndOfStreamContext& ec);
194 void handlePipelineStop();
195 void initPipeline(o2::framework::InitContext& ic);
196 void enqueuePipelinedJob(GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, gpurecoworkflow_internals::GPURecoWorkflow_QueueObject* context, bool inputFinal);
197 void finalizeInputPipelinedJob(GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, gpurecoworkflow_internals::GPURecoWorkflow_QueueObject* context);
198 void receiveFMQStateCallback(fair::mq::State);
199
200 CompletionPolicyData* mPolicyData;
201 std::function<bool(o2::framework::DataProcessingHeader::StartTime)> mPolicyOrder;
202 std::unique_ptr<GPUO2Interface> mGPUReco;
203 std::unique_ptr<GPUDisplayFrontendInterface> mDisplayFrontend;
204
205 calibObjectStruct mCalibObjects;
206 std::unique_ptr<o2::tpc::DeadChannelMapCreator> mTPCDeadChannelMapCreator;
207 std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainerBufferNew;
208 std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalibBufferNew;
209 std::queue<calibObjectStruct> mOldCalibObjects;
210 std::unique_ptr<TPCZSLinkMapping> mTPCZSLinkMapping;
211 std::unique_ptr<o2::tpc::VDriftHelper> mTPCVDriftHelper;
212 std::unique_ptr<o2::trd::GeometryFlat> mTRDGeometry;
213 std::unique_ptr<GPUTRDRecoParam> mTRDRecoParam;
214 std::unique_ptr<GPUO2InterfaceConfiguration> mConfig;
215 std::unique_ptr<GPUSettingsO2> mConfParam;
216 std::unique_ptr<TStopwatch> mTimer;
217 std::vector<std::array<uint32_t, 4>> mErrorQA;
218 int32_t mQATaskMask = 0;
219 std::unique_ptr<GPUO2InterfaceQA> mQA;
220 std::vector<int32_t> mClusterOutputIds;
221 std::vector<int32_t> mTPCSectors;
222 std::unique_ptr<o2::its::ITSTrackingInterface> mITSTrackingInterface;
223 std::unique_ptr<gpurecoworkflow_internals::GPURecoWorkflowSpec_PipelineInternals> mPipeline;
224 o2::its::TimeFrame<7>* mITSTimeFrame = nullptr;
225 std::vector<fair::mq::RegionInfo> mRegionInfos;
226 const o2::itsmft::TopologyDictionary* mITSDict = nullptr;
227 const o2::dataformats::MeanVertexObject* mMeanVertex;
228 uint64_t mTPCSectorMask = 0;
229 int64_t mCreationForCalib = -1;
230 int32_t mVerbosity = 0;
231 uint32_t mNTFs = 0;
232 uint32_t mNTFDumps = 0;
233 uint32_t mNDebugDumps = 0;
234 uint32_t mNextThreadIndex = 0;
235 bool mUpdateGainMapCCDB = true;
236 std::unique_ptr<o2::gpu::GPUSettingsTF> mTFSettings;
237 std::map<std::string, std::string> nnCCDBSettings;
238
239 Config mSpecConfig;
240 std::shared_ptr<o2::base::GRPGeomRequest> mGGR;
241 bool mGRPGeomUpdated = false;
242 bool mAutoContinuousMaxTimeBin = false;
243 bool mAutoSolenoidBz = false;
244 bool mMatLUTCreated = false;
245 bool mITSGeometryCreated = false;
246 bool mTRDGeometryCreated = false;
247 bool mTRDRecoParamCreated = false;
248 bool mPropagatorInstanceCreated = false;
249 int32_t mTPCCutAtTimeBin = -1;
250};
251
252} // end namespace gpu
253} // end namespace o2
254
255#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