Skip to content

Commit f0cd8b9

Browse files
authored
Merge pull request #44910 from kakwok/Mahi-alpaka_14_1_0_pre3
Alpaka implementation of Hcal Local Reconstruction (Mahi)
2 parents 422db62 + 19dde9c commit f0cd8b9

File tree

55 files changed

+3595
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3595
-6
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef CondFormats_DataRecord_HcalMahiConditionsRcd_h
2+
#define CondFormats_DataRecord_HcalMahiConditionsRcd_h
3+
4+
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
5+
6+
#include "CondFormats/DataRecord/interface/HcalRecoParamsRcd.h"
7+
#include "CondFormats/DataRecord/interface/HcalPedestalsRcd.h"
8+
#include "CondFormats/DataRecord/interface/HcalGainsRcd.h"
9+
#include "CondFormats/DataRecord/interface/HcalLUTCorrsRcd.h"
10+
#include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
11+
#include "CondFormats/DataRecord/interface/HcalTimeCorrsRcd.h"
12+
#include "CondFormats/DataRecord/interface/HcalPedestalWidthsRcd.h"
13+
#include "CondFormats/DataRecord/interface/HcalGainWidthsRcd.h"
14+
#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
15+
#include "CondFormats/DataRecord/interface/HcalQIETypesRcd.h"
16+
#include "CondFormats/DataRecord/interface/HcalQIEDataRcd.h"
17+
#include "CondFormats/DataRecord/interface/HcalSiPMParametersRcd.h"
18+
#include "Geometry/Records/interface/HcalRecNumberingRecord.h"
19+
20+
class HcalMahiConditionsRcd
21+
: public edm::eventsetup::DependentRecordImplementation<HcalMahiConditionsRcd,
22+
edm::mpl::Vector<HcalRecoParamsRcd,
23+
HcalPedestalsRcd,
24+
HcalGainsRcd,
25+
HcalLUTCorrsRcd,
26+
HcalRespCorrsRcd,
27+
HcalTimeCorrsRcd,
28+
HcalPedestalWidthsRcd,
29+
HcalGainWidthsRcd,
30+
HcalChannelQualityRcd,
31+
HcalQIETypesRcd,
32+
HcalQIEDataRcd,
33+
HcalSiPMParametersRcd,
34+
HcalRecNumberingRecord>> {};
35+
#endif
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "CondFormats/DataRecord/interface/HcalMahiConditionsRcd.h"
2+
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
3+
4+
EVENTSETUP_RECORD_REG(HcalMahiConditionsRcd);

