Skip to content

Commit

Permalink
GPU: Add possibility to allocate also non-device volatile memory
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrohr committed Mar 4, 2024
1 parent b4a04fd commit 6a28e8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions GPU/GPUTracking/Base/GPUReconstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,15 @@ void* GPUReconstruction::AllocateVolatileDeviceMemory(size_t size)
return retVal;
}

void* GPUReconstruction::AllocateVolatileMemory(size_t size, bool device)
{
if (device) {
return AllocateVolatileDeviceMemory(size);
}
mVolatileChunks.emplace_back(new char[size + GPUCA_BUFFER_ALIGNMENT]);
return GPUProcessor::alignPointer<GPUCA_BUFFER_ALIGNMENT>(mVolatileChunks.back().get());
}

void GPUReconstruction::ResetRegisteredMemoryPointers(GPUProcessor* proc)
{
for (unsigned int i = 0; i < mMemoryResources.size(); i++) {
Expand Down Expand Up @@ -796,6 +805,12 @@ void GPUReconstruction::ReturnVolatileDeviceMemory()
}
}

void GPUReconstruction::ReturnVolatileMemory()
{
ReturnVolatileDeviceMemory();
mVolatileChunks.clear();
}

void GPUReconstruction::PushNonPersistentMemory(unsigned long tag)
{
mNonPersistentMemoryStack.emplace_back(mHostMemoryPoolEnd, mDeviceMemoryPoolEnd, mNonPersistentIndividualAllocations.size(), tag);
Expand Down
3 changes: 3 additions & 0 deletions GPU/GPUTracking/Base/GPUReconstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class GPUReconstruction
std::shared_ptr<LibraryLoader> mMyLib = nullptr;
std::vector<GPUMemoryResource> mMemoryResources;
std::vector<std::unique_ptr<char[]>> mUnmanagedChunks;
std::vector<std::unique_ptr<char[]>> mVolatileChunks;
std::vector<std::unique_ptr<GPUChain>> mChains;

public:
Expand Down Expand Up @@ -205,10 +206,12 @@ class GPUReconstruction
void AllocateRegisteredForeignMemory(short res, GPUReconstruction* rec, GPUOutputControl* control = nullptr);
void* AllocateUnmanagedMemory(size_t size, int type);
void* AllocateVolatileDeviceMemory(size_t size);
void* AllocateVolatileMemory(size_t size, bool device);
void FreeRegisteredMemory(GPUProcessor* proc, bool freeCustom = false, bool freePermanent = false);
void FreeRegisteredMemory(short res);
void ClearAllocatedMemory(bool clearOutputs = true);
void ReturnVolatileDeviceMemory();
void ReturnVolatileMemory();
void PushNonPersistentMemory(unsigned long tag);
void PopNonPersistentMemory(RecoStep step, unsigned long tag);
void BlockStackedMemory(GPUReconstruction* rec);
Expand Down
6 changes: 3 additions & 3 deletions GPU/GPUTracking/Global/GPUChainTrackingSliceTracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ int GPUChainTracking::RunTPCTrackingSlices_internal()
int streamOccMap = mRec->NStreams() - 1;
runKernel<GPUMemClean16>(GetGridAutoStep(streamOccMap, RecoStep::TPCSliceTracking), krnlRunRangeNone, {}, ptr, GPUTPCClusterOccupancyMapBin::getTotalSize(param()));
runKernel<GPUTPCCreateOccupancyMap, GPUTPCCreateOccupancyMap::fill>(GetGridBlk(GPUCA_NSLICES * GPUCA_ROW_COUNT, streamOccMap), krnlRunRangeNone, krnlEventNone, ptr);
runKernel<GPUTPCCreateOccupancyMap, GPUTPCCreateOccupancyMap::fold>(GetGridBlk(GPUCA_NSLICES * GPUCA_ROW_COUNT, streamOccMap), krnlRunRangeNone, {&mEvents->init}, ptr);
runKernel<GPUTPCCreateOccupancyMap, GPUTPCCreateOccupancyMap::fold>(GetGridBlk(GPUCA_NSLICES * GPUCA_ROW_COUNT, streamOccMap), krnlRunRangeNone, krnlEventNone, ptr);
if (doGPU) {
TransferMemoryResourceLinkToHost(RecoStep::TPCSliceTracking, mInputsHost->mResourceOccupancyMap);
TransferMemoryResourceLinkToHost(RecoStep::TPCSliceTracking, mInputsHost->mResourceOccupancyMap, streamOccMap, &mEvents->init);
} else {
TransferMemoryResourceLinkToGPU(RecoStep::TPCSliceTracking, mInputsHost->mResourceOccupancyMap);
TransferMemoryResourceLinkToGPU(RecoStep::TPCSliceTracking, mInputsHost->mResourceOccupancyMap, streamOccMap, &mEvents->init);
}
mRec->UpdateParamOccupancyMap(mInputsHost->mTPCClusterOccupancyMap, mInputsShadow->mTPCClusterOccupancyMap, streamOccMap);
}
Expand Down

0 comments on commit 6a28e8d

Please sign in to comment.