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 GPUO2InterfaceQA;
89struct GPUTrackingInOutPointers;
90struct GPUTrackingInOutZS;
91struct GPUInterfaceOutputs;
92struct GPUInterfaceInputUpdate;
93namespace gpurecoworkflow_internals
94{
98} // namespace gpurecoworkflow_internals
99
101{
102 public:
103 using CompletionPolicyData = std::vector<framework::InputSpec>;
104
105 struct Config {
106 int32_t itsTriggerType = 0;
107 int32_t lumiScaleMode = 0;
108 bool enableMShape = false;
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;
119 bool outputCompClusters = 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 int32_t lumiScaleType = 0; // 0=off, 1=CTP, 2=TPC scalers
131 bool outputErrorQA = false;
132 bool runITSTracking = false;
133 bool itsOverrBeamEst = false;
134 bool tpcTriggerHandling = false;
135 bool isITS3 = false;
136 };
137
138 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);
140 void init(o2::framework::InitContext& ic) final;
143 void stop() final;
144 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
148
149 void deinitialize();
150
151 private:
152 struct calibObjectStruct {
153 std::unique_ptr<TPCFastTransform> mFastTransform;
154 std::unique_ptr<TPCFastTransform> mFastTransformRef;
155 std::unique_ptr<TPCFastTransform> mFastTransformMShape;
156 std::unique_ptr<o2::tpc::CorrectionMapsLoader> mFastTransformHelper;
157 std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalib;
158 std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainer;
159 };
160
162 void initFunctionTPCCalib(o2::framework::InitContext& ic);
163 void initFunctionITS(o2::framework::InitContext& ic);
165 void finaliseCCDBTPC(o2::framework::ConcreteDataMatcher& matcher, void* obj);
166 void finaliseCCDBITS(o2::framework::ConcreteDataMatcher& matcher, void* obj);
168 template <class T>
169 bool fetchCalibsCCDBTPC(o2::framework::ProcessingContext& pc, T& newCalibObjects, calibObjectStruct& oldCalibObjects);
170 bool fetchCalibsCCDBITS(o2::framework::ProcessingContext& pc);
172 void cleanOldCalibsTPCPtrs(calibObjectStruct& oldCalibObjects);
173
174 void doCalibUpdates(o2::framework::ProcessingContext& pc, calibObjectStruct& oldCalibObjects);
175
176 void doTrackTuneTPC(GPUTrackingInOutPointers& ptrs, char* buffout);
177
178 template <class D, class E, class F, class G, class H, class I, class J, class K>
179 void processInputs(o2::framework::ProcessingContext&, D&, E&, F&, G&, bool&, H&, I&, J&, K&);
180
181 int32_t runMain(o2::framework::ProcessingContext* pc, GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, int32_t threadIndex = 0, GPUInterfaceInputUpdate* inputUpdateCallback = nullptr);
182 int32_t runITSTracking(o2::framework::ProcessingContext& pc);
183
184 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);
185 void RunReceiveThread();
186 void RunWorkerThread(int32_t id);
187 void ExitPipeline();
188 void handlePipelineEndOfStream(o2::framework::EndOfStreamContext& ec);
189 void handlePipelineStop();
190 void initPipeline(o2::framework::InitContext& ic);
191 void enqueuePipelinedJob(GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, gpurecoworkflow_internals::GPURecoWorkflow_QueueObject* context, bool inputFinal);
192 void finalizeInputPipelinedJob(GPUTrackingInOutPointers* ptrs, GPUInterfaceOutputs* outputRegions, gpurecoworkflow_internals::GPURecoWorkflow_QueueObject* context);
193 void receiveFMQStateCallback(fair::mq::State);
194
195 CompletionPolicyData* mPolicyData;
196 std::function<bool(o2::framework::DataProcessingHeader::StartTime)> mPolicyOrder;
197 std::unique_ptr<GPUO2Interface> mGPUReco;
198 std::unique_ptr<GPUDisplayFrontendInterface> mDisplayFrontend;
199
200 calibObjectStruct mCalibObjects;
201 std::unique_ptr<o2::tpc::DeadChannelMapCreator> mTPCDeadChannelMapCreator;
202 std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainerBufferNew;
203 std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalibBufferNew;
204 std::queue<calibObjectStruct> mOldCalibObjects;
205 std::unique_ptr<TPCZSLinkMapping> mTPCZSLinkMapping;
206 std::unique_ptr<o2::tpc::VDriftHelper> mTPCVDriftHelper;
207 std::unique_ptr<o2::trd::GeometryFlat> mTRDGeometry;
208 std::unique_ptr<GPUO2InterfaceConfiguration> mConfig;
209 std::unique_ptr<GPUSettingsO2> mConfParam;
210 std::unique_ptr<TStopwatch> mTimer;
211 std::vector<std::array<uint32_t, 4>> mErrorQA;
212 int32_t mQATaskMask = 0;
213 std::unique_ptr<GPUO2InterfaceQA> mQA;
214 std::vector<int32_t> mClusterOutputIds;
215 std::vector<int32_t> mTPCSectors;
216 std::unique_ptr<o2::its::ITSTrackingInterface> mITSTrackingInterface;
217 std::unique_ptr<gpurecoworkflow_internals::GPURecoWorkflowSpec_PipelineInternals> mPipeline;
218 o2::its::TimeFrame<7>* mITSTimeFrame = nullptr;
219 std::vector<fair::mq::RegionInfo> mRegionInfos;
220 const o2::itsmft::TopologyDictionary* mITSDict = nullptr;
221 const o2::dataformats::MeanVertexObject* mMeanVertex;
222 uint64_t mTPCSectorMask = 0;
223 int64_t mCreationForCalib = -1;
224 int32_t mVerbosity = 0;
225 uint32_t mNTFs = 0;
226 uint32_t mNDebugDumps = 0;
227 uint32_t mNextThreadIndex = 0;
228 bool mUpdateGainMapCCDB = true;
229 std::unique_ptr<o2::gpu::GPUSettingsTF> mTFSettings;
230 std::unique_ptr<o2::gpu::GPUSettingsProcessingNNclusterizer> mNNClusterizerSettings;
231
232 Config mSpecConfig;
233 std::shared_ptr<o2::base::GRPGeomRequest> mGGR;
234 bool mGRPGeomUpdated = false;
235 bool mAutoContinuousMaxTimeBin = false;
236 bool mAutoSolenoidBz = false;
237 bool mMatLUTCreated = false;
238 bool mITSGeometryCreated = false;
239 bool mTRDGeometryCreated = false;
240 bool mPropagatorInstanceCreated = false;
241 int32_t mTPCCutAtTimeBin = -1;
242};
243
244} // end namespace gpu
245} // end namespace o2
246
247#endif // O2_GPU_WORKFLOW_SPEC_H
std::vector< InputSpec > CompletionPolicyData
Utilities for parsing of data sequences.
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 ...