CondFormats/HcalObjects/BuildFile.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
</ifrelease>
44
<use name="boost_serialization"/>
55
<use name="CondFormats/Serialization"/>
6+
<use name="DataFormats/Portable"/>
67
<use name="DataFormats/DetId"/>
78
<use name="DataFormats/HcalDetId"/>
9+
<use name="DataFormats/SoATemplate"/>
810
<use name="FWCore/MessageLogger"/>
911
<use name="FWCore/Utilities"/>
1012
<use name="Geometry/CaloTopology"/>
1113
<use name="HeterogeneousCore/CUDACore"/>
1214
<use name="HeterogeneousCore/CUDAUtilities"/>
15+
<use name="HeterogeneousCore/AlpakaCore"/>
16+
<use name="HeterogeneousCore/AlpakaInterface"/>
17+
<flags ALPAKA_BACKENDS="1"/>
1318
<export>
1419
<lib name="1"/>
1520
</export>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef CondFormats_HcalObjects_interface_HcalMahiConditionsHost_h
2+
#define CondFormats_HcalObjects_interface_HcalMahiConditionsHost_h
3+
4+
#include "CondFormats/HcalObjects/interface/HcalMahiConditionsSoA.h"
5+
#include "DataFormats/Portable/interface/PortableHostCollection.h"
6+
7+
namespace hcal {
8+
using HcalMahiConditionsPortableHost = PortableHostCollection<HcalMahiConditionsSoA>;
9+
}
10+
11+
#endif
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef CondFormats_HcalObjects_HcalMahiConditionsSoA_h
2+
#define CondFormats_HcalObjects_HcalMahiConditionsSoA_h
3+
4+
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalConstants.h"
5+
6+
#include "DataFormats/SoATemplate/interface/SoACommon.h"
7+
#include "DataFormats/SoATemplate/interface/SoALayout.h"
8+
#include "DataFormats/SoATemplate/interface/SoAView.h"
9+
10+
#include <array>
11+
12+
namespace hcal {
13+
14+
static constexpr uint32_t numValuesPerChannel = 16;
15+
using HcalPedestalArray = std::array<float, 4>; // 4 capIds
16+
using HcalQIECodersArray = std::array<float, numValuesPerChannel>; // QIEData
17+
18+
GENERATE_SOA_LAYOUT(HcalMahiConditionsSoALayout,
19+
SOA_COLUMN(HcalPedestalArray, pedestals_value),
20+
SOA_COLUMN(HcalPedestalArray, pedestals_width),
21+
SOA_COLUMN(HcalPedestalArray, gains_value),
22+
SOA_COLUMN(HcalPedestalArray, effectivePedestals),
23+
SOA_COLUMN(HcalPedestalArray, effectivePedestalWidths),
24+
SOA_COLUMN(float, lutCorrs_values),
25+
SOA_COLUMN(float, respCorrs_values),
26+
SOA_COLUMN(float, timeCorrs_values),
27+
// Use EIGEN_COLUMN for matrix?
28+
SOA_COLUMN(float, pedestalWidths_sigma00),
29+
SOA_COLUMN(float, pedestalWidths_sigma01),
30+
SOA_COLUMN(float, pedestalWidths_sigma02),
31+
SOA_COLUMN(float, pedestalWidths_sigma03),
32+
SOA_COLUMN(float, pedestalWidths_sigma10),
33+
SOA_COLUMN(float, pedestalWidths_sigma11),
34+
SOA_COLUMN(float, pedestalWidths_sigma12),
35+
SOA_COLUMN(float, pedestalWidths_sigma13),
36+
SOA_COLUMN(float, pedestalWidths_sigma20),
37+
SOA_COLUMN(float, pedestalWidths_sigma21),
38+
SOA_COLUMN(float, pedestalWidths_sigma22),
39+
SOA_COLUMN(float, pedestalWidths_sigma23),
40+
SOA_COLUMN(float, pedestalWidths_sigma30),
41+
SOA_COLUMN(float, pedestalWidths_sigma31),
42+
SOA_COLUMN(float, pedestalWidths_sigma32),
43+
SOA_COLUMN(float, pedestalWidths_sigma33),
44+
SOA_COLUMN(float, gainWidths_value0),
45+
SOA_COLUMN(float, gainWidths_value1),
46+
SOA_COLUMN(float, gainWidths_value2),
47+
SOA_COLUMN(float, gainWidths_value3),
48+
SOA_COLUMN(uint32_t, channelQuality_status),
49+
SOA_COLUMN(HcalQIECodersArray, qieCoders_offsets),
50+
SOA_COLUMN(HcalQIECodersArray, qieCoders_slopes),
51+
SOA_COLUMN(int, qieTypes_values),
52+
SOA_COLUMN(int, sipmPar_type),
53+
SOA_COLUMN(int, sipmPar_auxi1),
54+
SOA_COLUMN(float, sipmPar_fcByPE),
55+
SOA_COLUMN(float, sipmPar_darkCurrent),
56+
SOA_COLUMN(float, sipmPar_auxi2),
57+
SOA_SCALAR(int, maxDepthHB),
58+
SOA_SCALAR(int, maxDepthHE),
59+
SOA_SCALAR(int, maxPhiHE),
60+
SOA_SCALAR(int, firstHBRing),
61+
SOA_SCALAR(int, lastHBRing),
62+
SOA_SCALAR(int, firstHERing),
63+
SOA_SCALAR(int, lastHERing),
64+
SOA_SCALAR(int, nEtaHB),
65+
SOA_SCALAR(int, nEtaHE),
66+
SOA_SCALAR(uint32_t, offsetForHashes))
67+
using HcalMahiConditionsSoA = HcalMahiConditionsSoALayout<>;
68+
69+
} // namespace hcal
70+
71+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef CondFormats_HcalObjects_interface_HcalMahiPulseOffsetsPortable_h
2+
#define CondFormats_HcalObjects_interface_HcalMahiPulseOffsetsPortable_h
3+
4+
#include "CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsSoA.h"
5+
#include "DataFormats/Portable/interface/PortableHostCollection.h"
6+
7+
namespace hcal {
8+
using HcalMahiPulseOffsetsPortableHost = PortableHostCollection<HcalMahiPulseOffsetsSoA>;
9+
}
10+
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef CondFormats_HcalObjects_HcalMahiPulseOffsetsSoA_h
2+
#define CondFormats_HcalObjects_HcalMahiPulseOffsetsSoA_h
3+
4+
#include "DataFormats/SoATemplate/interface/SoACommon.h"
5+
#include "DataFormats/SoATemplate/interface/SoALayout.h"
6+
#include "DataFormats/SoATemplate/interface/SoAView.h"
7+
8+
namespace hcal {
9+
GENERATE_SOA_LAYOUT(HcalMahiPulseOffsetsSoALayout, SOA_COLUMN(int, offsets))
10+
using HcalMahiPulseOffsetsSoA = HcalMahiPulseOffsetsSoALayout<>;
11+
12+
} // namespace hcal
13+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHost_h
2+
#define CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHost_h
3+
4+
#include "CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeT.h"
5+
#include "DataFormats/Portable/interface/PortableCollection.h"
6+
#include "DataFormats/Portable/interface/PortableHostCollection.h"
7+
8+
namespace hcal {
9+
using HcalRecoParamWithPulseShapeHost = HcalRecoParamWithPulseShapeT<alpaka::DevCpu>;
10+
}
11+
namespace cms::alpakatools {
12+
template <>
13+
struct CopyToDevice<::hcal::HcalRecoParamWithPulseShapeHost> {
14+
template <typename TQueue>
15+
static auto copyAsync(TQueue& queue, ::hcal::HcalRecoParamWithPulseShapeHost const& hostProduct) {
16+
using RecoParamCopy = CopyToDevice<::hcal::HcalRecoParamWithPulseShapeHost::RecoParamCollection>;
17+
using PulseShapeCopy = CopyToDevice<::hcal::HcalRecoParamWithPulseShapeHost::PulseShapeCollection>;
18+
using Device = alpaka::Dev<TQueue>;
19+
return ::hcal::HcalRecoParamWithPulseShapeT<Device>(RecoParamCopy::copyAsync(queue, hostProduct.recoParam()),
20+
PulseShapeCopy::copyAsync(queue, hostProduct.pulseShape()));
21+
}
22+
};
23+
} // namespace cms::alpakatools
24+
25+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef CondFormats_HcalObjects_HcalRecoParamWithPulseShapeSoA_h
2+
#define CondFormats_HcalObjects_HcalRecoParamWithPulseShapeSoA_h
3+
4+
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalConstants.h"
5+
6+
#include "DataFormats/SoATemplate/interface/SoACommon.h"
7+
#include "DataFormats/SoATemplate/interface/SoALayout.h"
8+
#include "DataFormats/SoATemplate/interface/SoAView.h"
9+
10+
#include <array>
11+
12+
namespace hcal {
13+
using HcalPSfunctorArray = std::array<float, hcal::constants::maxPSshapeBin>; // 256
14+
using HcalPSfunctorBXarray = std::array<float, hcal::constants::nsPerBX>; // 25
15+
16+
GENERATE_SOA_LAYOUT(HcalRecoParamSoALayout,
17+
SOA_COLUMN(uint32_t, param1),
18+
SOA_COLUMN(uint32_t, param2),
19+
SOA_COLUMN(uint32_t, ids))
20+
GENERATE_SOA_LAYOUT(HcalPulseShapeSoALayout,
21+
SOA_COLUMN(HcalPSfunctorArray, acc25nsVec),
22+
SOA_COLUMN(HcalPSfunctorArray, diff25nsItvlVec),
23+
SOA_COLUMN(HcalPSfunctorBXarray, accVarLenIdxMinusOneVec),
24+
SOA_COLUMN(HcalPSfunctorBXarray, diffVarItvlIdxMinusOneVec),
25+
SOA_COLUMN(HcalPSfunctorBXarray, accVarLenIdxZEROVec),
26+
SOA_COLUMN(HcalPSfunctorBXarray, diffVarItvlIdxZEROVec))
27+
28+
using HcalRecoParamSoA = HcalRecoParamSoALayout<>;
29+
using HcalPulseShapeSoA = HcalPulseShapeSoALayout<>;
30+
} // namespace hcal
31+
#endif
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#ifndef CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHostT_h
2+
#define CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHostT_h
3+
4+
#include "CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeSoA.h"
5+
#include "DataFormats/Portable/interface/PortableCollection.h"
6+
#include "DataFormats/Portable/interface/PortableHostCollection.h"
7+
8+
namespace hcal {
9+
template <typename TDev>
10+
class HcalRecoParamWithPulseShapeT {
11+
public:
12+
using RecoParamCollection = PortableCollection<HcalRecoParamSoA, TDev>;
13+
using PulseShapeCollection = PortableCollection<HcalPulseShapeSoA, TDev>;
14+
15+
using PulseShapeConstElement = typename PulseShapeCollection::ConstView::const_element;
16+
17+
class ConstView {
18+
public:
19+
using RecoParamConstView = typename RecoParamCollection::ConstView;
20+
using PulseShapeConstView = typename PulseShapeCollection::ConstView;
21+
constexpr ConstView(RecoParamConstView recoView, PulseShapeConstView psView)
22+
: recoParamView_{recoView}, pulseShapeView_{psView} {};
23+
24+
ALPAKA_FN_ACC PulseShapeConstElement getPulseShape(uint32_t const hashedId) const {
25+
auto const recoPulseShapeId = recoParamView_.ids()[hashedId];
26+
return pulseShapeView_[recoPulseShapeId];
27+
}
28+
29+
constexpr typename RecoParamCollection::ConstView recoParamView() { return recoParamView_; }
30+
31+
private:
32+
typename RecoParamCollection::ConstView recoParamView_;
33+
typename PulseShapeCollection::ConstView pulseShapeView_;
34+
};
35+
36+
HcalRecoParamWithPulseShapeT(size_t recoSize, size_t pulseSize, TDev const& dev)
37+
: recoParam_(recoSize, dev), pulseShape_(pulseSize, dev) {}
38+
template <typename TQueue, typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
39+
HcalRecoParamWithPulseShapeT(size_t recoSize, size_t pulseSize, TQueue const& queue)
40+
: recoParam_(recoSize, queue), pulseShape_(pulseSize, queue) {}
41+
HcalRecoParamWithPulseShapeT(RecoParamCollection reco, PulseShapeCollection pulse)
42+
: recoParam_(std::move(reco)), pulseShape_(std::move(pulse)) {}
43+
44+
const RecoParamCollection& recoParam() const { return recoParam_; }
45+
const PulseShapeCollection& pulseShape() const { return pulseShape_; }
46+
47+
typename RecoParamCollection::View recoParamView() { return recoParam_.view(); }
48+
typename PulseShapeCollection::View pulseShapeView() { return pulseShape_.view(); }
49+
50+
ConstView const_view() const { return ConstView(recoParam_.view(), pulseShape_.view()); }
51+
52+
private:
53+
RecoParamCollection recoParam_;
54+
PulseShapeCollection pulseShape_;
55+
};
56+
} // namespace hcal
57+
#endif

0 commit comments

Comments
 (0)