Skip to content

Commit 15455a9

Browse files
committed
Replace HcalMahiPulseOffsetsESProducer with MoveToDeviceCache
1 parent 4d85726 commit 15455a9

File tree

11 files changed

+49
-109
lines changed

11 files changed

+49
-109
lines changed

CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsHost.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

CondFormats/HcalObjects/interface/alpaka/HcalMahiPulseOffsetsDevice.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

CondFormats/HcalObjects/src/ES_HcalMahiPulseOffsetsHost.cc

Lines changed: 0 additions & 4 deletions
This file was deleted.

CondFormats/HcalObjects/src/alpaka/ES_HcalMahiPulseOffsetsDevice.cc

Lines changed: 0 additions & 4 deletions
This file was deleted.

HLTrigger/Configuration/python/customizeHLTforCMSSW.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ def customizeHLTfor47047(process):
144144
setattr(prod, attr, copy.deepcopy(getattr(esProducer, attr)))
145145
delattr(process, esProducer.label())
146146

147+
for prod in producers_by_type(process, "HBHERecHitProducerPortable@alpaka", "alpaka_serial_sync::HBHERecHitProducerPortable"):
148+
pulseOffsetLabel = prod.mahiPulseOffSets.getModuleLabel()
149+
if hasattr(process, pulseOffsetLabel):
150+
esProducer = getattr(process, pulseOffsetLabel)
151+
prod.pulseOffsets = copy.deepcopy(esProducer.pulseOffsets)
152+
del prod.mahiPulseOffSets
153+
for prod in list(esproducers_by_type(process, "HcalMahiPulseOffsetsESProducer@alpaka")):
154+
delattr(process, prod.label())
155+
147156
return process
148157

149158
# CMSSW version specific customizations

RecoLocalCalo/HcalRecProducers/plugins/alpaka/HBHERecHitProducerPortable.cc

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
#include "FWCore/Framework/interface/MakerMacros.h"
22
#include "FWCore/ParameterSet/interface/ParameterSet.h"
33

4+
#include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
5+
46
#include "CondFormats/DataRecord/interface/HcalSiPMCharacteristicsRcd.h"
57
#include "CondFormats/HcalObjects/interface/alpaka/HcalSiPMCharacteristicsDevice.h"
68
#include "CondFormats/DataRecord/interface/HcalMahiConditionsRcd.h"
79
#include "CondFormats/HcalObjects/interface/alpaka/HcalMahiConditionsDevice.h"
810
#include "CondFormats/DataRecord/interface/HcalRecoParamsRcd.h"
911
#include "CondFormats/HcalObjects/interface/alpaka/HcalRecoParamWithPulseShapeDevice.h"
10-
#include "CondFormats/HcalObjects/interface/alpaka/HcalMahiPulseOffsetsDevice.h"
1112

1213
#include "DataFormats/HcalDigi/interface/alpaka/HcalDigiDeviceCollection.h"
1314
#include "DataFormats/HcalRecHit/interface/alpaka/HcalRecHitDeviceCollection.h"
1415

1516
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
17+
#include "HeterogeneousCore/AlpakaCore/interface/MoveToDeviceCache.h"
1618
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/Event.h"
1719
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EventSetup.h"
1820
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDGetToken.h"
1921
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
2022
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/EDProducer.h"
2123
#include "HeterogeneousCore/CUDACore/interface/JobConfigurationGPURecord.h"
2224

25+
#include "HcalMahiPulseOffsetsSoA.h"
2326
#include "Mahi.h"
24-
#include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
2527

