63GPUChainTracking::GPUChainTracking(
GPUReconstruction*
rec, uint32_t maxTPCHits, uint32_t maxTRDTracklets) :
GPUChain(
rec), mIOPtrs(processors()->ioPtrs), mInputsHost(new
GPUTrackingInputProvider), mInputsShadow(new
GPUTrackingInputProvider), mClusterNativeAccess(new
ClusterNativeAccess), mTriggerBuffer(new
GPUTriggerOutputs), mMaxTPCHits(maxTPCHits), mMaxTRDTracklets(maxTRDTracklets), mDebugFile(new
std::ofstream)
112#ifdef GPUCA_KERNEL_DEBUGGER_OUTPUT
157#ifdef GPUCA_KERNEL_DEBUGGER_OUTPUT
171 GPUError(
"Invalid Reconstruction Step Setting: dEdx requires TPC Merger to be active");
175 GPUError(
"Invalid GPU Reconstruction Step Setting: dEdx requires TPC Merger to be active");
178 if (!
param().par.earlyTpcTransform) {
179 if (((
GetRecoSteps() & GPUDataTypes::RecoStep::TPCSectorTracking) || (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCMerging)) && !(
GetRecoSteps() & GPUDataTypes::RecoStep::TPCConversion)) {
180 GPUError(
"Invalid Reconstruction Step Setting: Tracking without early transform requires TPC Conversion to be active");
185 GPUError(
"Invalid input, TPC Clusterizer needs TPC raw input");
189 GPUError(
"Invalid input / output / step, merger cannot read/store sectors tracks and needs TPC conversion");
192 bool tpcClustersAvail = (
GetRecoStepsInputs() & GPUDataTypes::InOutType::TPCClusters) || (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCClusterFinding) || (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCDecompression);
193 if ((
GetRecoSteps() & GPUDataTypes::RecoStep::TPCMerging) && !tpcClustersAvail) {
194 GPUError(
"Invalid Inputs for track merging, TPC Clusters required");
197#ifndef GPUCA_TPC_GEOMETRY_O2
198 if (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCClusterFinding) {
199 GPUError(
"Can not run TPC GPU Cluster Finding with Run 2 Data");
203 if (((
GetRecoSteps() & GPUDataTypes::RecoStep::TPCConversion) || (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCSectorTracking) || (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCCompression) || (
GetRecoSteps() & GPUDataTypes::RecoStep::TPCdEdx)) && !tpcClustersAvail) {
204 GPUError(
"Missing input for TPC Cluster conversion / sector tracking / compression / dEdx: TPC Clusters required");
208 GPUError(
"Input for TPC merger missing");
212 GPUError(
"Input for TPC compressor missing");
216 GPUError(
"Input for TRD Tracker missing");
220 GPUError(
"TPC Raw / TPC Clusters / TRD Tracklets cannot be output");
224 GPUError(
"No TPC Sector Tracker Output available");
228 GPUError(
"No TPC Merged Track Output available");
232 GPUError(
"No TPC Compression Output available");
236 GPUError(
"No TRD Tracker Output available");
239 if ((
GetRecoSteps() & GPUDataTypes::RecoStep::TPCdEdx) && (
processors()->calibObjects.dEdxCalibContainer ==
nullptr)) {
240 GPUError(
"Cannot run dE/dx without dE/dx calibration container object");
243 if ((
GetRecoSteps() & GPUDataTypes::RecoStep::TPCClusterFinding) &&
processors()->calibObjects.tpcPadGain ==
nullptr) {
244 GPUError(
"Cannot run gain calibration without calibration object");
248 GPUError(
"Cannot run TPC ZS Decoder without mapping object. (tpczslinkmapping.dump missing?)");
256 if ((
param().
rec.tpc.nWays & 1) == 0) {
257 GPUError(
"nWay setting musst be odd number!");
260 if (
param().
rec.tpc.mergerInterpolateErrors &&
param().
rec.tpc.nWays == 1) {
261 GPUError(
"Cannot do error interpolation with NWays = 1!");
265 GPUError(
"configured max time bin exceeds 256 orbits");
273 GPUError(
"noGPUMemoryRegistration only possible with gather mode 3");
277 if (!
GetRecoStepsOutputs().isOnlySet(GPUDataTypes::InOutType::TPCMergedTracks, GPUDataTypes::InOutType::TPCCompressedClusters, GPUDataTypes::InOutType::TPCClusters)) {
278 GPUError(
"Invalid outputs for double pipeline mode 0x%x", (uint32_t)
GetRecoStepsOutputs());
285 GPUError(
"Must use external output for double pipeline mode");
289 GPUError(
"Double pipeline incompatible to compression mode 1");
293 GPUError(
"Invalid reconstruction settings for double pipeline: Needs compression and cluster finding");
298 GPUError(
"tpcApplyCFCutsAtDecoding currently requires tpcUseOldCPUDecoding");
302 GPUError(
"Invalid tpcCompressionGatherMode for compression on CPU");
306 GPUError(
"tpcApplyDebugClusterFilter cannot be used with GPU clusterization or with delayedOutput for GPU or with MC labels");
311 GPUError(
"TRD tracking can only run on O2 TPC tracks if createO2Output is enabled (%d), nWaysOuter is set (%d), and matBudLUT is available (0x%p)", (int32_t)
GetProcessingSettings().createO2Output, (int32_t)
param().
rec.tpc.nWaysOuter, (
void*)
GetMatLUT());
315 GPUError(
"TRD tracking can only run on GPU TPC tracks if the createO2Output setting does not suppress them");
319 GPUError(
"Cannot use TRD tracking or Refit on GPU without GPU polynomial field map (%d) or matlut table (%p)", (int32_t)
GetProcessingSettings().o2PropagatorUseGPUField, (
void*)
GetMatLUT());
358 qa.reset(
new GPUQA(
this));
364 throw std::runtime_error(
"Error loading event display");
422 if (
processors()->calibObjects.matLUT && (ptrMask ==
nullptr || ptrMask->
matLUT)) {
460 throw std::runtime_error(
"Forwading zero-suppressed hits not supported");
470 qa.reset(
new GPUQA(
this));
472 if (!
GetQA()->IsInitialized()) {
495 char* fastTransformBase = (
char*)mem;
511 if ((
char*)mem - fastTransformBase < mChainTracking->
GetProcessingSettings().fastTransformObjectsMinMemorySize) {
600 std::unique_ptr<GPUSettingsGRP> grp;
601 const GPUSettingsProcessing* p =
nullptr;
602 std::lock_guard lk(mMutexUpdateCalib);
626 GPUFatal(
"GPU magnetic field for propagator requested, but received an O2 propagator without GPU field");
651 memcpy(oldFlatPtrsDevice.data(), (
void*)&
mFlatObjectsDevice, oldFlatPtrsDevice.size());
653 bool ptrsChanged = memcmp(oldFlatPtrs.data(), (
void*)&
mFlatObjectsShadow, oldFlatPtrs.size()) || memcmp(oldFlatPtrsDevice.data(), (
void*)&
mFlatObjectsDevice, oldFlatPtrsDevice.size());
655 GPUInfo(
"Updating all calib objects since pointers changed");
674 GPUFatal(
"Cannot run TRD tracking or refit with o2 track model without o2 propagator");
700 }
catch (
const std::bad_alloc& e) {
701 GPUError(
"Memory Allocation Error");
747 GPUInfo(
"Preempting tpcZS input of foreign chain");
750 mPipelineFinalizationCtx->rec = this->
mRec;
751 foreignChain->mPipelineNotifyCtx = mPipelineFinalizationCtx.get();
759 if (
GetProcessingSettings().trdTrackModelO2 ?
runRecoStep(RecoStep::TRDTracking, &GPUChainTracking::RunTRDTracking<GPUTRDTrackerKernels::o2Version>) :
runRecoStep(RecoStep::TRDTracking, &GPUChainTracking::RunTRDTracking<GPUTRDTrackerKernels::gpuVersion>)) {
786 int32_t retVal2 = RunChainFinalize();
787 return retVal2 ? retVal2 :
retVal;
790int32_t GPUChainTracking::RunChainFinalize()
834 GPUInfo(
"Press key for next event!");
841 iKey = kbhit() ? getch() : 0;
844 }
else if (iKey ==
'n') {
861 GPUInfo(
"Loading next event");
871 if (mPipelineFinalizationCtx) {
873 std::unique_lock<std::mutex> lock(mPipelineFinalizationCtx->mutex);
874 auto* ctx = mPipelineFinalizationCtx.get();
875 mPipelineFinalizationCtx->cond.wait(lock, [ctx]() {
return ctx->ready; });
877 mPipelineFinalizationCtx.reset();
879 return RunChainFinalize();
885 for (int32_t
i = 0;
i < 1 + (!cpuOnly &&
mRec->
IsGPU());
i++) {
896 static int32_t errorsShown = 0;
897 static bool quiet =
false;
898 static std::chrono::time_point<std::chrono::steady_clock> silenceFrom;
900 silenceFrom = std::chrono::steady_clock::now();
903 auto currentTime = std::chrono::steady_clock::now();
904 std::chrono::duration<double> elapsed_seconds = currentTime - silenceFrom;
905 if (elapsed_seconds.count() > 60 * 10) {
912 GPUWarning(
"GPUReconstruction suffered from an error in the %s part",
i ?
"GPU" :
"CPU");
914 GPUError(
"GPUReconstruction suffered from an error in the %s part",
i ?
"GPU" :
"CPU");
922 for (uint32_t
j = 0;
j < nErrors;
j++) {
923 fillErrors->emplace_back(std::array<uint32_t, 4>{pErrors[4 *
j], pErrors[4 *
j + 1], pErrors[4 *
j + 2], pErrors[4 *
j + 3]});
944 std::lock_guard lk(mMutexUpdateCalib);
946 void*
const* pSrc = (
void*
const*)&obj;
948 for (uint32_t
i = 0;
i <
sizeof(*mNewCalibObjects) /
sizeof(
void*);
i++) {
973 GPUFatal(
"GPU magnetic field for propagator requested, but received an O2 propagator without GPU field");
Definition of container class for dE/dx corrections.
Helper class to access correction maps.
#define GPUCA_MEMORY_SIZE
#define GPUCA_HOST_MEMORY_SIZE
Online TRD tracker based on extrapolated TPC tracks.
Used for storing the MC labels for the TRD tracklets.
TRD Tracklet word for GPU tracker - 32bit tracklet info + half chamber ID + index.
Definition of a container to keep Monte Carlo truth external to simulation objects.
bool isSet(const bitfield &v) const
size_t getFlatBufferSize() const
Gives size of the flat buffer.
void SetMatLUT(std::unique_ptr< o2::base::MatLayerCylSet > &&lut)
~GPUChainTracking() override
std::unique_ptr< o2::base::MatLayerCylSet > mMatLUTU
int32_t RunTPCCompression()
const o2::base::Propagator * GetDeviceO2Propagator()
void SetTRDGeometry(std::unique_ptr< o2::trd::GeometryFlat > &&geo)
GPUChainTracking * mQAFromForeignChain
void SetO2Propagator(const o2::base::Propagator *prop)
std::unique_ptr< GPUQA > mQA
std::unique_ptr< CorrectionMapsHelper > mTPCFastTransformHelperU
GPUTrackingFlatObjects mFlatObjectsDevice
int32_t RunTPCClusterizer(bool synchronizeOutput=true)
int32_t RunTPCTrackingSectors()
void UpdateGPUCalibObjectsPtrs(int32_t stream)
int32_t RunTPCTrackingMerger(bool synchronizeOutput=true)
std::unique_ptr< GPUTrackingInputProvider > mInputsHost
std::unique_ptr< GPUTPCClusterStatistics > mCompressionStatistics
const o2::base::MatLayerCylSet * GetMatLUT() const
std::array< GPUOutputControl *, GPUTrackingOutputs::count()> mSubOutputControls
std::unique_ptr< std::ofstream > mDebugFile
void SetUpdateCalibObjects(const GPUCalibObjectsConst &obj, const GPUNewCalibValues &vals)
bool mUpdateNewCalibObjects
std::unique_ptr< GPUCalibObjectsConst > mNewCalibObjects
std::unique_ptr< o2::trd::GeometryFlat > mTRDGeometryU
int32_t Finalize() override
GPUTrackingFlatObjects mFlatObjectsShadow
void RegisterPermanentMemoryAndProcessors() override
void RegisterGPUProcessors() override
void ClearErrorCodes(bool cpuOnly=false)
const GPUQA * GetQA() const
void MemorySize(size_t &gpuMem, size_t &pageLockedHostMem) override
void SetTPCFastTransform(std::unique_ptr< TPCFastTransform > &&tpcFastTransform, std::unique_ptr< CorrectionMapsHelper > &&tpcTransformHelper)
int32_t RunTPCDecompression()
int32_t DoQueuedUpdates(int32_t stream, bool updateSlave=true)
std::unique_ptr< GPUNewCalibValues > mNewCalibValues
int32_t CheckErrorCodes(bool cpuOnly=false, bool forceShowErrors=false, std::vector< std::array< uint32_t, 4 > > *fillErrors=nullptr) override
std::unique_ptr< TPCFastTransform > mTPCFastTransformU
bool mFractionalQAEnabled
int32_t PrepareEvent() override
int32_t RunChain() override
GPUChainTracking(GPUReconstruction *rec, uint32_t maxTPCHits=GPUCA_MAX_CLUSTERS, uint32_t maxTRDTracklets=GPUCA_MAX_TRD_TRACKLETS)
void PrepareDebugOutput()
void UpdateGPUCalibObjects(int32_t stream, const GPUCalibObjectsConst *ptrMask=nullptr)
int32_t ConvertNativeToClusterData()
GPUTrackingInOutPointers & mIOPtrs
struct o2::gpu::GPUChainTracking::InOutMemory mIOMem
const o2::tpc::CalibdEdxContainer * GetdEdxCalibContainer() const
std::unique_ptr< GPUTrackingInputProvider > mInputsShadow
const GPUSettingsQA * mConfigQA
int32_t FinalizePipelinedProcessing() override
bool mTPCSectorScratchOnStack
std::unique_ptr< GPUDisplayInterface > mEventDisplay
void TransferMemoryResourceLinkToGPU(RecoStep step, int16_t res, int32_t stream=-1, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
GPUConstantMem * processorsDevice()
GPUReconstruction::RecoStepField GetRecoStepsGPU() const
GPUReconstruction::RecoStepField GetRecoSteps() const
virtual std::unique_ptr< gpu_reconstruction_kernels::threadContext > GetThreadContext()
void WriteToConstantMemory(RecoStep step, size_t offset, const void *src, size_t size, int32_t stream=-1, deviceEvent *ev=nullptr)
GPUChain * GetNextChainInQueue()
GPUReconstruction::InOutTypeField GetRecoStepsOutputs() const
GPUConstantMem * processors()
const GPUSettingsProcessing & GetProcessingSettings() const
void SynchronizeStream(int32_t stream)
GPUReconstructionCPU * mRec
GPUConstantMem * processorsShadow()
GPUReconstruction::InOutTypeField GetRecoStepsInputs() const
static constexpr int32_t NSECTORS
void TransferMemoryResourceLinkToHost(RecoStep step, int16_t res, int32_t stream=-1, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
void AllocateIOMemoryHelper(uint32_t n, const T *&ptr, std::unique_ptr< T[]> &u)
int32_t runRecoStep(RecoStep step, S T::*func, Args... args)
GPUReconstruction * rec()
static constexpr const char *const RECO_STEP_NAMES[]
static GPUDisplayInterface * getDisplay(GPUDisplayFrontendInterface *frontend, GPUChainTracking *chain, GPUQA *qa, const GPUParam *param=nullptr, const GPUCalibObjectsConst *calib=nullptr, const GPUSettingsDisplay *config=nullptr)
const uint32_t * getErrorPtr() const
void setMemory(GPUglobalref() uint32_t *m)
void printErrors(bool silent=false)
uint32_t getNErrors() const
static void computePointerWithAlignment(T *&basePtr, S *&objPtr, size_t nEntries=1)
void InitGPUProcessor(GPUReconstruction *rec, ProcessorType type=PROCESSOR_TYPE_CPU, GPUProcessor *slaveProcessor=nullptr)
static bool QAAvailable()
int32_t DrawQAHistograms()
void UpdateChain(GPUChainTracking *chain)
static bool IsInitialized()
int32_t InitQA(int32_t tasks=0)
void RunQA(bool matchOnly=false)
HighResTimer & getGeneralStepTimer(GeneralStep step)
void SetNActiveThreads(int32_t n)
void AddGPUEvents(T *&events)
std::vector< std::array< uint32_t, 4 > > * getErrorCodeOutput()
void PopNonPersistentMemory(RecoStep step, uint64_t tag)
void RegisterGPUDeviceProcessor(GPUProcessor *proc, GPUProcessor *slaveProcessor)
void RegisterGPUProcessor(T *proc, bool deviceSlave)
void ResetRegisteredMemoryPointers(GPUProcessor *proc)
int16_t RegisterMemoryAllocation(T *proc, void *(T::*setPtr)(void *), int32_t type, const char *name="", const GPUMemoryReuse &re=GPUMemoryReuse())
uint32_t getNEventsProcessed()
void UpdateSettings(const GPUSettingsGRP *g, const GPUSettingsProcessing *p=nullptr, const GPUSettingsRecDynamic *d=nullptr)
void PushNonPersistentMemory(uint64_t tag)
GPUMemorySizeScalers * MemoryScalers()
const GPUSettingsGRP & GetGRPSettings() const
GPUOutputControl & OutputControl()
static constexpr const uint32_t TPC_MAX_TF_TIME_BIN
GPUCalibObjectsTemplate< ConstPtr > GPUCalibObjectsConst
Global TPC definitions and constants.
Defining DataPointCompositeObject explicitly as copiable.
std::unique_ptr< GPUDisplayFrontendInterface > eventDisplay
constexpr T qStr2Tag(const char *str)
S< o2::trd::GeometryFlat >::type * trdGeometry
S< o2::tpc::CalibdEdxContainer >::type * dEdxCalibContainer
S< TPCZSLinkMapping >::type * tpcZSLinkMapping
S< TPCFastTransform >::type * fastTransform
S< TPCPadGainCalib >::type * tpcPadGain
S< o2::base::PropagatorImpl< float > >::type * o2Propagator
S< o2::base::MatLayerCylSet >::type * matLUT
S< CorrectionMapsHelper >::type * fastTransformHelper
S< TPCFastTransform >::type * fastTransformRef
S< TPCFastTransform >::type * fastTransformMShape
char * mTpcTransformMShapeBuffer
char * mTpcTransformBuffer
char * mTpcTransformRefBuffer
void * SetPointersFlatObjects(void *mem)
GPUCalibObjects mCalibObjects
char * mdEdxSplinesBuffer
GPUChainTracking * mChainTracking
std::unique_ptr< GPUTPCMCInfo[]> mcInfosTPC
std::unique_ptr< GPUTRDTrackletWord[]> trdTracklets
std::unique_ptr< GPUTPCMCInfoCol[]> mcInfosTPCCol
std::unique_ptr< GPUTPCGMMergedTrackHit[]> mergedTrackHits
std::unique_ptr< int32_t[]> trdTrackletIdxFirst
std::unique_ptr< GPUTPCGMMergedTrack[]> mergedTracks
std::unique_ptr< AliHLTTPCClusterMCLabel[]> mcLabelsTPC
std::unique_ptr< GPUTPCGMMergedTrackHitXYZ[]> mergedTrackHitsXYZ
std::unique_ptr< GPUTPCClusterData[]> clusterData[NSECTORS]
std::unique_ptr< o2::tpc::ClusterNative[]> clustersNative
std::unique_ptr< float[]> trdTriggerTimes
std::unique_ptr< GPUTPCTrack[]> sectorTracks[NSECTORS]
std::unique_ptr< GPUTRDSpacePoint[]> trdSpacePoints
std::unique_ptr< uint8_t[]> trdTrigRecMask
std::unique_ptr< o2::tpc::ClusterNativeAccess > clusterNativeAccess
std::unique_ptr< AliHLTTPCRawCluster[]> rawClusters[NSECTORS]
std::unique_ptr< GPUTPCHitId[]> sectorClusters[NSECTORS]
std::unique_ptr< GPUTRDTrackGPU[]> trdTracks
GPUTRDTrackerGPU trdTrackerGPU
GPUCalibObjectsConst calibObjects
GPUTRDTracker trdTrackerO2
const int32_t * trdTrackletIdxFirst
const GPUTPCGMMergedTrackHitXYZ * mergedTrackHitsXYZ
const GPUTPCHitId * sectorClusters[NSECTORS]
const o2::tpc::ClusterNativeAccess * clustersNative
const GPUTPCMCInfo * mcInfosTPC
uint32_t nClusterData[NSECTORS]
uint32_t nRawClusters[NSECTORS]
const o2::tpc::CompressedClustersFlat * tpcCompressedClusters
const AliHLTTPCClusterMCLabel * mcLabelsTPC
uint32_t nSectorClusters[NSECTORS]
const GPUTRDSpacePoint * trdSpacePoints
const GPUTPCTrack * sectorTracks[NSECTORS]
const GPUTRDTrackGPU * trdTracks
const GPUTRDTrackletWord * trdTracklets
const GPUTrackingInOutZS * tpcZS
const AliHLTTPCRawCluster * rawClusters[NSECTORS]
const GPUTPCClusterData * clusterData[NSECTORS]
uint32_t nSectorTracks[NSECTORS]
uint32_t nMergedTrackHits
const float * trdTriggerTimes
const uint8_t * trdTrigRecMask
const GPUTPCGMMergedTrackHit * mergedTrackHits
const GPUTrackingInOutDigits * tpcPackedDigits
uint32_t nTRDTriggerRecords
const GPUTPCMCInfoCol * mcInfosTPCCol
const GPUTPCGMMergedTrack * mergedTracks
GPUOutputControl clustersNative
size_t getIndex(const GPUOutputControl &v)
GPUOutputControl sharedClusterMap
GPUOutputControl compressedClusters
GPUOutputControl tpcTracks
unsigned int nClustersTotal