Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ MERGER_INTERPOLATION_ERROR_TYPE,"""CAMath::half_t""","""float""",,,,,,,,,,,,,,,,
COMP_GATHER_KERNEL,4,0,4,4,,,,,,4,4,4,4,,4,,4,4,
COMP_GATHER_MODE,3,0,3,3,,,,,,3,3,3,3,,3,,3,3,
CF_SCAN_WORKGROUP_SIZE,512,0,,,,,,,,224,,992,448,,1024,,,448,
CF_CHECK_PAD_BASELINE_SEGMENTED,0,0,,,,,,,,,,,,,,,,,1
MERGER_SPLIT_LOOP_INTERPOLATION,,,,,,,,,,,,,,,1,,,1,
65 changes: 65 additions & 0 deletions GPU/GPUTracking/TPCClusterFinder/GPUTPCCFCheckPadBaseline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ GPUd() void GPUTPCCFCheckPadBaseline::CheckBaselineGPU(int32_t nBlocks, int32_t

const CfFragment& frag = clusterer.mPmemory->frag;
const bool hipFilterOn = clusterer.Param().rec.tpc.hipTailFilter;
if constexpr (GPUCA_PAR_CF_CHECK_PAD_BASELINE_SEGMENTED) {
if (!hipFilterOn) {
CheckBaselineGPUSegmented(iBlock, iThread, smem, clusterer);
return;
}
}
const Charge hipTailThreshold = clusterer.Param().rec.tpc.hipTailFilterThreshold;
const Charge hipTailFilterAlpha = clusterer.Param().rec.tpc.hipTailFilterAlpha;
CfArray2D<PackedCharge> chargeMap(reinterpret_cast<PackedCharge*>(clusterer.mPchargeMap));
Expand Down Expand Up @@ -407,6 +413,65 @@ GPUd() void GPUTPCCFCheckPadBaseline::CheckBaselineGPU(int32_t nBlocks, int32_t
#endif
}

// Without the HIP tail filter, a pad only needs the number of time bins with charge, the longest run of
// them and the largest charge. These combine over consecutive time segments, so the NThreads / MaxNPadsPerRow
// threads of a pad each scan one segment straight from the charge map, instead of one thread scanning all time
// bins of the pad, and the segments are joined at the end. The result is the same as that of the scan in time order.
GPUd() void GPUTPCCFCheckPadBaseline::CheckBaselineGPUSegmented(int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer)
{
#if defined(GPUCA_GPUCODE) && !defined(GPUCA_DEVICE_SINGLE_THREAD)
constexpr int32_t NSegments = NThreads / MaxNPadsPerRow;
constexpr GPUTPCGeometry geo;
const CfFragment& frag = clusterer.mPmemory->frag;
CfArray2D<PackedCharge> chargeMap(reinterpret_cast<PackedCharge*>(clusterer.mPchargeMap));
const auto iRow = iBlock;
const int16_t nPads = geo.NPads(iRow);
const CfChargePos basePos{(Row)iRow, 0, 0};
const int16_t pad = iThread % MaxNPadsPerRow;
const int32_t segment = iThread / MaxNPadsPerRow;
const int32_t segmentLength = (frag.length + NSegments - 1) / NSegments;
const int32_t tStart = CAMath::Min<int32_t>(segment * segmentLength, frag.length);
const int32_t tEnd = CAMath::Min<int32_t>(tStart + segmentLength, frag.length);

if (segment < NSegments) {
int32_t totalCharges = 0, consecCharges = 0, maxConsecCharges = 0, firstConsecCharges = 0;
bool leading = true;
Charge maxCharge = 0;
if (pad < nPads) {
for (int32_t t = tStart; t < tEnd; t++) {
const Charge q = chargeMap[basePos.delta({pad, (TPCFragmentTime)t})].unpack();
totalCharges += q > 0;
consecCharges = q > 0 ? consecCharges + 1 : 0;
maxConsecCharges = CAMath::Max(consecCharges, maxConsecCharges);
maxCharge = CAMath::Max<Charge>(q, maxCharge);
leading &= q > 0;
firstConsecCharges += leading;
}
}
smem.segments.totalCharges[iThread] = totalCharges;
smem.segments.maxConsecCharges[iThread] = maxConsecCharges;
smem.segments.firstConsecCharges[iThread] = firstConsecCharges;
smem.segments.lastConsecCharges[iThread] = consecCharges;
smem.segments.maxCharge[iThread] = maxCharge;
}
GPUbarrier();

if (segment == 0 && pad < nPads) {
int32_t totalCharges = 0, maxConsecCharges = 0, consecCharges = 0;
Charge maxCharge = 0;
for (int32_t i = 0; i < NSegments; i++) {
const int32_t j = i * MaxNPadsPerRow + pad;
const int32_t length = CAMath::Min<int32_t>(CAMath::Min<int32_t>(i * segmentLength, frag.length) + segmentLength, frag.length) - CAMath::Min<int32_t>(i * segmentLength, frag.length);
totalCharges += smem.segments.totalCharges[j];
maxConsecCharges = CAMath::Max(maxConsecCharges, CAMath::Max(smem.segments.maxConsecCharges[j], consecCharges + smem.segments.firstConsecCharges[j]));
consecCharges = smem.segments.firstConsecCharges[j] == length ? consecCharges + length : smem.segments.lastConsecCharges[j];
maxCharge = CAMath::Max<Charge>(smem.segments.maxCharge[j], maxCharge);
}
updatePadBaseline(basePos.gpad + pad, clusterer, totalCharges, maxConsecCharges, maxCharge);
}
#endif
}

GPUd() void GPUTPCCFCheckPadBaseline::CheckBaselineCPU(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer)
{
#ifndef GPUCA_GPUCODE
Expand Down
12 changes: 11 additions & 1 deletion GPU/GPUTracking/TPCClusterFinder/GPUTPCCFCheckPadBaseline.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ class GPUTPCCFCheckPadBaseline : public GPUKernelTemplate
};

struct GPUSharedMemory : public GPUKernelTemplate::GPUSharedMemoryScan64<int16_t, NThreads> {
tpccf::Charge charges[NumOfCachedTBs][MaxNPadsPerRow];
union {
tpccf::Charge charges[NumOfCachedTBs][MaxNPadsPerRow];
struct { // Per-thread results of the segmented scan, see CheckBaselineGPUSegmented
int32_t totalCharges[NThreads];
int32_t maxConsecCharges[NThreads];
int32_t firstConsecCharges[NThreads];
int32_t lastConsecCharges[NThreads];
tpccf::Charge maxCharge[NThreads];
} segments;
};
HipTailRange tails[MaxNPadsPerRow];
uint8_t tailsClosedPad[MaxNPadsPerRow];
HipTailRange tailsClosed[MaxNPadsPerRow];
Expand Down Expand Up @@ -139,6 +148,7 @@ class GPUTPCCFCheckPadBaseline : public GPUKernelTemplate

private:
GPUd() static void CheckBaselineGPU(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer);
GPUd() static void CheckBaselineGPUSegmented(int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer);
GPUd() static void CheckBaselineCPU(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer);

GPUd() static void updatePadBaseline(int32_t pad, const GPUTPCClusterFinder&, int32_t totalCharges, int32_t consecCharges, tpccf::Charge maxCharge);
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUTracking/kernels.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ o2_gpu_kernel_add_parameter(NEIGHBOURS_FINDER_MAX_NNEIGHUP # Number o
SORT_STARTHITS # Sort start hits to improve cache locality during tracklet construction [0/1]
TPC_MERGER_REBUILD_CONSTRAINED_ROW_MEMORY # Allocate the track rebuild memory only for the row range a track can reach [0/1]
CF_SCAN_WORKGROUP_SIZE # Work group size to use in clusterizer scan operation
CF_CHECK_PAD_BASELINE_SEGMENTED # Scan the pad baseline in time segments split between the threads of a pad [0/1]
AMD_EUS_PER_CU) # Number of SIMD units per Compute Unit (only for AMD GPUs)

o2_gpu_kernel_add_string_parameter(DEDX_STORAGE_TYPE # Data type to use for intermediate storage of dEdx truncated mean inputs
Expand Down