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
5 changes: 5 additions & 0 deletions GPU/GPUTracking/Base/GPUReconstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ int32_t GPUReconstruction::InitPhaseBeforeDevice()
mNStreams = std::max<int32_t>(GetProcessingSettings().nStreams, 3);
}

if ((int32_t)GetProcessingSettings().nStreamsTPCSectorTracking > GetProcessingSettings().nStreams || GetProcessingSettings().nStreamsTPCSectorTracking < 1) {
GPUError("Invalid value for nStreamsTPCSectorTracking: %d (must not exceed nStreams: %d)", GetProcessingSettings().nStreamsTPCSectorTracking, (int32_t)GetProcessingSettings().nStreams);
mProcessingSettings->nStreamsTPCSectorTracking = std::max<int8_t>(GetProcessingSettings().nStreams, 1);
}

if (GetProcessingSettings().nTPCClustererLanes == -1) {
mProcessingSettings->nTPCClustererLanes = (GetRecoStepsGPU() & RecoStep::TPCClusterFinding) ? 3 : std::max<int32_t>(1, std::min<int32_t>(GPUTPCGeometry::NSECTORS, GetProcessingSettings().inKernelParallel ? (mMaxHostThreads >= 4 ? std::min<int32_t>(mMaxHostThreads / 2, mMaxHostThreads >= 32 ? GPUTPCGeometry::NSECTORS : 4) : 1) : mMaxHostThreads));
}
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUTracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set(HDRS_INSTALL
SectorTracker/GPUTPCBaseTrackParam.h
SectorTracker/GPUTPCClusterData.h
SectorTracker/GPUTPCDef.h
SectorTracker/GPUTPCExtrapolationCandidate.h
SectorTracker/GPUTPCHit.h
SectorTracker/GPUTPCHitId.h
SectorTracker/GPUTPCMCInfo.h
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUTracking/Definitions/GPUSettingsList.template
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ AddOption(ompThreads, int32_t, -1, "", 0, "Deprecated synonym for nHostThreads")
AddOption(inKernelParallel, uint8_t, 2, "", 0, "Parallelize with multi-threading inside kernels on the host instead of over TPC sectors: 0 disable, 1 full and exclusive in-kernel parallelization, 2 for nested parallelization over TPC sectors (nTPCClustererLanes thread-groups) and inside kernels")
AddOption(autoAdjustHostThreads, bool, true, "", 0, "Auto-adjust number of OMP threads, decreasing the number for small input data")
AddOption(nStreams, int8_t, 8, "", 0, "Number of GPU streams / command queues")
AddOption(nStreamsTPCSectorTracking, int8_t, 6, "", 0, "Number of GPU streams / command queues for TPC sector tracking, gets clamped by nStreams")
AddOption(nTPCClustererLanes, int8_t, -1, "", 0, "Number of TPC clusterers that can run in parallel (-1 = autoset)")
AddOption(overrideClusterizerFragmentLen, int32_t, -1, "", 0, "Force the cluster max fragment len to a certain value (-1 = autodetect)")
AddOption(delayedOutput, bool, true, "", 0, "Delay output to be parallel to track fit")
Expand Down
20 changes: 10 additions & 10 deletions GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ WARP_SIZE,0,,64,64,32,32,32,32,32,32,32,32,32,32,32,64,32,64,32
THREAD_COUNT_DEFAULT,256,,256,256,,,,,,512,512,,512,256,512,512,512,,256
,,,,,,,,,,,,,,,,,,,
LB:,,,,,,,,,,,,,,,,,,,
GPUTPCCreateTrackingData,256,,"[256, 7]","[192, 2]",,,,,,"[224, 7]",256,"[128, 14]",416,,"[64, 21]",,384,"[320, 2]",64
GPUTPCTrackletConstructor,256,,"[768, 8]","[512, 10]","[256, 2]","[256, 1]","[256, 2]","[1024, 2]","[512, 4]",1024,"[256, 2]",1024,"[1024, 1]",,"[768, 2]",,768,512,"[128, 32]"
GPUTPCTrackletSelector,256,,"[384, 5]","[192, 10]","[256, 3]","[256, 1]","[256, 3]","[512, 4]","[256, 3]","[288, 3]","[192, 3]","[544, 1]","[32, 2]",,"[384, 3]",,992,"[256, 6]",
GPUTPCNeighboursFinder,256,,"[192, 8]","[960, 8]",256,256,256,512,256,864,"[640, 1]","[512, 2]","[736, 1]",,"[480, 3]",,992,"[704, 1]",
GPUTPCNeighboursCleaner,256,,"[128, 5]","[384, 9]",256,256,256,256,256,544,512,"[192, 9]","[512, 1]",,"[384, 5]",,672,"[640, 1]",
GPUTPCExtrapolationTracking,256,,"[256, 7]","[256, 2]",,,,,,"[352, 4]","[192, 2]","[896, 1]","[352, 1]",,"[1024, 1]",,896,1024,
GPUTPCCreateTrackingData,256,,"[256, 7]","[192, 2]",,,,,,"[224, 7]",256,"[128, 14]","[128, 6]",,"[64, 21]",,384,"[256, 2]",64
GPUTPCTrackletConstructor,256,,"[768, 8]","[512, 10]","[256, 2]","[256, 1]","[256, 2]","[1024, 2]","[512, 4]",1024,"[256, 2]",1024,"[1024, 1]",,"[768, 2]",,768,"[512, 1]","[128, 32]"
GPUTPCTrackletSelector,256,,"[384, 5]","[192, 10]","[256, 3]","[256, 1]","[256, 3]","[512, 4]","[256, 3]","[288, 3]","[192, 3]","[544, 1]",352,,"[384, 3]",,992,"[64, 16]",
GPUTPCNeighboursFinder,256,,"[192, 8]","[960, 8]",256,256,256,512,256,864,"[640, 1]","[512, 2]","[896, 1]",,"[480, 3]",,992,"[896, 1]",
GPUTPCNeighboursCleaner,256,,"[128, 5]","[384, 9]",256,256,256,256,256,544,512,"[192, 9]","[256, 2]",,"[384, 5]",,672,"[512, 3]",
GPUTPCExtrapolationTracking,256,,"[128, 1]","[128, 1]",,,,,,"[64, 1]","[64, 1]","[64, 1]","[544, 2]",,"[128, 1]",,"[64, 1]","[128, 1]",
GPUTRDTrackerKernels_gpuVersion,512,,,,,,,,,512,,512,512,,512,,,512,
GPUTPCCreateOccupancyMap_fill,256,,,,,,,,,256,,256,256,,256,,,256,
GPUTPCCreateOccupancyMap_fold,256,,,,,,,,,256,,256,256,,256,,,256,
Expand Down Expand Up @@ -64,8 +64,8 @@ GPUTPCGMMergerMergeLoopers_step1,256,,,,,,,,,256,,256,256,,256,,256,256,
GPUTPCGMMergerMergeLoopers_step2,256,,,,,,,,,256,,256,256,,256,,256,256,
GPUTPCGMO2Output_prepare,256,,,,,,,,,256,,256,256,,256,,256,256,
GPUTPCGMO2Output_output,256,,,,,,,,,256,,256,256,,256,,256,256,
GPUTPCStartHitsFinder,256,,"[1024, 2]","[1024, 7]",256,256,256,256,256,"[224, 1]",512,"[416, 4]",928,,"[320, 5]",,608,"[448, 3]",
GPUTPCStartHitsSorter,256,,"[1024, 5]","[512, 7]",256,256,256,256,256,"[320, 2]","[512, 1]","[864, 1]","[96, 2]",,"[192, 5]",,608,"[448, 1]",
GPUTPCStartHitsFinder,256,,"[1024, 2]","[1024, 7]",256,256,256,256,256,"[224, 1]",512,"[256, 1]","[224, 5]",,"[896, 2]",,"[928, 1]","[256, 5]",
GPUTPCStartHitsSorter,256,,"[1024, 5]","[512, 7]",256,256,256,256,256,"[320, 2]","[512, 1]",640,"[1024, 1]",,"[320, 6]",,928,448,
GPUTPCCFCheckPadBaseline,576,,"[576, 2]","[576, 2]",,,,,,"[576, 3]",,"[576, 1]","[576, 1]",,"[576, 2]",,"[576, 2]",576,
GPUTPCCFHIPTailConnector,256,,256,256,,,,,,"[224, 2]",,"[320, 5]","[704, 1]",,"[128, 7]",,,"[448, 4]",
GPUTPCCFHIPClusterizer,256,,256,256,,,,,,"[288, 5]",,"[480, 3]","[448, 3]",,352,,,"[512, 3]",
Expand Down Expand Up @@ -111,8 +111,8 @@ AMD_EUS_PER_CU,0,0,4,4,,,,,,,,,,,4,,0,4,
SORT_STARTHITS,1,0,,,,,,,,1,,1,1,,1,,1,1,
TPC_MERGER_REBUILD_CONSTRAINED_ROW_MEMORY,0,0,,,,,,,,,,,,,,,,,
NEIGHBOURS_FINDER_MAX_NNEIGHUP,6,0,10,4,,,,,,4,4,4,4,,5,,2,5,
NEIGHBOURS_FINDER_UNROLL_GLOBAL,4,0,4,2,,,,,,2,,8,8,,4,,2,2,
NEIGHBOURS_FINDER_UNROLL_SHARED,1,0,0,0,,,,,,1,,1,0,,1,,1,1,
NEIGHBOURS_FINDER_UNROLL_GLOBAL,4,0,4,2,,,,,,2,,8,2,,2,,8,4,
NEIGHBOURS_FINDER_UNROLL_SHARED,1,0,0,0,,,,,,1,,0,1,,0,,1,0,
TRACKLET_SELECTOR_HITS_REG_SIZE,12,0,9,27,,,,,,20,20,20,20,,20,,2,20,
ALTERNATE_BORDER_SORT,1,0,1,1,,,,,,1,1,1,1,,1,,1,1,
SORT_BEFORE_FIT,1,0,1,1,,,,,,1,1,1,1,,1,,1,1,
Expand Down
7 changes: 2 additions & 5 deletions GPU/GPUTracking/Global/GPUChainTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class GPUChainTracking : public GPUChain
int32_t DoQueuedUpdates(int32_t stream, bool updateSlave = true); // Forces doing queue calib updates, don't call when you are not sure you are allowed to do so!
bool QARanForTF() const { return mFractionalQAEnabled; }
static void ApplySyncSettings(GPUSettingsProcessing& proc, GPUSettingsRec& rec, gpudatatypes::RecoStepField& steps, bool syncMode, bool asyncMode, int32_t dEdxMode = -2);
static uint32_t StreamForSector(uint32_t sector, const GPUSettingsProcessing& proc);

// Structures for input and output data
GPUTrackingInOutPointers& mIOPtrs;
Expand Down Expand Up @@ -220,6 +221,7 @@ class GPUChainTracking : public GPUChain
struct eventStruct // Must consist only of void* ptr that will hold the GPU event ptrs!
{
deviceEvent sector[NSECTORS];
deviceEvent extrapolationTrackingDone[NSECTORS];
deviceEvent stream[constants::GPU_MAX_STREAMS];
deviceEvent init;
deviceEvent single;
Expand All @@ -234,8 +236,6 @@ class GPUChainTracking : public GPUChain

GPUChainTracking(GPUReconstruction* rec, uint32_t maxTPCHits = constants::GPU_MEM_MAX_TPC_CLUSTERS, uint32_t maxTRDTracklets = constants::GPU_MEM_MAX_TRD_TRACKLETS);

int32_t ExtrapolationTracking(uint32_t iSector, bool blocking);

int32_t PrepareProfile();
int32_t DoProfile();
void PrintMemoryRelations();
Expand Down Expand Up @@ -295,8 +295,6 @@ class GPUChainTracking : public GPUChain

// Synchronization and Locks
eventStruct* mEvents = nullptr;
std::array<int8_t, NSECTORS> mExtrapolationTrackingDone;

std::vector<outputQueueEntry> mOutputQueue;

private:
Expand All @@ -321,7 +319,6 @@ class GPUChainTracking : public GPUChain
void SortClusters(bool buildNativeGPU, bool propagateMCLabels, o2::tpc::ClusterNativeAccess* clusterAccess, o2::tpc::ClusterNative* clusters);
template <int32_t I>
int32_t RunTRDTrackingInternal();
uint32_t StreamForSector(uint32_t sector) const;

// Debug
void DoDebugMergerNClDump(const GPUTPCGMMerger& merger);
Expand Down
64 changes: 31 additions & 33 deletions GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,15 @@

using namespace o2::gpu;

uint32_t GPUChainTracking::StreamForSector(uint32_t sector) const
uint32_t GPUChainTracking::StreamForSector(uint32_t sector, const GPUSettingsProcessing& proc)
{
return sector % mRec->NStreams();
}

int32_t GPUChainTracking::ExtrapolationTracking(uint32_t iSector, bool blocking)
{
const uint32_t stream = StreamForSector(iSector);
runKernel<GPUTPCExtrapolationTracking>({GetGridBlk(256, stream), {iSector}});
TransferMemoryResourceLinkToHost(RecoStep::TPCSectorTracking, processors()->tpcTrackers[iSector].MemoryResCommon(), stream);
if (blocking) {
SynchronizeStream(stream);
uint32_t nStreams = proc.nStreamsTPCSectorTracking;
if (nStreams % 2 == 0 && nStreams > 1) {
uint32_t nStreamsHalf = nStreams / 2;
return sector % nStreamsHalf + (2 * sector < NSECTORS ? 0 : nStreamsHalf);
} else {
return sector % nStreams;
}
return (0);
}

int32_t GPUChainTracking::RunTPCTrackingSectors()
Expand Down Expand Up @@ -145,7 +140,7 @@ int32_t GPUChainTracking::RunTPCTrackingSectors_internal()
mRec->runParallelOuterLoop(doGPU, NSECTORS, [&](uint32_t iSector) {
GPUTPCTracker& trk = processors()->tpcTrackers[iSector];
GPUTPCTracker& trkShadow = doGPU ? processorsShadow()->tpcTrackers[iSector] : trk;
int32_t useStream = StreamForSector(iSector);
int32_t useStream = StreamForSector(iSector, GetProcessingSettings());

if (GetProcessingSettings().debugLevel >= 3) {
GPUInfo("Creating Sector Data (Sector %d)", iSector);
Expand Down Expand Up @@ -230,39 +225,42 @@ int32_t GPUChainTracking::RunTPCTrackingSectors_internal()

if (doGPU || GetProcessingSettings().debugLevel >= 1) {
if (param().rec.tpc.extrapolationTracking) {
std::vector<bool> blocking(NSECTORS * mRec->NStreams());
for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
for (uint32_t iStream = 0; iStream < mRec->NStreams(); iStream++) {
blocking[iSector * mRec->NStreams() + iStream] = StreamForSector(iSector) == iStream;
}
uint32_t nSectorsHalf = NSECTORS / 2;
for (uint32_t leftSector = 0; leftSector < NSECTORS; leftSector++) {
uint32_t rightSector = (leftSector + 1) % nSectorsHalf + (leftSector < nSectorsHalf ? 0 : nSectorsHalf);
int32_t stream = StreamForSector(leftSector, GetProcessingSettings());
StreamWaitForEvents(stream, &mEvents->sector[rightSector]);
runKernel<GPUTPCExtrapolationTracking>({GetGridBlk(256, stream)}, leftSector, rightSector);
RecordMarker(&mEvents->extrapolationTrackingDone[leftSector], stream);
}
for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
uint32_t tmpSector = GPUTPCExtrapolationTracking::ExtrapolationTrackingSectorOrder(iSector);
uint32_t sectorLeft, sectorRight;
GPUTPCExtrapolationTracking::ExtrapolationTrackingSectorLeftRight(tmpSector, sectorLeft, sectorRight);
if (doGPU && !blocking[tmpSector * mRec->NStreams() + StreamForSector(sectorLeft)]) {
StreamWaitForEvents(StreamForSector(tmpSector), &mEvents->sector[sectorLeft]);
blocking[tmpSector * mRec->NStreams() + StreamForSector(sectorLeft)] = true;
}
if (doGPU && !blocking[tmpSector * mRec->NStreams() + StreamForSector(sectorRight)]) {
StreamWaitForEvents(StreamForSector(tmpSector), &mEvents->sector[sectorRight]);
blocking[tmpSector * mRec->NStreams() + StreamForSector(sectorRight)] = true;
}
ExtrapolationTracking(tmpSector, false);
for (uint32_t rightSector = 0; rightSector < NSECTORS; rightSector++) {
uint32_t leftSector = (rightSector + nSectorsHalf - 1) % nSectorsHalf + (rightSector < nSectorsHalf ? 0 : nSectorsHalf);
int32_t stream = StreamForSector(rightSector, GetProcessingSettings());
TransferMemoryResourceLinkToHost(RecoStep::TPCSectorTracking, processors()->tpcTrackers[rightSector].MemoryResCommon(), stream, nullptr, &mEvents->extrapolationTrackingDone[leftSector]);
}
}
if (doGPU) {
ReleaseEvent(mEvents->init);
for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
ReleaseEvent(mEvents->sector[iSector]);
ReleaseEvent(mEvents->extrapolationTrackingDone[iSector]);
}
}
} else {
mRec->runParallelOuterLoop(doGPU, NSECTORS, [&](uint32_t iSector) {
mRec->runParallelOuterLoop(doGPU, NSECTORS, [&](uint32_t leftSector) {
if (param().rec.tpc.extrapolationTracking) {
ExtrapolationTracking(iSector, true);
uint32_t nSectorsHalf = NSECTORS / 2;
uint32_t rightSector = (leftSector + 1) % nSectorsHalf + (leftSector < nSectorsHalf ? 0 : nSectorsHalf);
int32_t stream = StreamForSector(leftSector, GetProcessingSettings());
runKernel<GPUTPCExtrapolationTracking>({GetGridBlk(256, stream)}, leftSector, rightSector);
}
});
if (param().rec.tpc.extrapolationTracking && mRec->IsGPU()) {
mRec->runParallelOuterLoop(doGPU, NSECTORS, [&](uint32_t sector) {
int32_t stream = StreamForSector(sector, GetProcessingSettings());
TransferMemoryResourceLinkToHost(RecoStep::TPCSectorTracking, processors()->tpcTrackers[sector].MemoryResCommon(), stream);
});
}
mRec->SetNActiveThreadsOuterLoop(1);
}

Expand Down
40 changes: 40 additions & 0 deletions GPU/GPUTracking/SectorTracker/GPUTPCExtrapolationCandidate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file GPUTPCExtrapolationCandidate.h
/// \author Oliver Rietmann

#ifndef GPUTPCEXTRAPOLATIONCANDIDATE_H
#define GPUTPCEXTRAPOLATIONCANDIDATE_H

#include "GPUCommonDef.h"

namespace o2::gpu
{
class GPUTPCExtrapolationCandidate
{
public:
GPUhd() static int32_t Pack(int32_t localTrackId, int32_t direction)
{
return (direction == -1) ? (int32_t)((uint32_t)localTrackId | 0x80000000u) : localTrackId;
}
GPUhd() static int32_t GetLocalTrackId(int32_t packed)
{
return (int32_t)((uint32_t)packed & 0x7FFFFFFFu);
}
GPUhd() static int32_t GetDirection(int32_t packed)
{
return ((uint32_t)packed & 0x80000000u) ? -1 : 1;
}
};
} // namespace o2::gpu

#endif
Loading