Skip to content

Commit deb0a78

Browse files
davidrohrMichaelLettrich
authored andcommitted
GPU: Add option to force size of GPU / Host memory pool
1 parent a9435f7 commit deb0a78

7 files changed

Lines changed: 17 additions & 11 deletions

File tree

GPU/GPUTracking/Base/GPUReconstruction.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,18 @@ int GPUReconstruction::Init()
120120
mDeviceProcessingSettings.nThreads = 1;
121121
#endif
122122

123+
mDeviceMemorySize = mHostMemorySize = 0;
123124
for (unsigned int i = 0; i < mChains.size(); i++) {
124125
mChains[i]->RegisterPermanentMemoryAndProcessors();
126+
size_t memGpu, memHost;
127+
mChains[i]->MemorySize(memGpu, memHost);
128+
mDeviceMemorySize += memGpu;
129+
mHostMemorySize += memHost;
125130
}
131+
if (mDeviceProcessingSettings.forceMemoryPoolSize) {
132+
mDeviceMemorySize = mHostMemorySize = mDeviceProcessingSettings.forceMemoryPoolSize;
133+
}
134+
126135
for (unsigned int i = 0; i < mProcessors.size(); i++) {
127136
(mProcessors[i].proc->*(mProcessors[i].RegisterMemoryAllocation))();
128137
}

GPU/GPUTracking/Base/GPUReconstructionCPU.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ int GPUReconstructionCPU::GetThread()
113113
int GPUReconstructionCPU::InitDevice()
114114
{
115115
if (mDeviceProcessingSettings.memoryAllocationStrategy == GPUMemoryResource::ALLOCATION_GLOBAL) {
116-
mHostMemoryPermanent = mHostMemoryBase = operator new(GPUCA_HOST_MEMORY_SIZE);
117-
mHostMemorySize = GPUCA_HOST_MEMORY_SIZE;
116+
if (mDeviceMemorySize > mHostMemorySize) {
117+
mHostMemorySize = mDeviceMemorySize;
118+
}
119+
mHostMemoryPermanent = mHostMemoryBase = operator new(mHostMemorySize);
118120
ClearAllocatedMemory();
119121
}
120122
SetThreadCounts();

GPU/GPUTracking/Base/GPUReconstructionDeviceBase.cxx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,6 @@ int GPUReconstructionDeviceBase::InitDevice()
242242
return (1);
243243
}
244244

245-
mDeviceMemorySize = 0;
246-
mHostMemorySize = 0;
247-
for (unsigned int i = 0; i < mChains.size(); i++) {
248-
size_t memGpu, memHost;
249-
mChains[i]->MemorySize(memGpu, memHost);
250-
mDeviceMemorySize += memGpu;
251-
mHostMemorySize += memHost;
252-
}
253-
254245
int retVal = InitDevice_Runtime();
255246
if (retVal) {
256247
GPUImportant("GPU Tracker initialization failed");

GPU/GPUTracking/Base/GPUSettings.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ void GPUSettingsDeviceProcessing::SetDefaults()
7979
nStreams = 8;
8080
trackletConstructorInPipeline = true;
8181
trackletSelectorInPipeline = false;
82+
forceMemoryPoolSize = 0;
8283
}

GPU/GPUTracking/Base/GPUSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct GPUSettingsDeviceProcessing {
134134
int nStreams; // Number of parallel GPU streams
135135
bool trackletConstructorInPipeline; // Run tracklet constructor in pileline like the preceeding tasks instead of as one big block
136136
bool trackletSelectorInPipeline; // Run tracklet selector in pipeline, requres also tracklet constructor in pipeline
137+
size_t forceMemoryPoolSize; // Override size of memory pool to be allocated on GPU / Host
137138
};
138139
} // namespace gpu
139140
} // namespace GPUCA_NAMESPACE

GPU/GPUTracking/Standalone/qconfigoptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ AddOptionSet(nways, int, 1, "1Way", 0, "Use 3-way track-fit")
129129
AddOption(nwaysouter, bool, false, "OuterParam", 0, "Create OuterParam")
130130
AddOption(dzdr, float, 2.5f, "DzDr", 0, "Use dZ/dR search window instead of vertex window")
131131
AddOption(cont, bool, false, "continuous", 0, "Process continuous timeframe data")
132+
AddOption(forceMemorySize, unsigned long long int, 0, "forceMemorySize", 0, "Force size of allocated GPU / page locked host memory", min(0ull))
132133
AddOption(outputcontrolmem, unsigned long long int, 0, "outputMemory", 0, "Use predefined output buffer of this size", min(0ull), message("Using %lld bytes as output memory"))
133134
AddOption(affinity, int, -1, "cpuAffinity", 0, "Pin CPU affinity to this CPU core", min(-1), message("Setting affinity to restrict on CPU %d"))
134135
AddOption(fifo, bool, false, "fifoScheduler", 0, "Use FIFO realtime scheduler", message("Setting FIFO scheduler: %s"))

GPU/GPUTracking/Standalone/standalone.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ int SetupReconstruction()
285285
devProc.nThreads = configStandalone.OMPThreads;
286286
}
287287
devProc.deviceNum = configStandalone.cudaDevice;
288+
devProc.forceMemoryPoolSize = configStandalone.forceMemorySize;
288289
devProc.debugLevel = configStandalone.DebugLevel;
289290
devProc.runQA = configStandalone.qa;
290291
devProc.runCompressionStatistics = configStandalone.compressionStat;

0 commit comments

Comments
 (0)