Skip to content

Commit

Permalink
GPU QA: Use single GPU QA instance for double-pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrohr committed Sep 25, 2023
1 parent 9c112f8 commit 86a6bab
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
3 changes: 3 additions & 0 deletions GPU/GPUTracking/Benchmark/standalone.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ int ReadEvent(int n)
if ((configStandalone.proc.runQA || configStandalone.eventDisplay) && !configStandalone.QA.noMC) {
chainTracking->ForceInitQA();
snprintf(filename, 256, "events/%s/mc.%d.dump", configStandalone.eventsDir, n);
chainTracking->GetQA()->UpdateChain(chainTracking);
if (chainTracking->GetQA()->ReadO2MCData(filename)) {
snprintf(filename, 256, "events/%s/mc.%d.dump", configStandalone.eventsDir, 0);
if (chainTracking->GetQA()->ReadO2MCData(filename) && configStandalone.proc.runQA) {
Expand Down Expand Up @@ -734,12 +735,14 @@ int main(int argc, char** argv)
recAsync->SetDebugLevelTmp(configStandalone.proc.debugLevel);
}
chainTrackingAsync = recAsync->AddChain<GPUChainTracking>();
chainTrackingAsync->SetQAFromForeignChain(chainTracking);
}
if (configStandalone.proc.doublePipeline) {
if (configStandalone.proc.debugLevel >= 3) {
recPipeline->SetDebugLevelTmp(configStandalone.proc.debugLevel);
}
chainTrackingPipeline = recPipeline->AddChain<GPUChainTracking>();
chainTrackingPipeline->SetQAFromForeignChain(chainTracking);
}
#ifdef GPUCA_HAVE_O2HEADERS
if (!configStandalone.proc.doublePipeline) {
Expand Down
28 changes: 17 additions & 11 deletions GPU/GPUTracking/Global/GPUChainTracking.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,14 @@ int GPUChainTracking::Init()
}

if (GPUQA::QAAvailable() && (GetProcessingSettings().runQA || GetProcessingSettings().eventDisplay)) {
mQA.reset(new GPUQA(this));
auto& qa = mQAFromForeignChain ? mQAFromForeignChain->mQA : mQA;
if (!qa) {
qa.reset(new GPUQA(this));
}
}
if (GetProcessingSettings().eventDisplay) {
#ifndef GPUCA_ALIROOT_LIB
mEventDisplay.reset(GPUDisplayInterface::getDisplay(GetProcessingSettings().eventDisplay, this, mQA.get()));
mEventDisplay.reset(GPUDisplayInterface::getDisplay(GetProcessingSettings().eventDisplay, this, GetQA()));
#endif
if (mEventDisplay == nullptr) {
throw std::runtime_error("Error loading event display");
Expand Down Expand Up @@ -479,19 +482,21 @@ int GPUChainTracking::PrepareEvent()

int GPUChainTracking::ForceInitQA()
{
if (!mQA) {
mQA.reset(new GPUQA(this));
auto& qa = mQAFromForeignChain ? mQAFromForeignChain->mQA : mQA;
if (!qa) {
qa.reset(new GPUQA(this));
}
if (!mQA->IsInitialized()) {
return mQA->InitQA();
if (!GetQA()->IsInitialized()) {
return GetQA()->InitQA();
}
return 0;
}

int GPUChainTracking::Finalize()
{
if (GetProcessingSettings().runQA && mQA->IsInitialized() && !(mConfigQA && mConfigQA->shipToQC)) {
mQA->DrawQAHistograms();
if (GetProcessingSettings().runQA && GetQA()->IsInitialized() && !(mConfigQA && mConfigQA->shipToQC) && !mQAFromForeignChain) {
GetQA()->UpdateChain(this);
GetQA()->DrawQAHistograms();
}
if (GetProcessingSettings().debugLevel >= 6) {
mDebugFile->close();
Expand Down Expand Up @@ -670,8 +675,8 @@ int GPUChainTracking::RunChain()
mCompressionStatistics.reset(new GPUTPCClusterStatistics);
}
const bool needQA = GPUQA::QAAvailable() && (GetProcessingSettings().runQA || (GetProcessingSettings().eventDisplay && (mIOPtrs.nMCInfosTPC || GetProcessingSettings().runMC)));
if (needQA && mQA->IsInitialized() == false) {
if (mQA->InitQA(GetProcessingSettings().runQA ? -GetProcessingSettings().runQA : -1)) {
if (needQA && GetQA()->IsInitialized() == false) {
if (GetQA()->InitQA(GetProcessingSettings().runQA ? -GetProcessingSettings().runQA : -1)) {
return 1;
}
}
Expand Down Expand Up @@ -796,7 +801,8 @@ int GPUChainTracking::RunChainFinalize()
const bool needQA = GPUQA::QAAvailable() && (GetProcessingSettings().runQA || (GetProcessingSettings().eventDisplay && mIOPtrs.nMCInfosTPC));
if (needQA && mFractionalQAEnabled) {
mRec->getGeneralStepTimer(GeneralStep::QA).Start();
mQA->RunQA(!GetProcessingSettings().runQA);
GetQA()->UpdateChain(this);
GetQA()->RunQA(!GetProcessingSettings().runQA);
mRec->getGeneralStepTimer(GeneralStep::QA).Stop();
if (GetProcessingSettings().debugLevel == 0) {
GPUInfo("Total QA runtime: %d us", (int)(mRec->getGeneralStepTimer(GeneralStep::QA).GetElapsedTime() * 1000000));
Expand Down
6 changes: 4 additions & 2 deletions GPU/GPUTracking/Global/GPUChainTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ class GPUChainTracking : public GPUChain, GPUReconstructionHelpers::helperDelega
const GPUTPCGMMerger& GetTPCMerger() const { return processors()->tpcMerger; }
GPUTPCGMMerger& GetTPCMerger() { return processors()->tpcMerger; }
GPUDisplayInterface* GetEventDisplay() { return mEventDisplay.get(); }
const GPUQA* GetQA() const { return mQA.get(); }
GPUQA* GetQA() { return mQA.get(); }
const GPUQA* GetQA() const { return mQAFromForeignChain ? mQAFromForeignChain->mQA.get() : mQA.get(); }
GPUQA* GetQA() { return mQAFromForeignChain ? mQAFromForeignChain->mQA.get() : mQA.get(); }
int ForceInitQA();
void SetQAFromForeignChain(GPUChainTracking* chain) { mQAFromForeignChain = chain; }

// Processing functions
int RunTPCClusterizer(bool synchronizeOutput = true);
Expand Down Expand Up @@ -254,6 +255,7 @@ class GPUChainTracking : public GPUChain, GPUReconstructionHelpers::helperDelega
// Display / QA
bool mDisplayRunning = false;
std::unique_ptr<GPUDisplayInterface> mEventDisplay;
GPUChainTracking* mQAFromForeignChain = nullptr;
std::unique_ptr<GPUQA> mQA;
std::unique_ptr<GPUTPCClusterStatistics> mCompressionStatistics;

Expand Down
4 changes: 4 additions & 0 deletions GPU/GPUTracking/Interface/GPUO2Interface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ int GPUO2Interface::Initialize(const GPUO2InterfaceConfiguration& config)
}
for (unsigned int i = 0; i < mNContexts; i++) {
mCtx[i].mChain = mCtx[i].mRec->AddChain<GPUChainTracking>(mConfig->configInterface.maxTPCHits, mConfig->configInterface.maxTRDTracklets);
if (i) {
mCtx[i].mChain->SetQAFromForeignChain(mCtx[0].mChain);
}
mCtx[i].mChain->mConfigDisplay = &mConfig->configDisplay;
mCtx[i].mChain->mConfigQA = &mConfig->configQA;
mCtx[i].mRec->SetSettings(&mConfig->configGRP, &mConfig->configReconstruction, &mConfig->configProcessing, &mConfig->configWorkflow);
Expand Down Expand Up @@ -145,6 +148,7 @@ void GPUO2Interface::DumpEvent(int nEvent, GPUTrackingInOutPointers* data)
if (mConfig->configProcessing.runMC) {
mCtx[0].mChain->ForceInitQA();
snprintf(fname, 1024, "mc.%d.dump", nEvent);
mCtx[0].mChain->GetQA()->UpdateChain(mCtx[0].mChain);
mCtx[0].mChain->GetQA()->DumpO2MCData(fname);
}
#endif
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUTracking/qa/GPUQA.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class GPUQA
int ReadO2MCData(const char* filename);
static bool QAAvailable() { return true; }
bool IsInitialized() { return mQAInitialized; }
void UpdateChain(GPUChainTracking* chain) { mTracking = chain; }

const std::vector<TH1F>& getHistograms1D() const { return *mHist1D; }
const std::vector<TH2F>& getHistograms2D() const { return *mHist2D; }
Expand Down

0 comments on commit 86a6bab

Please sign in to comment.