Skip to content

Commit 8a5548d

Browse files
committed
GPU: Clean up deletion of old calib objects
1 parent 793e5c1 commit 8a5548d

File tree

3 files changed

+110
-109
lines changed

3 files changed

+110
-109
lines changed

GPU/Workflow/include/GPUWorkflow/GPUWorkflowSpec.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <vector>
2929
#include <mutex>
3030
#include <functional>
31+
#include <queue>
3132

3233
class TStopwatch;
3334
namespace fair::mq
@@ -141,6 +142,14 @@ class GPURecoWorkflowSpec : public o2::framework::Task
141142
void deinitialize();
142143

143144
private:
145+
struct calibObjectStruct {
146+
std::unique_ptr<TPCFastTransform> mFastTransform;
147+
std::unique_ptr<TPCFastTransform> mFastTransformRef;
148+
std::unique_ptr<o2::tpc::CorrectionMapsLoader> mFastTransformHelper;
149+
std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalib;
150+
std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainer;
151+
};
152+
144153
/// initialize TPC options from command line
145154
void initFunctionTPCCalib(o2::framework::InitContext& ic);
146155
void initFunctionITS(o2::framework::InitContext& ic);
@@ -149,12 +158,12 @@ class GPURecoWorkflowSpec : public o2::framework::Task
149158
void finaliseCCDBITS(o2::framework::ConcreteDataMatcher& matcher, void* obj);
150159
/// asking for newer calib objects
151160
template <class T>
152-
bool fetchCalibsCCDBTPC(o2::framework::ProcessingContext& pc, T& newCalibObjects);
161+
bool fetchCalibsCCDBTPC(o2::framework::ProcessingContext& pc, T& newCalibObjects, calibObjectStruct& oldCalibObjects);
153162
bool fetchCalibsCCDBITS(o2::framework::ProcessingContext& pc);
154-
/// storing the new calib objects by overwritting the old calibs
155-
void cleanOldCalibsTPCPtrs();
163+
/// delete old calib objects no longer needed
164+
void cleanOldCalibsTPCPtrs(calibObjectStruct& oldCalibObjects);
156165

157-
void doCalibUpdates(o2::framework::ProcessingContext& pc);
166+
void doCalibUpdates(o2::framework::ProcessingContext& pc, calibObjectStruct& oldCalibObjects);
158167

159168
void doTrackTuneTPC(GPUTrackingInOutPointers& ptrs, char* buffout);
160169

@@ -178,18 +187,12 @@ class GPURecoWorkflowSpec : public o2::framework::Task
178187
std::function<bool(o2::framework::DataProcessingHeader::StartTime)> mPolicyOrder;
179188
std::unique_ptr<GPUO2Interface> mGPUReco;
180189
std::unique_ptr<GPUDisplayFrontendInterface> mDisplayFrontend;
181-
std::unique_ptr<TPCFastTransform> mFastTransform;
182-
std::unique_ptr<TPCFastTransform> mFastTransformRef;
183-
std::unique_ptr<TPCFastTransform> mFastTransformNew;
184-
std::unique_ptr<TPCFastTransform> mFastTransformRefNew;
185-
std::unique_ptr<o2::tpc::CorrectionMapsLoader> mFastTransformHelper;
186-
std::unique_ptr<o2::tpc::CorrectionMapsLoader> mFastTransformHelperNew;
187-
188-
std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalib;
190+
191+
calibObjectStruct mCalibObjects;
192+
std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainerBufferNew;
189193
std::unique_ptr<TPCPadGainCalib> mTPCPadGainCalibBufferNew;
194+
std::queue<calibObjectStruct> mOldCalibObjects;
190195
std::unique_ptr<TPCZSLinkMapping> mTPCZSLinkMapping;
191-
std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainer;
192-
std::unique_ptr<o2::tpc::CalibdEdxContainer> mdEdxCalibContainerBufferNew;
193196
std::unique_ptr<o2::tpc::VDriftHelper> mTPCVDriftHelper;
194197
std::unique_ptr<o2::trd::GeometryFlat> mTRDGeometry;
195198
std::unique_ptr<GPUO2InterfaceConfiguration> mConfig;
@@ -223,7 +226,6 @@ class GPURecoWorkflowSpec : public o2::framework::Task
223226
bool mITSGeometryCreated = false;
224227
bool mTRDGeometryCreated = false;
225228
bool mPropagatorInstanceCreated = false;
226-
bool mMustUpdateFastTransform = false;
227229
bool mITSRunVertexer = false;
228230
bool mITSCosmicsProcessing = false;
229231
std::string mITSMode = "sync";

GPU/Workflow/src/GPUWorkflowSpec.cxx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ void GPURecoWorkflowSpec::init(InitContext& ic)
247247
// initialize TPC calib objects
248248
initFunctionTPCCalib(ic);
249249

250-
mConfig->configCalib.fastTransform = mFastTransformHelper->getCorrMap();
251-
mConfig->configCalib.fastTransformRef = mFastTransformHelper->getCorrMapRef();
252-
mConfig->configCalib.fastTransformHelper = mFastTransformHelper.get();
250+
mConfig->configCalib.fastTransform = mCalibObjects.mFastTransformHelper->getCorrMap();
251+
mConfig->configCalib.fastTransformRef = mCalibObjects.mFastTransformHelper->getCorrMapRef();
252+
mConfig->configCalib.fastTransformHelper = mCalibObjects.mFastTransformHelper.get();
253253
if (mConfig->configCalib.fastTransform == nullptr) {
254254
throw std::invalid_argument("GPU workflow: initialization of the TPC transformation failed");
255255
}
@@ -501,14 +501,20 @@ int GPURecoWorkflowSpec::runMain(o2::framework::ProcessingContext* pc, GPUTracki
501501
}
502502
}
503503

504-
cleanOldCalibsTPCPtrs(); // setting TPC calibration objects
505-
506504
if (!mSpecConfig.enableDoublePipeline) { // TODO: Why is this needed for double-pipeline?
507505
mGPUReco->Clear(false, threadIndex); // clean non-output memory used by GPU Reconstruction
508506
}
509507
return retVal;
510508
}
511509

510+
void GPURecoWorkflowSpec::cleanOldCalibsTPCPtrs(calibObjectStruct& oldCalibObjects)
511+
{
512+
if (mOldCalibObjects.size() > 0) {
513+
mOldCalibObjects.pop();
514+
}
515+
mOldCalibObjects.emplace(std::move(oldCalibObjects));
516+
}
517+
512518
void GPURecoWorkflowSpec::run(ProcessingContext& pc)
513519
{
514520
constexpr static size_t NSectors = o2::tpc::Sector::MAXSECTOR;
@@ -746,7 +752,8 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
746752

747753
const auto& holdData = o2::tpc::TPCTrackingDigitsPreCheck::runPrecheck(&ptrs, mConfig.get());
748754

749-
doCalibUpdates(pc);
755+
calibObjectStruct oldCalibObjects;
756+
doCalibUpdates(pc, oldCalibObjects);
750757

751758
lockDecodeInput.reset();
752759

@@ -784,6 +791,7 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
784791
if (retVal != 0) {
785792
debugTFDump = true;
786793
}
794+
cleanOldCalibsTPCPtrs(oldCalibObjects);
787795

788796
o2::utils::DebugStreamer::instance()->flush(); // flushing debug output to file
789797

@@ -959,7 +967,7 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
959967
LOG(info) << "GPU Reoncstruction time for this TF " << mTimer->CpuTime() - cput << " s (cpu), " << mTimer->RealTime() - realt << " s (wall)";
960968
}
961969

962-
void GPURecoWorkflowSpec::doCalibUpdates(o2::framework::ProcessingContext& pc)
970+
void GPURecoWorkflowSpec::doCalibUpdates(o2::framework::ProcessingContext& pc, calibObjectStruct& oldCalibObjects)
963971
{
964972
GPUCalibObjectsConst newCalibObjects;
965973
GPUNewCalibValues newCalibValues;
@@ -1011,7 +1019,7 @@ void GPURecoWorkflowSpec::doCalibUpdates(o2::framework::ProcessingContext& pc)
10111019
mTRDGeometryCreated = true;
10121020
}
10131021
}
1014-
needCalibUpdate = fetchCalibsCCDBTPC(pc, newCalibObjects) || needCalibUpdate;
1022+
needCalibUpdate = fetchCalibsCCDBTPC(pc, newCalibObjects, oldCalibObjects) || needCalibUpdate;
10151023
if (mSpecConfig.runITSTracking) {
10161024
needCalibUpdate = fetchCalibsCCDBITS(pc) || needCalibUpdate;
10171025
}
@@ -1069,7 +1077,7 @@ Inputs GPURecoWorkflowSpec::inputs()
10691077
inputs.emplace_back("tpcthreshold", gDataOriginTPC, "PADTHRESHOLD", 0, Lifetime::Condition, ccdbParamSpec("TPC/Config/FEEPad"));
10701078
o2::tpc::VDriftHelper::requestCCDBInputs(inputs);
10711079
Options optsDummy;
1072-
mFastTransformHelper->requestCCDBInputs(inputs, optsDummy, mSpecConfig.requireCTPLumi, mSpecConfig.lumiScaleMode); // option filled here is lost
1080+
mCalibObjects.mFastTransformHelper->requestCCDBInputs(inputs, optsDummy, mSpecConfig.requireCTPLumi, mSpecConfig.lumiScaleMode); // option filled here is lost
10731081
}
10741082
if (mSpecConfig.decompressTPC) {
10751083
inputs.emplace_back(InputSpec{"input", ConcreteDataTypeMatcher{gDataOriginTPC, mSpecConfig.decompressTPCFromROOT ? o2::header::DataDescription("COMPCLUSTERS") : o2::header::DataDescription("COMPCLUSTERSFLAT")}, Lifetime::Timeframe});

0 commit comments

Comments
 (0)