Skip to content

Commit bb12ce2

Browse files
committed
GPU: Improve configuration dump
1 parent 29217ed commit bb12ce2

File tree

13 files changed

+158
-52
lines changed

13 files changed

+158
-52
lines changed

GPU/GPUTracking/Base/GPUReconstruction.cxx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include "GPUReconstruction.h"
4141
#include "GPUReconstructionIncludes.h"
4242
#include "GPUROOTDumpCore.h"
43+
#include "GPUConfigDump.h"
44+
#include "GPUChainTracking.h"
4345

4446
#include "GPUMemoryResource.h"
4547
#include "GPUChain.h"
@@ -212,18 +214,30 @@ int GPUReconstruction::Init()
212214

213215
int GPUReconstruction::InitPhaseBeforeDevice()
214216
{
217+
if (mProcessingSettings.printSettings) {
218+
if (mSlaves.size() || mMaster) {
219+
printf("\nConfig Dump %s\n", mMaster ? "Slave" : "Master");
220+
}
221+
const GPUChainTracking* chTrk;
222+
for (unsigned int i = 0; i < mChains.size(); i++) {
223+
if ((chTrk = dynamic_cast<GPUChainTracking*>(mChains[i].get()))) {
224+
break;
225+
}
226+
}
227+
GPUConfigDump::dumpConfig(&param().rec, &mProcessingSettings, chTrk ? chTrk->GetQAConfig() : nullptr, chTrk ? chTrk->GetEventDisplayConfig() : nullptr, &mDeviceBackendSettings, &mRecoSteps);
228+
}
215229
#ifndef GPUCA_HAVE_O2HEADERS
216-
mRecoSteps.setBits(RecoStep::ITSTracking, false);
217-
mRecoSteps.setBits(RecoStep::TRDTracking, false);
218-
mRecoSteps.setBits(RecoStep::TPCConversion, false);
219-
mRecoSteps.setBits(RecoStep::TPCCompression, false);
220-
mRecoSteps.setBits(RecoStep::TPCdEdx, false);
230+
mRecoSteps.steps.setBits(RecoStep::ITSTracking, false);
231+
mRecoSteps.steps.setBits(RecoStep::TRDTracking, false);
232+
mRecoSteps.steps.setBits(RecoStep::TPCConversion, false);
233+
mRecoSteps.steps.setBits(RecoStep::TPCCompression, false);
234+
mRecoSteps.steps.setBits(RecoStep::TPCdEdx, false);
221235
mProcessingSettings.createO2Output = false;
222236
#endif
223-
mRecoStepsGPU &= mRecoSteps;
224-
mRecoStepsGPU &= AvailableRecoSteps();
237+
mRecoSteps.stepsGPUMask &= mRecoSteps.steps;
238+
mRecoSteps.stepsGPUMask &= AvailableGPURecoSteps();
225239
if (!IsGPU()) {
226-
mRecoStepsGPU.set((unsigned char)0);
240+
mRecoSteps.stepsGPUMask.set((unsigned char)0);
227241
}
228242

229243
if (mProcessingSettings.forceMemoryPoolSize >= 1024 || mProcessingSettings.forceHostMemoryPoolSize >= 1024) {
@@ -286,7 +300,7 @@ int GPUReconstruction::InitPhaseBeforeDevice()
286300
if (!mProcessingSettings.createO2Output || !IsGPU()) {
287301
mProcessingSettings.clearO2OutputFromGPU = false;
288302
}
289-
if (!(mRecoStepsGPU & GPUDataTypes::RecoStep::TPCMerging)) {
303+
if (!(mRecoSteps.stepsGPUMask & GPUDataTypes::RecoStep::TPCMerging)) {
290304
mProcessingSettings.mergerSortTracks = false;
291305
}
292306
if (!IsGPU()) {
@@ -296,7 +310,7 @@ int GPUReconstruction::InitPhaseBeforeDevice()
296310
if (param().rec.nonConsecutiveIDs) {
297311
param().rec.tpc.disableRefitAttachment = 0xFF;
298312
}
299-
if (!(mRecoStepsGPU & RecoStep::TPCMerging) || !param().rec.tpc.mergerReadFromTrackerDirectly) {
313+
if (!(mRecoSteps.stepsGPUMask & RecoStep::TPCMerging) || !param().rec.tpc.mergerReadFromTrackerDirectly) {
300314
mProcessingSettings.fullMergerOnGPU = false;
301315
}
302316
if (mProcessingSettings.debugLevel > 3 || !mProcessingSettings.fullMergerOnGPU || mProcessingSettings.deterministicGPUReconstruction) {
@@ -1113,7 +1127,7 @@ void GPUReconstruction::UpdateSettings(const GPUSettingsGRP* g, const GPUSetting
11131127
mProcessingSettings.debugLevel = p->debugLevel;
11141128
mProcessingSettings.resetTimers = p->resetTimers;
11151129
}
1116-
GPURecoStepConfiguration w = {mRecoSteps, mRecoStepsGPU, mRecoStepsInputs, mRecoStepsOutputs};
1130+
GPURecoStepConfiguration w = mRecoSteps;
11171131
param().UpdateSettings(g, p, &w);
11181132
if (mInitialized) {
11191133
WriteConstantParams();
@@ -1161,10 +1175,10 @@ void GPUReconstruction::SetSettings(const GPUSettingsGRP* grp, const GPUSettings
11611175
mProcessingSettings = *proc;
11621176
}
11631177
if (workflow) {
1164-
mRecoSteps = workflow->steps;
1165-
mRecoStepsGPU &= workflow->stepsGPUMask;
1166-
mRecoStepsInputs = workflow->inputs;
1167-
mRecoStepsOutputs = workflow->outputs;
1178+
mRecoSteps.steps = workflow->steps;
1179+
mRecoSteps.stepsGPUMask &= workflow->stepsGPUMask;
1180+
mRecoSteps.inputs = workflow->inputs;
1181+
mRecoSteps.outputs = workflow->outputs;
11681182
}
11691183
param().SetDefaults(&mGRPSettings, rec, proc, workflow);
11701184
}

GPU/GPUTracking/Base/GPUReconstruction.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ class GPUReconstruction
210210
int NStreams() const { return mNStreams; }
211211
const void* DeviceMemoryBase() const { return mDeviceMemoryBase; }
212212

213-
RecoStepField GetRecoSteps() const { return mRecoSteps; }
214-
RecoStepField GetRecoStepsGPU() const { return mRecoStepsGPU; }
215-
InOutTypeField GetRecoStepsInputs() const { return mRecoStepsInputs; }
216-
InOutTypeField GetRecoStepsOutputs() const { return mRecoStepsOutputs; }
213+
RecoStepField GetRecoSteps() const { return mRecoSteps.steps; }
214+
RecoStepField GetRecoStepsGPU() const { return mRecoSteps.stepsGPUMask; }
215+
InOutTypeField GetRecoStepsInputs() const { return mRecoSteps.inputs; }
216+
InOutTypeField GetRecoStepsOutputs() const { return mRecoSteps.outputs; }
217217
int getRecoStepNum(RecoStep step, bool validCheck = true);
218218
int getGeneralStepNum(GeneralStep step, bool validCheck = true);
219219

@@ -286,7 +286,7 @@ class GPUReconstruction
286286
int ReadStructFromFile(const char* file, T* obj);
287287

288288
// Others
289-
virtual RecoStepField AvailableRecoSteps() { return RecoStep::AllRecoSteps; }
289+
virtual RecoStepField AvailableGPURecoSteps() { return RecoStep::AllRecoSteps; }
290290
virtual bool CanQueryMaxMemory() { return false; }
291291

292292
// Pointers to tracker classes
@@ -304,10 +304,7 @@ class GPUReconstruction
304304
GPUOutputControl mInputControl; // Prefefined input memory location for reading standalone dumps
305305
std::unique_ptr<GPUMemorySizeScalers> mMemoryScalers; // Scalers how much memory will be needed
306306

307-
RecoStepField mRecoSteps = RecoStep::AllRecoSteps;
308-
RecoStepField mRecoStepsGPU = RecoStep::AllRecoSteps;
309-
InOutTypeField mRecoStepsInputs = 0;
310-
InOutTypeField mRecoStepsOutputs = 0;
307+
GPURecoStepConfiguration mRecoSteps;
311308

312309
std::string mDeviceName = "CPU";
313310

GPU/GPUTracking/Base/GPUReconstructionCPU.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ inline int GPUReconstructionCPU::runKernel(krnlSetup&& setup, Args&&... args)
198198
if (myStep == GPUCA_RECO_STEP::NoRecoStep) {
199199
throw std::runtime_error("Failure running general kernel without defining RecoStep");
200200
}
201-
int cpuFallback = IsGPU() ? (setup.x.device == krnlDeviceType::CPU ? 2 : (mRecoStepsGPU & myStep) != myStep) : 0;
201+
int cpuFallback = IsGPU() ? (setup.x.device == krnlDeviceType::CPU ? 2 : (mRecoSteps.stepsGPUMask & myStep) != myStep) : 0;
202202
unsigned int& nThreads = setup.x.nThreads;
203203
unsigned int& nBlocks = setup.x.nBlocks;
204204
const unsigned int stream = setup.x.stream;

GPU/GPUTracking/Base/opencl/GPUReconstructionOCL1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class GPUReconstructionOCL1Backend : public GPUReconstructionOCL
4040
template <class S, class T, int I, bool MULTI>
4141
S& getKernelObject();
4242

43-
RecoStepField AvailableRecoSteps() override { return (RecoStep::TPCSliceTracking); }
43+
RecoStepField AvailableGPURecoSteps() override { return (RecoStep::TPCSliceTracking); }
4444
bool ContextForAllPlatforms() override { return true; }
4545
bool CheckPlatform(unsigned int i) override;
4646
int GetOCLPrograms() override;

GPU/GPUTracking/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ set(SRCS
6868
TRDTracking/GPUTRDTrackerKernels.cxx
6969
Base/GPUParam.cxx)
7070

71-
set(SRCS_DATATYPES DataTypes/GPUDataTypes.cxx)
71+
set(SRCS_DATATYPES DataTypes/GPUDataTypes.cxx DataTypes/GPUConfigDump.cxx)
7272
set(SRCS_DATATYPE_HEADERS DataTypes/GPUTPCGMPolynomialField.cxx)
7373

7474
set(HDRS_CINT_O2 Merger/GPUTPCGMMergedTrack.h Merger/GPUTPCGMSliceTrack.h Merger/GPUTPCGMBorderTrack.h)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
12+
/// \file GPUConfigDump.cxx
13+
/// \author David Rohr
14+
15+
#include "GPUConfigDump.h"
16+
#include "GPUDataTypes.h"
17+
#include "GPUSettings.h"
18+
19+
#include <functional>
20+
#include <iostream>
21+
#include <cstdio>
22+
23+
#include "utils/qconfig_helpers.h"
24+
25+
using namespace GPUCA_NAMESPACE::gpu;
26+
27+
namespace
28+
{
29+
GPUSettingsStandalone configStandalone;
30+
std::vector<std::function<void()>> qprint_global;
31+
#define QCONFIG_PRINT
32+
#include "utils/qconfig.h"
33+
#undef QCONFIG_PRINT
34+
} // namespace
35+
36+
void GPUConfigDump::dumpConfig(const GPUSettingsRec* rec, const GPUSettingsProcessing* proc, const GPUSettingsQA* qa, const GPUSettingsDisplay* display, const GPUSettingsDeviceBackend* device, const GPURecoStepConfiguration* workflow)
37+
{
38+
if (rec) {
39+
qConfigPrint(*rec, "rec.");
40+
}
41+
if (proc) {
42+
qConfigPrint(*proc, "proc.");
43+
}
44+
if (qa) {
45+
qConfigPrint(*qa, "QA.");
46+
}
47+
if (display) {
48+
qConfigPrint(*display, "display.");
49+
}
50+
if (device) {
51+
std::cout << "\n\tGPUSettingsDeviceBackend:\n"
52+
<< "\tdeviceType = " << (int)device->deviceType << "\n"
53+
<< "\tforceDeviceType = " << (device->forceDeviceType ? "true" : "false") << "\n"
54+
<< "\tslave = " << (device->master ? "true" : "false") << "\n";
55+
}
56+
if (workflow) {
57+
printf("\n\tReconstruction steps / inputs / outputs:\n\tReco Steps = 0x%08x\n\tReco Steps GPU = 0x%08x\n\tInputs = 0x%08x\n\tOutputs = 0x%08x\n", (unsigned int)workflow->steps, (unsigned int)workflow->stepsGPUMask, (unsigned int)workflow->inputs, (unsigned int)workflow->outputs);
58+
}
59+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
12+
/// \file GPUConfigDump.h
13+
/// \author David Rohr
14+
15+
#ifndef GPUCONFIGDUMP_H
16+
#define GPUCONFIGDUMP_H
17+
18+
#include "GPUCommonDef.h"
19+
20+
namespace GPUCA_NAMESPACE::gpu
21+
{
22+
struct GPUSettingsRec;
23+
struct GPUSettingsProcessing;
24+
struct GPUSettingsQA;
25+
struct GPUSettingsDisplay;
26+
struct GPUSettingsDeviceBackend;
27+
struct GPURecoStepConfiguration;
28+
29+
class GPUConfigDump
30+
{
31+
public:
32+
static void dumpConfig(const GPUSettingsRec* rec, const GPUSettingsProcessing* proc, const GPUSettingsQA* qa, const GPUSettingsDisplay* display, const GPUSettingsDeviceBackend* device, const GPURecoStepConfiguration* workflow);
33+
};
34+
35+
} // namespace GPUCA_NAMESPACE::gpu
36+
37+
#endif

GPU/GPUTracking/DataTypes/GPUDataTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "GPUCommonDef.h"
1919

20-
// These are basic and non-comprex data types, which will also be visible on the GPU.
20+
// These are basic and non-complex data types, which will also be visible on the GPU.
2121
// Please add complex data types required on the host but not GPU to GPUHostDataTypes.h and forward-declare!
2222
#ifndef GPUCA_GPUCODE_DEVICE
2323
#include <cstddef>

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ AddOption(tpcDownscaledEdx, unsigned char, 0, "", 0, "If != 0, downscale dEdx pr
282282
AddOption(tpcMaxAttachedClustersPerSectorRow, unsigned int, 51000, "", 0, "Maximum number of TPC attached clusters which can be decoded per SectorRow")
283283
AddOption(tpcUseOldCPUDecoding, bool, false, "", 0, "Enable old CPU-based TPC decoding")
284284
AddOption(RTCcacheFolder, std::string, "./rtccache/", "", 0, "Folder in which the cache file is stored")
285+
AddOption(printSettings, bool, false, "", 0, "Print all settings when initializing")
285286
AddVariable(eventDisplay, GPUCA_NAMESPACE::gpu::GPUDisplayFrontendInterface*, nullptr)
286287
AddSubConfig(GPUSettingsProcessingRTC, rtc)
287288
AddSubConfig(GPUSettingsProcessingParam, param)
@@ -503,9 +504,9 @@ AddHelp("help", 'h')
503504
AddHelpAll("helpall", 'H')
504505
AddSubConfig(GPUSettingsRec, rec)
505506
AddSubConfig(GPUSettingsProcessing, proc)
506-
AddSubConfig(GPUSettingsTFSim, TF)
507507
AddSubConfig(GPUSettingsQA, QA)
508508
AddSubConfig(GPUSettingsDisplay, display)
509+
AddSubConfig(GPUSettingsTFSim, TF)
509510
AddSubConfig(GPUSettingsEG, EG)
510511
EndConfig()
511512
#endif // BeginConfig

GPU/GPUTracking/Global/GPUChainTracking.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ class GPUChainTracking : public GPUChain, GPUReconstructionHelpers::helperDelega
159159
GPUQA* GetQA() { return mQAFromForeignChain ? mQAFromForeignChain->mQA.get() : mQA.get(); }
160160
int ForceInitQA();
161161
void SetQAFromForeignChain(GPUChainTracking* chain) { mQAFromForeignChain = chain; }
162+
const GPUSettingsDisplay* GetEventDisplayConfig() const { return mConfigDisplay; }
163+
const GPUSettingsQA* GetQAConfig() const { return mConfigQA; }
162164

163165
// Processing functions
164166
int RunTPCClusterizer(bool synchronizeOutput = true);

0 commit comments

Comments
 (0)