2628
namespace ALPAKA_ACCELERATOR_NAMESPACE {
29+
namespace {
30+
using HcalMahiPulseOffsetsCache =
31+
cms::alpakatools::MoveToDeviceCache<Device, PortableHostCollection<hcal::HcalMahiPulseOffsetsSoA>>;
32+
}
2733

28-
class HBHERecHitProducerPortable : public stream::EDProducer<> {
34+
class HBHERecHitProducerPortable : public stream::EDProducer<edm::GlobalCache<HcalMahiPulseOffsetsCache>> {
2935
public:
30-
explicit HBHERecHitProducerPortable(edm::ParameterSet const&);
36+
explicit HBHERecHitProducerPortable(edm::ParameterSet const&, HcalMahiPulseOffsetsCache const*);
3137
~HBHERecHitProducerPortable() override = default;
3238
static void fillDescriptions(edm::ConfigurationDescriptions&);
39+
static std::unique_ptr<HcalMahiPulseOffsetsCache> initializeGlobalCache(edm::ParameterSet const& ps);
40+
41+
static void globalEndJob(HcalMahiPulseOffsetsCache*) {}
3342

3443
private:
3544
void produce(device::Event&, device::EventSetup const&) override;
@@ -50,21 +59,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
5059
const device::ESGetToken<hcal::HcalSiPMCharacteristicsPortableDevice, HcalSiPMCharacteristicsRcd>
5160
sipmCharacteristicsToken_;
5261
const device::ESGetToken<hcal::HcalRecoParamWithPulseShapeDevice, HcalRecoParamsRcd> recoParamsToken_;
53-
const device::ESGetToken<hcal::HcalMahiPulseOffsetsPortableDevice, JobConfigurationGPURecord> mahiPulseOffsetsToken_;
5462
//
5563

5664
hcal::reconstruction::ConfigParameters configParameters_;
5765
};
5866

59-
HBHERecHitProducerPortable::HBHERecHitProducerPortable(edm::ParameterSet const& ps)
67+
HBHERecHitProducerPortable::HBHERecHitProducerPortable(edm::ParameterSet const& ps, HcalMahiPulseOffsetsCache const*)
6068
: digisTokenF01HE_{consumes(ps.getParameter<edm::InputTag>("digisLabelF01HE"))},
6169
digisTokenF5HB_{consumes(ps.getParameter<edm::InputTag>("digisLabelF5HB"))},
6270
digisTokenF3HB_{consumes(ps.getParameter<edm::InputTag>("digisLabelF3HB"))},
6371
rechitsM0Token_{produces()},
6472
mahiConditionsToken_{esConsumes()},
6573
sipmCharacteristicsToken_{esConsumes()},
66-
recoParamsToken_{esConsumes()},
67-
mahiPulseOffsetsToken_{esConsumes(ps.getParameter<edm::ESInputTag>("mahiPulseOffSets"))} {
74+
recoParamsToken_{esConsumes()} {
6875
configParameters_.maxTimeSamples = ps.getParameter<uint32_t>("maxTimeSamples");
6976
configParameters_.kprep1dChannelsPerBlock = ps.getParameter<uint32_t>("kprep1dChannelsPerBlock");
7077
configParameters_.sipmQTSShift = ps.getParameter<int>("sipmQTSShift");
@@ -95,7 +102,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
95102

96103
void HBHERecHitProducerPortable::fillDescriptions(edm::ConfigurationDescriptions& cdesc) {
97104
edm::ParameterSetDescription desc;
98-
desc.add<edm::ESInputTag>("mahiPulseOffSets", edm::ESInputTag(""));
99105
desc.add<uint32_t>("maxTimeSamples", 10);
100106
desc.add<uint32_t>("kprep1dChannelsPerBlock", 32);
101107
desc.add<edm::InputTag>("digisLabelF01HE", edm::InputTag{"hcalRawToDigiGPU", "f01HEDigisGPU"});
@@ -118,9 +124,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
118124
desc.add<std::vector<double>>("tmaxTimeSlewParameters", {16.00, 10.00, 6.25});
119125
desc.add<std::vector<uint32_t>>("kernelMinimizeThreads", {16, 1, 1});
120126

127+
desc.add<std::vector<int>>("pulseOffsets", {-3, -2, -1, 0, 1, 2, 3, 4});
128+
121129
cdesc.addWithDefaultLabel(desc);
122130
}
123131

132+
std::unique_ptr<HcalMahiPulseOffsetsCache> HBHERecHitProducerPortable::initializeGlobalCache(
133+
edm::ParameterSet const& ps) {
134+
std::vector<int> offsets = ps.getParameter<std::vector<int>>("pulseOffsets");
135+
136+
PortableHostCollection<hcal::HcalMahiPulseOffsetsSoA> obj(offsets.size(), cms::alpakatools::host());
137+
auto view = obj.view();
138+
139+
for (uint32_t i = 0; i < offsets.size(); i++) {
140+
view[i] = offsets[i];
141+
}
142+
143+
return std::make_unique<HcalMahiPulseOffsetsCache>(std::move(obj));
144+
}
145+
124146
void HBHERecHitProducerPortable::produce(device::Event& event, device::EventSetup const& setup) {
125147
auto& queue = event.queue();
126148

@@ -141,7 +163,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
141163
auto const& mahiConditionsDev = setup.getData(mahiConditionsToken_);
142164
auto const& sipmCharacteristicsDev = setup.getData(sipmCharacteristicsToken_);
143165
auto const& recoParamsWithPulseShapeDev = setup.getData(recoParamsToken_);
144-
auto const& mahiPulseOffsetsDev = setup.getData(mahiPulseOffsetsToken_);
166+
auto const& mahiPulseOffsetsDev = globalCache()->get(queue);
145167

146168
//
147169
// schedule algorithms

RecoLocalCalo/HcalRecProducers/plugins/alpaka/HcalMahiPulseOffsetsESProducer.cc

Lines changed: 0 additions & 44 deletions
This file was deleted.

CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsSoA.h renamed to RecoLocalCalo/HcalRecProducers/plugins/alpaka/HcalMahiPulseOffsetsSoA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef CondFormats_HcalObjects_HcalMahiPulseOffsetsSoA_h
2-
#define CondFormats_HcalObjects_HcalMahiPulseOffsetsSoA_h
1+
#ifndef RecoLocalCalo_HcalRecProducers_plugins_alpaka_HcalMahiPulseOffsetsSoA_h
2+
#define RecoLocalCalo_HcalRecProducers_plugins_alpaka_HcalMahiPulseOffsetsSoA_h
33

44
#include "DataFormats/SoATemplate/interface/SoACommon.h"
55
#include "DataFormats/SoATemplate/interface/SoALayout.h"

RecoLocalCalo/HcalRecProducers/plugins/alpaka/Mahi.dev.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
753753
float* pulseMatrices,
754754
float* pulseMatricesM,
755755
float* pulseMatricesP,
756-
HcalMahiPulseOffsetsPortableDevice::ConstView pulseOffsets,
756+
HcalMahiPulseOffsetsSoA::ConstView pulseOffsets,
757757
float const* amplitudes,
758758
IProductTypef01::ConstView f01HEDigis,
759759
IProductTypef5::ConstView f5HBDigis,
@@ -975,7 +975,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
975975
float* pulseMatrices,
976976
float* pulseMatricesM,
977977
float* pulseMatricesP,
978-
HcalMahiPulseOffsetsPortableDevice::ConstView pulseOffsetsView,
978+
HcalMahiPulseOffsetsSoA::ConstView pulseOffsetsView,
979979
float* noiseTerms,
980980
float* electronicNoiseTerms,
981981
int8_t* soiSamples,
@@ -1290,7 +1290,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
12901290
HcalMahiConditionsPortableDevice::ConstView const& mahi,
12911291
HcalSiPMCharacteristicsPortableDevice::ConstView const& sipmCharacteristics,
12921292
HcalRecoParamWithPulseShapeDevice::ConstView const& recoParamsWithPS,
1293-
HcalMahiPulseOffsetsPortableDevice::ConstView const& mahiPulseOffsets,
1293+
HcalMahiPulseOffsetsSoA::ConstView const& mahiPulseOffsets,
12941294
ConfigParameters const& configParameters) {
12951295
auto const totalChannels =
12961296
f01HEDigis.metadata().size() + f5HBDigis.metadata().size() + f3HBDigis.metadata().size();

RecoLocalCalo/HcalRecProducers/plugins/alpaka/Mahi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#include "CondFormats/HcalObjects/interface/alpaka/HcalMahiConditionsDevice.h"
1212
#include "CondFormats/HcalObjects/interface/alpaka/HcalSiPMCharacteristicsDevice.h"
1313
#include "CondFormats/HcalObjects/interface/alpaka/HcalRecoParamWithPulseShapeDevice.h"
14-
#include "CondFormats/HcalObjects/interface/alpaka/HcalMahiPulseOffsetsDevice.h"
14+
15+
#include "HcalMahiPulseOffsetsSoA.h"
1516

1617
namespace ALPAKA_ACCELERATOR_NAMESPACE::hcal::reconstruction {
1718

@@ -50,7 +51,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::hcal::reconstruction {
5051
HcalMahiConditionsPortableDevice::ConstView const& mahi,
5152
HcalSiPMCharacteristicsPortableDevice::ConstView const& sipmCharacteristics,
5253
HcalRecoParamWithPulseShapeDevice::ConstView const& recoParams,
53-
HcalMahiPulseOffsetsPortableDevice::ConstView const& mahiPulseOffsets,
54+
HcalMahiPulseOffsetsSoA::ConstView const& mahiPulseOffsets,
5455
ConfigParameters const& configParameters);
5556

5657
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::hcal::reconstruction

0 commit comments

Comments
 (0)