Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for ECAL rechits on GPU #475

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e12ea51
raw to digi is adapted to 110x patatrack branch
vkhristenko Mar 30, 2020
dd8cd82
adding validation source
vkhristenko Mar 30, 2020
0d118e1
cuda data formats ecal rechit fixes for 110x
vkhristenko Mar 30, 2020
894d06a
ecal reco algos adapted for 110x
vkhristenko Mar 30, 2020
1fea2b7
ecal reco producers adapted for 111x
vkhristenko Mar 30, 2020
6e0f630
make sure proper types are deduced for cuda copies
vkhristenko Apr 1, 2020
0e946cc
add ratio plot
vkhristenko Apr 1, 2020
b21427c
Clean up ECAL unapcker code
fwyzard Apr 3, 2020
d5f1117
first commit
amassiro Apr 6, 2020
2a58303
Merged ecal_unpacker_patatrack_110x from repository vkhristenko with …
amassiro Apr 6, 2020
e3b89a0
Merged amassiro-ecal-rechit-11_1_0 from repository amassiro with cms-…
amassiro Apr 8, 2020
5d1dc2f
Merged patatrack-ECAL_unpacker_cleanup from repository fwyzard with c…
amassiro Apr 9, 2020
de95016
minor fix
amassiro Apr 10, 2020
ee0c5ea
tests ongoing
amassiro Apr 21, 2020
ba98200
last file missing
amassiro Apr 21, 2020
e1268b1
update to make it work
amassiro May 13, 2020
32b56f6
missing files
amassiro May 13, 2020
e8b2602
Merged amassiro-ecal-rechit-11_1_0-PR-2 from repository amassiro with…
amassiro May 14, 2020
f159c29
fixes as for PR and clang-tidy
amassiro May 15, 2020
e2f7e8a
further changes from PR comments
amassiro May 18, 2020
1cb2afa
after running clang tidy
amassiro May 18, 2020
bf27284
Merged amassiro-ecal-rechit-11_1_0-PR-3 from repository amassiro with…
amassiro May 27, 2020
55c10ec
change from CUDAHostAllocator to HostAllocator
amassiro May 27, 2020
5dd85ff
remove message logger not needed
amassiro May 29, 2020
34f8084
suggestions from PR implemented
amassiro Jun 4, 2020
02c4d10
add cuda protection
amassiro Jun 4, 2020
aed8400
Update sequences for ECAL local reconstruction running on GPU
fwyzard Jun 5, 2020
92afb3e
Reconstruct ECAL rechits on GPUs
fwyzard Jun 5, 2020
f803a1c
Merged patatrack_update_ECAL_GPU_workflows from repository cms-patatr…
amassiro Jun 8, 2020
e94bc01
fixes of the previous PR after central validation
amassiro Jun 8, 2020
907a3bb
ops, a cout slipped through
amassiro Jun 8, 2020
ff30a39
Remove extra whitespace
fwyzard Jun 8, 2020
134ab3a
Move skip_this_channel inside the if block
fwyzard Jun 8, 2020
a6a074f
Avoid some repeated assignments
fwyzard Jun 8, 2020
9da15f2
Silence warning about unused variable
fwyzard Jun 10, 2020
dacaf2e
Set flagBits for all channels
fwyzard Jun 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions EventFilter/EcalRawToDigi/python/ecalDigis_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

