Skip to content

Commit 47d866b

Browse files
committed
Fixing host allocation
1 parent 0833ce8 commit 47d866b

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,8 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
944944
const bool buildNativeNNDirection = rec()->GetParam().rec.tpc.useNNClusterDirection && GetProcessingSettings().nn.applyNNclusterizer;
945945
const bool propagateMCLabels = buildNativeHost && GetProcessingSettings().runMC && processors()->ioPtrs.tpcPackedDigits && processors()->ioPtrs.tpcPackedDigits->tpcDigitsMC;
946946
const bool sortClusters = buildNativeHost && (GetProcessingSettings().deterministicGPUReconstruction || GetProcessingSettings().debugLevel >= 4);
947+
const bool buildNativeNNDirectionHost = buildNativeNNDirection && (!buildNativeGPU || sortClusters);
948+
bool buildNativeNNDirectionGPU = buildNativeNNDirection;
947949

948950
if (GetProcessingSettings().runMC && (!processors()->ioPtrs.tpcPackedDigits || !processors()->ioPtrs.tpcPackedDigits->tpcDigitsMC)) {
949951
GPUWarning("Requested to process MC labels, but no labels present");
@@ -968,14 +970,14 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
968970
if (!GetProcessingSettings().tpcApplyClusterFilterOnCPU) {
969971
AllocateRegisteredMemory(mInputsHost->mResourceClusterNativeOutput, GetProcessingSettings().tpcWriteClustersAfterRejection ? nullptr : mSubOutputControls[GPUTrackingOutputs::getIndex(&GPUTrackingOutputs::clustersNative)]);
970972
tmpNativeClusters = mInputsHost->mPclusterNativeOutput;
971-
if (buildNativeNNDirection) {
973+
if (buildNativeNNDirectionHost) {
972974
AllocateRegisteredMemory(mInputsHost->mResourceClusterNativeNNDirectionOutput);
973975
tmpNativeNNDirections = mInputsHost->mPclusterNativeNNDirectionOutput;
974976
}
975977
} else {
976978
tmpNativeClusterBuffer = std::make_unique<ClusterNative[]>(mInputsHost->mNClusterNative);
977979
tmpNativeClusters = tmpNativeClusterBuffer.get();
978-
if (buildNativeNNDirection) {
980+
if (buildNativeNNDirectionHost) {
979981
tmpNativeNNDirectionBuffer = std::make_unique<ClusterNativeNNDirection[]>(mInputsHost->mNClusterNative);
980982
tmpNativeNNDirections = tmpNativeNNDirectionBuffer.get();
981983
}
@@ -1460,7 +1462,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
14601462
}
14611463
} else if (buildNativeHost) {
14621464
GPUMemCpyAlways(RecoStep::TPCClusterFinding, (void*)&tmpNativeClusters[nClsTotal], (const void*)&clustererShadow.mPclusterByRow[j * clusterer.mNMaxClusterPerRow], sizeof(mIOPtrs.clustersNative->clustersLinear[0]) * clusterer.mPclusterInRow[j], mRec->NStreams() - 1, false);
1463-
if (buildNativeNNDirection && clustererShadow.mPclusterNNDirectionByRow != nullptr) {
1465+
if (buildNativeNNDirectionHost && clustererShadow.mPclusterNNDirectionByRow != nullptr) {
14641466
GPUMemCpyAlways(RecoStep::TPCClusterFinding, (void*)&tmpNativeNNDirections[nClsTotal], (const void*)&clustererShadow.mPclusterNNDirectionByRow[j * clusterer.mNMaxClusterPerRow], sizeof(tmpNativeNNDirections[0]) * clusterer.mPclusterInRow[j], mRec->NStreams() - 1, false);
14651467
}
14661468
}
@@ -1491,7 +1493,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
14911493
mOutputQueue.emplace_back(outputQueueEntry{(void*)((char*)&tmpNativeClusters[nClsFirst] - (char*)&tmpNativeClusters[0]), &mInputsShadow->mPclusterNativeBuffer[nClsFirst], (nClsTotal - nClsFirst) * sizeof(tmpNativeClusters[0]), RecoStep::TPCClusterFinding});
14921494
} else {
14931495
GPUMemCpy(RecoStep::TPCClusterFinding, (void*)&tmpNativeClusters[nClsFirst], (const void*)&mInputsShadow->mPclusterNativeBuffer[nClsFirst], (nClsTotal - nClsFirst) * sizeof(tmpNativeClusters[0]), mRec->NStreams() - 1, false);
1494-
if (buildNativeNNDirection) {
1496+
if (buildNativeNNDirectionHost) {
14951497
GPUMemCpy(RecoStep::TPCClusterFinding, (void*)&tmpNativeNNDirections[nClsFirst], (const void*)&mInputsShadow->mPclusterNativeNNDirectionBuffer[nClsFirst], (nClsTotal - nClsFirst) * sizeof(tmpNativeNNDirections[0]), mRec->NStreams() - 1, false);
14961498
}
14971499
}
@@ -1567,7 +1569,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
15671569
mInputsHost->mNClusterNative = mInputsShadow->mNClusterNative = nClsTotal;
15681570
AllocateRegisteredMemory(mInputsHost->mResourceClusterNativeOutput, GetProcessingSettings().tpcWriteClustersAfterRejection ? nullptr : mSubOutputControls[GPUTrackingOutputs::getIndex(&GPUTrackingOutputs::clustersNative)]);
15691571
tmpNativeClusters = mInputsHost->mPclusterNativeOutput;
1570-
if (buildNativeNNDirection) {
1572+
if (buildNativeNNDirectionHost) {
15711573
AllocateRegisteredMemory(mInputsHost->mResourceClusterNativeNNDirectionOutput);
15721574
tmpNativeNNDirections = mInputsHost->mPclusterNativeNNDirectionOutput;
15731575
GPUMemCpy(RecoStep::TPCClusterFinding, (void*)tmpNativeNNDirections, (const void*)mInputsShadow->mPclusterNativeNNDirectionBuffer, nClsTotal * sizeof(tmpNativeNNDirections[0]), mRec->NStreams() - 1, false);
@@ -1579,7 +1581,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
15791581

15801582
if (buildNativeHost) {
15811583
tmpNativeAccess->clustersLinear = tmpNativeClusters;
1582-
tmpNativeAccess->clustersLinearNNDirection = buildNativeNNDirection ? tmpNativeNNDirections : nullptr;
1584+
tmpNativeAccess->clustersLinearNNDirection = tmpNativeNNDirections;
15831585
tmpNativeAccess->clustersMCTruth = mcLabelsConstView;
15841586
tmpNativeAccess->setOffsetPtrs();
15851587
mIOPtrs.clustersNative = tmpNativeAccess;
@@ -1593,6 +1595,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
15931595
nClsTotal = tmpNativeAccess->nClustersTotal;
15941596
tmpNativeAccess->clustersLinearNNDirection = nullptr;
15951597
tmpNativeNNDirections = nullptr;
1598+
buildNativeNNDirectionGPU = false;
15961599
}
15971600
}
15981601

@@ -1605,7 +1608,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
16051608
WriteToConstantMemory(RecoStep::TPCClusterFinding, (char*)&processors()->ioPtrs - (char*)processors(), &processorsShadow()->ioPtrs, sizeof(processorsShadow()->ioPtrs), 0);
16061609
*mInputsHost->mPclusterNativeAccess = *mIOPtrs.clustersNative;
16071610
mInputsHost->mPclusterNativeAccess->clustersLinear = mInputsShadow->mPclusterNativeBuffer;
1608-
mInputsHost->mPclusterNativeAccess->clustersLinearNNDirection = mIOPtrs.clustersNative->clustersLinearNNDirection ? mInputsShadow->mPclusterNativeNNDirectionBuffer : nullptr;
1611+
mInputsHost->mPclusterNativeAccess->clustersLinearNNDirection = buildNativeNNDirectionGPU ? mInputsShadow->mPclusterNativeNNDirectionBuffer : nullptr;
16091612
mInputsHost->mPclusterNativeAccess->setOffsetPtrs();
16101613
TransferMemoryResourceLinkToGPU(RecoStep::TPCClusterFinding, mInputsHost->mResourceClusterNativeAccess, 0);
16111614
}

0 commit comments

Comments
 (0)