Skip to content

Commit 4ec1f57

Browse files
committed
GPU: Do not copy scratch memory forth and back in TPC merger on GPU
1 parent cb6bc44 commit 4ec1f57

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,27 +251,43 @@ void* GPUTPCGMMerger::SetPointersMemory(void* mem)
251251
return mem;
252252
}
253253

254-
void* GPUTPCGMMerger::SetPointersRefit(void* mem)
254+
void* GPUTPCGMMerger::SetPointersRefitScratch(void* mem)
255255
{
256256
computePointerWithAlignment(mem, mRetryRefitIds, mNMaxTracks);
257257
computePointerWithAlignment(mem, mLoopData, mNMaxTracks);
258-
computePointerWithAlignment(mem, mOutputTracks, mNMaxTracks);
259-
computePointerWithAlignment(mem, mClusters, mNMaxOutputTrackClusters);
258+
if (mRec->GetDeviceProcessingSettings().fullMergerOnGPU) {
259+
mem = SetPointersRefitScratch2(mem);
260+
}
261+
return mem;
262+
}
263+
264+
void* GPUTPCGMMerger::SetPointersRefitScratch2(void* mem)
265+
{
260266
computePointerWithAlignment(mem, mTrackOrderAttach, mNMaxTracks);
261267
if (mRec->GetDeviceProcessingSettings().mergerSortTracks) {
262268
computePointerWithAlignment(mem, mTrackOrderProcess, mNMaxTracks);
263269
}
270+
return mem;
271+
}
272+
273+
void* GPUTPCGMMerger::SetPointersRefit(void* mem)
274+
{
275+
computePointerWithAlignment(mem, mOutputTracks, mNMaxTracks);
276+
computePointerWithAlignment(mem, mClusters, mNMaxOutputTrackClusters);
264277
computePointerWithAlignment(mem, mClusterAttachment, mNMaxClusters);
278+
if (!mRec->GetDeviceProcessingSettings().fullMergerOnGPU) {
279+
mem = SetPointersRefitScratch2(mem);
280+
}
265281

266282
return mem;
267283
}
268284

269285
void GPUTPCGMMerger::RegisterMemoryAllocation()
270286
{
271287
AllocateAndInitializeLate();
272-
auto mergerMemory = mRec->GetDeviceProcessingSettings().fullMergerOnGPU ? GPUMemoryResource::MEMORY_SCRATCH : (GPUMemoryResource::MEMORY_SCRATCH | GPUMemoryResource::MEMORY_HOST);
273-
mRec->RegisterMemoryAllocation(this, &GPUTPCGMMerger::SetPointersMerger, mergerMemory, "TPCMerger");
274-
mRec->RegisterMemoryAllocation(this, &GPUTPCGMMerger::SetPointersRefit, GPUMemoryResource::MEMORY_INOUT, "TPCMergerRefit");
288+
mRec->RegisterMemoryAllocation(this, &GPUTPCGMMerger::SetPointersMerger, mRec->GetDeviceProcessingSettings().fullMergerOnGPU ? GPUMemoryResource::MEMORY_SCRATCH : (GPUMemoryResource::MEMORY_SCRATCH | GPUMemoryResource::MEMORY_HOST), "TPCMerger");
289+
mRec->RegisterMemoryAllocation(this, &GPUTPCGMMerger::SetPointersRefitScratch, GPUMemoryResource::MEMORY_SCRATCH, "TPCMergerRefitScratch");
290+
mRec->RegisterMemoryAllocation(this, &GPUTPCGMMerger::SetPointersRefit, mRec->GetDeviceProcessingSettings().fullMergerOnGPU ? GPUMemoryResource::MEMORY_OUTPUT : GPUMemoryResource::MEMORY_INOUT, "TPCMergerRefit");
275291
mMemoryResMemory = mRec->RegisterMemoryAllocation(this, &GPUTPCGMMerger::SetPointersMemory, GPUMemoryResource::MEMORY_PERMANENT, "TPCMergerMemory");
276292
}
277293

GPU/GPUTracking/Merger/GPUTPCGMMerger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class GPUTPCGMMerger : public GPUProcessor
8282
void RegisterMemoryAllocation();
8383
void SetMaxData(const GPUTrackingInOutPointers& io);
8484
void* SetPointersMerger(void* mem);
85+
void* SetPointersRefitScratch(void* mem);
86+
void* SetPointersRefitScratch2(void* mem);
8587
void* SetPointersRefit(void* mem);
8688
void* SetPointersMemory(void* mem);
8789

0 commit comments

Comments
 (0)