Project
Loading...
Searching...
No Matches
GPUTPCTracker.cxx
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
14
15#include "GPUTPCTracker.h"
16#include "GPUTPCRow.h"
17#include "GPUTPCTrack.h"
18#include "GPUCommonMath.h"
19
20#include "GPUTPCClusterData.h"
21#include "GPUO2DataTypes.h"
22#include "GPUTPCTrackParam.h"
23#include "GPUParam.inc"
24#include "GPUTPCConvertImpl.h"
25
26#if !defined(GPUCA_GPUCODE)
27#include <cstring>
28#include <cmath>
29#include <algorithm>
30#include <stdexcept>
31
32#include "GPUReconstruction.h"
34#endif
35
36using namespace o2::gpu;
37using namespace o2::tpc;
38
39#if !defined(GPUCA_GPUCODE)
40
42
43// ----------------------------------------------------------------------------------
44void GPUTPCTracker::SetSector(int32_t iSector) { mISector = iSector; }
46{
47 if (mISector < 0) {
48 throw std::runtime_error("Sector not set");
49 }
52}
53
54void* GPUTPCTracker::SetPointersDataLinks(void* mem) { return mData.SetPointersLinks(mem); }
55void* GPUTPCTracker::SetPointersDataWeights(void* mem) { return mData.SetPointersWeights(mem); }
57void* GPUTPCTracker::SetPointersDataRows(void* mem) { return mData.SetPointersRows(mem); }
58
60{
61 computePointerWithAlignment(mem, mTrackletStartHits, mNMaxStartHits);
62 if (mRec->GetProcessingSettings().memoryAllocationStrategy != GPUMemoryResource::ALLOCATION_INDIVIDUAL) {
63 mem = SetPointersTracklets(mem);
64 }
66 computePointerWithAlignment(mem, mTrackletTmpStartHits, GPUCA_ROW_COUNT * mNMaxRowStartHits);
67 computePointerWithAlignment(mem, mRowStartHitCountOffset, GPUCA_ROW_COUNT);
68 }
69 return mem;
70}
71
73{
74 if (mRec->GetProcessingSettings().keepDisplayMemory) {
75 computePointerWithAlignment(mem, mLinkTmpMemory, mRec->Res(mMemoryResLinks).Size());
76 }
78 return mem;
79}
80
82{
83 computePointerWithAlignment(mem, mCommonMem, 1);
84 return mem;
85}
86
88{
90 bool reuseCondition = !mRec->GetProcessingSettings().keepDisplayMemory && ((mRec->GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCSectorTracking) || mRec->GetProcessingSettings().inKernelParallel == 1 || mRec->GetProcessingSettings().nHostThreads == 1);
91 GPUMemoryReuse reLinks{reuseCondition, GPUMemoryReuse::REUSE_1TO1, GPUMemoryReuse::TrackerDataLinks, (uint16_t)(mISector % mRec->GetProcessingSettings().nStreams)};
94 GPUMemoryReuse reWeights{reuseCondition, GPUMemoryReuse::REUSE_1TO1, GPUMemoryReuse::TrackerDataWeights, (uint16_t)(mISector % mRec->GetProcessingSettings().nStreams)};
96 GPUMemoryReuse reScratch{reuseCondition, GPUMemoryReuse::REUSE_1TO1, GPUMemoryReuse::TrackerScratch, (uint16_t)(mISector % mRec->GetProcessingSettings().nStreams)};
101
103 if (mRec->GetProcessingSettings().memoryAllocationStrategy == GPUMemoryResource::ALLOCATION_INDIVIDUAL) { // For individual scheme, we allocate tracklets separately, and change the type for the following allocations to custom
105 mMemoryResTracklets = mRec->RegisterMemoryAllocation(this, &GPUTPCTracker::SetPointersTracklets, type, "TPCTrackerTracklets");
106 }
107 mMemoryResOutput = mRec->RegisterMemoryAllocation(this, &GPUTPCTracker::SetPointersOutput, type, "TPCTrackerTracks");
108}
109
110GPUhd() void* GPUTPCTracker::SetPointersTracklets(void* mem)
111{
112 computePointerWithAlignment(mem, mTracklets, mNMaxTracklets);
113 computePointerWithAlignment(mem, mTrackletRowHits, mNMaxRowHits);
114 return mem;
115}
116
117GPUhd() void* GPUTPCTracker::SetPointersOutput(void* mem)
118{
119 computePointerWithAlignment(mem, mTracks, mNMaxTracks);
120 computePointerWithAlignment(mem, mTrackHits, mNMaxTrackHits);
121 return mem;
122}
123
125{
126 if (mRec->GetProcessingSettings().memoryAllocationStrategy == GPUMemoryResource::ALLOCATION_INDIVIDUAL) {
127 mNMaxStartHits = mData.NumberOfHits();
128 } else {
129 mNMaxStartHits = mRec->MemoryScalers()->NTPCStartHits(mData.NumberOfHits());
130 }
131 if (io.clustersNative) {
132 uint32_t maxRowHits = 0;
133 for (uint32_t i = 0; i < GPUCA_ROW_COUNT; i++) {
134 if (io.clustersNative->nClusters[mISector][i] > maxRowHits) {
135 maxRowHits = io.clustersNative->nClusters[mISector][i];
136 }
137 }
138 mNMaxRowStartHits = mRec->MemoryScalers()->NTPCRowStartHits(maxRowHits * GPUCA_ROW_COUNT);
139 } else {
140 mNMaxRowStartHits = mRec->MemoryScalers()->NTPCRowStartHits(mData.NumberOfHits());
141 }
142 mNMaxTracklets = mRec->MemoryScalers()->NTPCTracklets(mData.NumberOfHits());
143 mNMaxRowHits = mRec->MemoryScalers()->NTPCTrackletHits(mData.NumberOfHits());
144 mNMaxTracks = mRec->MemoryScalers()->NTPCSectorTracks(mData.NumberOfHits());
145 mNMaxTrackHits = mRec->MemoryScalers()->NTPCSectorTrackHits(mData.NumberOfHits(), mRec->GetProcessingSettings().tpcInputWithClusterRejection);
146#ifdef GPUCA_SORT_STARTHITS_GPU
148 if (mNMaxStartHits > mNMaxRowStartHits * GPUCA_ROW_COUNT) {
149 mNMaxStartHits = mNMaxRowStartHits * GPUCA_ROW_COUNT;
150 }
151 }
152#endif
153 mData.SetMaxData();
154}
155
157{
158 mNMaxTracklets = mCommonMem->nStartHits;
159 mNMaxTracks = mNMaxTracklets * 2 + 50;
160 mNMaxRowHits = mNMaxTracklets * GPUCA_ROW_COUNT;
161}
162
164
165GPUh() int32_t GPUTPCTracker::CheckEmptySector()
166{
167 // Check if the Sector is empty, if so set the output apropriate and tell the reconstuct procesdure to terminate
168 if (NHitsTotal() < 1) {
169 mCommonMem->nTracks = mCommonMem->nTrackHits = 0;
170 return 1;
171 }
172 return 0;
173}
174
175#endif
int32_t i
#define GPUhd()
#define GPUh()
#define GPUCA_ROW_COUNT
GPUReconstruction * mRec
static void computePointerWithAlignment(T *&basePtr, S *&objPtr, size_t nEntries=1)
RecoStepField GetRecoStepsGPU() const
int16_t RegisterMemoryAllocation(T *proc, void *(T::*setPtr)(void *), int32_t type, const char *name="", const GPUMemoryReuse &re=GPUMemoryReuse())
GPUMemoryResource & Res(int16_t num)
GPUMemorySizeScalers * MemoryScalers()
const GPUSettingsProcessing & GetProcessingSettings() const
void * SetPointersScratchHost(void *mem)
void * SetPointersDataWeights(void *mem)
void * SetPointersDataRows(void *mem)
void * SetPointersOutput(void *mem)
void SetMaxData(const GPUTrackingInOutPointers &io)
void * SetPointersDataLinks(void *mem)
void * SetPointersDataScratch(void *mem)
void InitializeRows(const GPUParam *param)
void * SetPointersCommon(void *mem)
void * SetPointersTracklets(void *mem)
void * SetPointersScratch(void *mem)
void SetSector(int32_t iSector)
void * SetPointersScratch(void *mem, bool idsOnGPU)
void * SetPointersClusterIds(void *mem, bool idsOnGPU)
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
Global TPC definitions and constants.
Definition SimTraits.h:167
size_t NTPCSectorTrackHits(size_t tpcHits, uint8_t withRejection=0)
size_t NTPCTracklets(size_t tpcHits)
size_t NTPCTrackletHits(size_t tpcHits)
size_t NTPCSectorTracks(size_t tpcHits)
size_t NTPCRowStartHits(size_t tpcHits)
size_t NTPCStartHits(size_t tpcHits)
const o2::tpc::ClusterNativeAccess * clustersNative
unsigned int nClusters[constants::MAXSECTOR][constants::MAXGLOBALPADROW]