# copy the digi from the GPU to the CPU and convert to legacy format
from EventFilter.EcalRawToDigi.ecalCPUDigisProducer_cfi import ecalCPUDigisProducer as _ecalCPUDigisProducer
_gpu_ecalDigis = _ecalCPUDigisProducer.clone(
digisInLabelEB = 'ecalDigisGPU:ebDigisGPU',
digisInLabelEE = 'ecalDigisGPU:eeDigisGPU',
produceDummyIntegrityCollections = True,
_ecalDigis_gpu = _ecalCPUDigisProducer.clone(
digisInLabelEB = cms.InputTag('ecalDigisGPU', 'ebDigisGPU'),
digisInLabelEE = cms.InputTag('ecalDigisGPU', 'eeDigisGPU'),
produceDummyIntegrityCollections = True
)
gpu.toReplaceWith(ecalDigis, _gpu_ecalDigis)
gpu.toReplaceWith(ecalDigis, _ecalDigis_gpu)

gpu.toReplaceWith(ecalDigisTask, cms.Task(ecalElectronicsMappingGPUESProducer, ecalDigisGPU, ecalDigis))
52 changes: 52 additions & 0 deletions RecoLocalCalo/Configuration/python/ecalLocalRecoSequence_cff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FWCore.ParameterSet.Config as cms
from Configuration.ProcessModifiers.gpu_cff import gpu

# TPG condition needed by ecalRecHit producer if TT recovery is ON
from RecoLocalCalo.EcalRecProducers.ecalRecHitTPGConditions_cff import *
Expand Down Expand Up @@ -43,6 +44,57 @@

ecalOnlyLocalRecoSequence = cms.Sequence(ecalOnlyLocalRecoTask)

# ECAL rechit calibrations on GPU
from RecoLocalCalo.EcalRecProducers.ecalRechitADCToGeVConstantGPUESProducer_cfi import ecalRechitADCToGeVConstantGPUESProducer
from RecoLocalCalo.EcalRecProducers.ecalRechitChannelStatusGPUESProducer_cfi import ecalRechitChannelStatusGPUESProducer
from RecoLocalCalo.EcalRecProducers.ecalIntercalibConstantsGPUESProducer_cfi import ecalIntercalibConstantsGPUESProducer
from RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosGPUESProducer_cfi import ecalLaserAPDPNRatiosGPUESProducer
from RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosRefGPUESProducer_cfi import ecalLaserAPDPNRatiosRefGPUESProducer
from RecoLocalCalo.EcalRecProducers.ecalLaserAlphasGPUESProducer_cfi import ecalLaserAlphasGPUESProducer
from RecoLocalCalo.EcalRecProducers.ecalLinearCorrectionsGPUESProducer_cfi import ecalLinearCorrectionsGPUESProducer

# ECAL rechits running on GPU
from RecoLocalCalo.EcalRecProducers.ecalRecHitGPU_cfi import ecalRecHitGPU as _ecalRecHitGPU
ecalRecHitGPU = _ecalRecHitGPU.clone(
uncalibrecHitsInLabelEB = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEB'),
uncalibrecHitsInLabelEE = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEE')
)

# copy the rechits from GPU to CPU
from RecoLocalCalo.EcalRecProducers.ecalCPURecHitProducer_cfi import ecalCPURecHitProducer as _ecalCPURecHitProducer
ecalRecHitSoA = _ecalCPURecHitProducer.clone(
recHitsInLabelEB = cms.InputTag('ecalRecHitGPU', 'EcalRecHitsEB'),
recHitsInLabelEE = cms.InputTag('ecalRecHitGPU', 'EcalRecHitsEE')
)

# convert the rechits from SoA to legacy format
from RecoLocalCalo.EcalRecProducers.ecalRecHitConvertGPU2CPUFormat_cfi import ecalRecHitConvertGPU2CPUFormat as _ecalRecHitConvertGPU2CPUFormat
_ecalRecHit_gpu = _ecalRecHitConvertGPU2CPUFormat.clone(
recHitsLabelGPUEB = cms.InputTag('ecalRecHitSoA', 'EcalRecHitsEB'),
recHitsLabelGPUEE = cms.InputTag('ecalRecHitSoA', 'EcalRecHitsEE')
)
gpu.toReplaceWith(ecalRecHit, _ecalRecHit_gpu)

# ECAL reconstruction on GPU
gpu.toReplaceWith(ecalRecHitNoTPTask, cms.Task(
# ECAL rechit calibrations on GPU
ecalRechitADCToGeVConstantGPUESProducer,
ecalRechitChannelStatusGPUESProducer,
ecalIntercalibConstantsGPUESProducer,
ecalLaserAPDPNRatiosGPUESProducer,
ecalLaserAPDPNRatiosRefGPUESProducer,
ecalLaserAlphasGPUESProducer,
ecalLinearCorrectionsGPUESProducer,
# ECAL rechits running on GPU
ecalRecHitGPU,
# copy the rechits from GPU to CPU
ecalRecHitSoA,
# convert the rechits from SoA to legacy format
ecalRecHit,
# ECAL preshower rechit legacy module
ecalPreshowerRecHit
))

# Phase 2 modifications
from RecoLocalCalo.EcalRecProducers.ecalDetailedTimeRecHit_cfi import *
_phase2_timing_ecalRecHitTask = cms.Task( ecalRecHitTask.copy() , ecalDetailedTimeRecHit )
Expand Down
4 changes: 4 additions & 0 deletions RecoLocalCalo/EcalRecAlgos/src/EcalLinearCorrectionsGPU.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ EcalLinearCorrectionsGPU::Product::~Product() {
// deallocation
cudaCheck(cudaFree(p1));
cudaCheck(cudaFree(p2));
cudaCheck(cudaFree(p3));
cudaCheck(cudaFree(t1));
cudaCheck(cudaFree(t2));
cudaCheck(cudaFree(t3));
}

EcalLinearCorrectionsGPU::Product const& EcalLinearCorrectionsGPU::getProduct(cudaStream_t cudaStream) const {
Expand Down
37 changes: 23 additions & 14 deletions RecoLocalCalo/EcalRecAlgos/src/EcalRecHitBuilderKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace ecal {

::ecal::reco::StorageScalarType const* amplitude = isEndcap ? amplitude_ee : amplitude_eb;

::ecal::reco::StorageScalarType const* time_in = isEndcap ? time_ee : time_eb;
//::ecal::reco::StorageScalarType const* time_in = isEndcap ? time_ee : time_eb;

::ecal::reco::StorageScalarType const* chi2_in = isEndcap ? chi2_ee : chi2_eb;

Expand Down Expand Up @@ -287,16 +287,31 @@ namespace ecal {
//
energy[ch] = -1; //---- AM: default, un-physical, ok

//
static const int chStatusMask = 0x1F;
// truncate the chi2
if (chi2_in[inputCh] > 64)
chi2[ch] = 64;
else
chi2[ch] = chi2_in[inputCh];

// default values for the flags
flagBits[ch] = 0;
extra[ch] = 0;

static const int chStatusMask = 0x1f;
// ChannelStatusToBeExcluded is a "int" then I put "dbstatus" to be the same
int dbstatus = EcalChannelStatusCode_Code((status[hashedId]) & chStatusMask);
if (ChannelStatusToBeExcludedSize != 0) {
bool skip_this_channel = false;
for (int ich_to_check = 0; ich_to_check < ChannelStatusToBeExcludedSize; ich_to_check++) {
if (ChannelStatusToBeExcluded[ich_to_check] == dbstatus) {
return;
skip_this_channel = true;
break;
}
}
if (skip_this_channel) {
// skip this channel
continue;
}
}

// Take our association map of dbstatuses-> recHit flagbits and return the apporpriate flagbit word
Expand Down Expand Up @@ -335,13 +350,13 @@ namespace ecal {
flagbit_counter += 1;
}

flagBits[ch] = temporary_flagBits;

if ((flagmask & temporary_flagBits) && killDeadChannels) {
return;
// skip this channel
continue;
}

//
flagBits[ch] = temporary_flagBits;

//
// multiply the adc counts with factors to get GeV
//
Expand All @@ -352,13 +367,7 @@ namespace ecal {
// Time is not saved so far, FIXME
// time[ch] = time_in[inputCh];

if (chi2_in[inputCh] > 64)
chi2[ch] = 64;
else
chi2[ch] = chi2_in[inputCh];

// NB: calculate the "flagBits extra" --> not really "flags", but actually an encoded version of energy uncertainty, time unc., ...
extra[ch] = 0;

//
// extra packing ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"

//
//
//

// format
#include "CUDADataFormats/EcalRecHitSoA/interface/EcalUncalibratedRecHit_soa.h"
#include "CUDADataFormats/EcalRecHitSoA/interface/EcalRecHit_soa.h"
Expand Down Expand Up @@ -302,7 +298,7 @@ void EcalRecHitProducerGPU::acquire(edm::Event const& event,

neb_ = ebUncalibRecHits.size;
nee_ = eeUncalibRecHits.size;
// std::cout << " [EcalRecHitProducerGPU::acquire] neb_:nee_ = " << neb_ << " : " << nee_ << std::endl;
// std::cout << " [EcalRecHitProducerGPU::acquire] neb_:nee_ = " << neb_ << " : " << nee_ << std::endl;

int nchannelsEB = ebUncalibRecHits.size; // --> offsetForInput, first EB and then EE

Expand All @@ -321,8 +317,6 @@ void EcalRecHitProducerGPU::acquire(edm::Event const& event,
setup.get<EcalLaserAlphasRcd>().get(LaserAlphasHandle_);
setup.get<EcalLinearCorrectionsRcd>().get(LinearCorrectionsHandle_);

//

auto const& ADCToGeVConstantProduct = ADCToGeVConstantHandle_->getProduct(ctx.stream());
auto const& IntercalibConstantsProduct = IntercalibConstantsHandle_->getProduct(ctx.stream());
auto const& ChannelStatusProduct = ChannelStatusHandle_->getProduct(ctx.stream());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@
recHitsInLabelEE = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEE'),
)

# convert the uncalibrated rechits legacy format
# convert the uncalibrated rechits from SoA to legacy format
from RecoLocalCalo.EcalRecProducers.ecalUncalibRecHitConvertGPU2CPUFormat_cfi import ecalUncalibRecHitConvertGPU2CPUFormat as _ecalUncalibRecHitConvertGPU2CPUFormat
_gpu_ecalMultiFitUncalibRecHit = _ecalUncalibRecHitConvertGPU2CPUFormat.clone(
_ecalMultiFitUncalibRecHit_gpu = _ecalUncalibRecHitConvertGPU2CPUFormat.clone(
recHitsLabelGPUEB = cms.InputTag('ecalMultiFitUncalibRecHitSoA', 'EcalUncalibRecHitsEB'),
recHitsLabelGPUEE = cms.InputTag('ecalMultiFitUncalibRecHitSoA', 'EcalUncalibRecHitsEE'),
)
gpu.toReplaceWith(ecalMultiFitUncalibRecHit, _gpu_ecalMultiFitUncalibRecHit)
gpu.toReplaceWith(ecalMultiFitUncalibRecHit, _ecalMultiFitUncalibRecHit_gpu)

gpu.toReplaceWith(ecalMultiFitUncalibRecHitTask, cms.Task(ecalMultiFitUncalibRecHitGPU, ecalMultiFitUncalibRecHitSoA, ecalMultiFitUncalibRecHit))
gpu.toReplaceWith(ecalMultiFitUncalibRecHitTask, cms.Task(
# ECAL conditions used by the multifit running on GPU
ecalPedestalsGPUESProducer,
ecalGainRatiosGPUESProducer,
ecalPulseShapesGPUESProducer,
ecalPulseCovariancesGPUESProducer,
ecalSamplesCorrelationGPUESProducer,
ecalTimeBiasCorrectionsGPUESProducer,
ecalTimeCalibConstantsGPUESProducer,
# ECAL multifit running on GP
ecalMultiFitUncalibRecHitGPU,
# copy the uncalibrated rechits from GPU to CPU
ecalMultiFitUncalibRecHitSoA,
# convert the uncalibrated rechits legacy format
ecalMultiFitUncalibRecHit,
))