Skip to content

GPU TPC: Run extrapolation tracking only on selected tracks - #16210

Open
OliverRietmann wants to merge 4 commits into
AliceO2Group:devfrom
cern-nextgen:PR-extrapolation-tracking
Open

OliverRietmann wants to merge 4 commits into
AliceO2Group:devfrom
cern-nextgen:PR-extrapolation-tracking

Conversation

@OliverRietmann

Copy link
Copy Markdown
Contributor

Changes: For every TPC sector, during GPUTPCTrackletSelector, we write a list of left and right exiting tracks. Then GPUTPCExtrapolationTracking only runs on those tracks. Newly, we do this per pair of sectors, or per edge that they share, respectively. This changes how the sectors have to wait for their neighboring sectors to finish GPUTPCTrackletSelector. While not strictly necessary, we have changed the number of streams and how we assign them to the sectors. Finally, the GPUParameters.csv was updated to fit the new extrapolation tracking.

Remarks:

  1. Since extrapolation tracking is now done per edge rather than per sector, we needed write access via iSector.GetConstantMem()->tpcTrackers[iSectorNeighbor]. This is was actively prohibited before and should thus be looked at.
  2. Since the extrapolation over the left and right edge of a sector now run in different streams, copying to the host is less trivial. The PR implements a redundant copy in GPUChainTracking::ExtrapolationTracking. The two copies are racing, but in a way taht doesn't corrupt the final data (on copy copies a subset of the other). Maybe we can find a better solution for this.

@davidrohr davidrohr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general comments, didn't check the kernel in detail, I assume with deterministic reconstruction, it reproduces the previous output exactly?

#endif

GPUd() GPUconstantref() const GPUConstantMem* GetConstantMem() const; // Body in GPUConstantMem.h to avoid circular headers
GPUd() GPUconstantref() GPUConstantMem* GetConstantMem(); // ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need a non-const version? In principle, this should be constant memory during kernels?

void GPUReconstruction::RegisterGPUDeviceProcessor(GPUProcessor* proc, GPUProcessor* slaveProcessor) { proc->InitGPUProcessor(this, GPUProcessor::PROCESSOR_TYPE_DEVICE, slaveProcessor); }
void GPUReconstruction::ConstructGPUProcessor(GPUProcessor* proc) { proc->mConstantMem = proc->mGPUProcessorType == GPUProcessor::PROCESSOR_TYPE_DEVICE ? mDeviceConstantMem : mHostConstantMem.get(); }

uint32_t GPUReconstruction::StreamForSector(uint32_t sector) const

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move everything that is not pure-GPU related to GPUChainTracking. GPUReconstruction should be generic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reusable memory in GPUTPCTracker::RegisterMemoryAllocation() relied on the specific way of assigning the sectors to the streams that we had before (round robin). I moved the function to have a "single source of truth" for both GPUTPCTracker and GPUTPCChainTrackingSectorTracker. I can move it back to GPUChainTracking and include the latter in GPUTPCTracker.

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(nStreams, int8_t, 6, "", 0, "Number of GPU streams / command queues")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong, but I belive the TPC clusterization can parallelize over 7 streams at the moment. I thought you wanted to add a nStreamsTPCSectorTracking option, to use only a subset of streams in the sector tracking?

GPUhd() GPUglobalref() GPUAtomic(uint32_t) * NExtrapolationCandidatesRight() const { return &mCommonMem->nExtrapolationCandidatesRight; }
GPUhd() GPUglobalref() int32_t* ExtrapolationCandidatesLeft() const { return mExtrapolationCandidatesLeft; }
GPUhd() GPUglobalref() int32_t* ExtrapolationCandidatesRight() const { return mExtrapolationCandidatesRight; }
GPUhd() GPUglobalref() int32_t* ExtrapolationCandidatesLeftDirection() const { return mExtrapolationCandidatesLeftDirection; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int8_t should be enough. In principle, you should be able to store the direction together with the candidateID by using the highest bit. nTracks should never exceed 24 bit anyway.

@davidrohr

Copy link
Copy Markdown
Collaborator

2. Since the extrapolation over the left and right edge of a sector now run in different streams, copying to the host is less trivial. The PR implements a redundant copy in GPUChainTracking::ExtrapolationTracking. The two copies are racing, but in a way taht doesn't corrupt the final data (on copy copies a subset of the other). Maybe we can find a better solution for this.

I think you can just use GPUMemcpy directly to copy only part of a buffer?

@davidrohr

Copy link
Copy Markdown
Collaborator
  1. Since extrapolation tracking is now done per edge rather than per sector, we needed write access via iSector.GetConstantMem()->tpcTrackers[iSectorNeighbor]. This is was actively prohibited before and should thus be looked at.

I still don't understand what do you need the write access for? You should only write to the arrays, but not to the constant memory itself.
In any case, probably what you want to do instead is to change the processoor type of the processor, so that you get all of them (like

  GPUhdi() static processorType* Processor(GPUConstantMem& processors)
  {
    return &processors;
  }

like the merger and DataCompression kernels do it. Then your kernel already receives ConstantMem and not only the current sector GPUTPCTracker.

{
AllocateAndInitializeLate();
bool reuseCondition = MemoryReuseAllowed();
GPUMemoryReuse reLinks{reuseCondition, GPUMemoryReuse::REUSE_1TO1, GPUMemoryReuse::TrackerDataLinks, (uint16_t)(mISector % mRec->GetProcessingSettings().nStreams)};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you refer to this? This seems a bug indeed! I'd do the following:

  • Move StreamForSector back to GPUChainTracking.
  • Include GPUChainTracking.h to GPUTPCTracker.cxx #ifndef GPUCAGPUCODE
  • Add an optional option to StreamForSector overriding the nstreams, and use the new parameter for tpcsectortracking when called from GPUTPCTracker.cxx

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants