Skip to content

Commit 4c8434c

Browse files
committed
Remove the default constructor from PortableCollection
Remove the default constructor from PortableCollection, PortableObject and related types, and introduce the special constructor taking kUninitialized.
1 parent 74c7d61 commit 4c8434c

File tree

14 files changed

+72
-26
lines changed

14 files changed

+72
-26
lines changed

DataFormats/Portable/interface/PortableDeviceCollection.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
#include <alpaka/alpaka.hpp>
99

10+
#include "DataFormats/Common/interface/Uninitialized.h"
11+
#include "DataFormats/Portable/interface/PortableCollectionCommon.h"
1012
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
1113
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
12-
#include "DataFormats/Portable/interface/PortableCollectionCommon.h"
1314

1415
// generic SoA-based product in device memory
1516
template <typename T, typename TDev, typename = std::enable_if_t<alpaka::isDevice<TDev>>>
@@ -24,7 +25,9 @@ class PortableDeviceCollection {
2425
using Buffer = cms::alpakatools::device_buffer<TDev, std::byte[]>;
2526
using ConstBuffer = cms::alpakatools::const_device_buffer<TDev, std::byte[]>;
2627

27-
PortableDeviceCollection() = default;
28+
PortableDeviceCollection() = delete;
29+
30+
explicit PortableDeviceCollection(edm::Uninitialized) noexcept {}
2831

2932
PortableDeviceCollection(int32_t elements, TDev const& device)
3033
: buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, Layout::computeDataSize(elements))},
@@ -144,7 +147,9 @@ class PortableDeviceMultiCollection {
144147
}
145148

146149
public:
147-
PortableDeviceMultiCollection() = default;
150+
PortableDeviceMultiCollection() = delete;
151+
152+
explicit PortableDeviceMultiCollection(edm::Uninitialized) noexcept {};
148153

149154
PortableDeviceMultiCollection(int32_t elements, TDev const& device)
150155
: buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, Layout<>::computeDataSize(elements))},

DataFormats/Portable/interface/PortableDeviceObject.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <alpaka/alpaka.hpp>
99

10+
#include "DataFormats/Common/interface/Uninitialized.h"
1011
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
1112
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
1213

@@ -21,7 +22,9 @@ class PortableDeviceObject {
2122
using Buffer = cms::alpakatools::device_buffer<TDev, Product>;
2223
using ConstBuffer = cms::alpakatools::const_device_buffer<TDev, Product>;
2324

24-
PortableDeviceObject() = default;
25+
PortableDeviceObject() = delete;
26+
27+
PortableDeviceObject(edm::Uninitialized) {}
2528

2629
PortableDeviceObject(TDev const& device)
2730
// allocate global device memory

DataFormats/Portable/interface/PortableHostCollection.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
#include <alpaka/alpaka.hpp>
88

9+
#include "DataFormats/Common/interface/Uninitialized.h"
10+
#include "DataFormats/Portable/interface/PortableCollectionCommon.h"
911
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
1012
#include "HeterogeneousCore/AlpakaInterface/interface/host.h"
1113
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
12-
#include "DataFormats/Portable/interface/PortableCollectionCommon.h"
1314

1415
// generic SoA-based product in host memory
1516
template <typename T>
@@ -21,7 +22,9 @@ class PortableHostCollection {
2122
using Buffer = cms::alpakatools::host_buffer<std::byte[]>;
2223
using ConstBuffer = cms::alpakatools::const_host_buffer<std::byte[]>;
2324

24-
PortableHostCollection() = default;
25+
PortableHostCollection() = delete;
26+
27+
explicit PortableHostCollection(edm::Uninitialized) noexcept {};
2528

2629
PortableHostCollection(int32_t elements, alpaka_common::DevHost const& host)
2730
// allocate pageable host memory
@@ -154,7 +157,9 @@ class PortableHostMultiCollection {
154157
}
155158

156159
public:
157-
PortableHostMultiCollection() = default;
160+
PortableHostMultiCollection() = delete;
161+
162+
explicit PortableHostMultiCollection(edm::Uninitialized) noexcept {};
158163

159164
PortableHostMultiCollection(int32_t elements, alpaka_common::DevHost const& host)
160165
// allocate pageable host memory

DataFormats/Portable/interface/PortableHostObject.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <alpaka/alpaka.hpp>
99

10+
#include "DataFormats/Common/interface/Uninitialized.h"
1011
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
1112
#include "HeterogeneousCore/AlpakaInterface/interface/host.h"
1213
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
@@ -19,7 +20,9 @@ class PortableHostObject {
1920
using Buffer = cms::alpakatools::host_buffer<Product>;
2021
using ConstBuffer = cms::alpakatools::const_host_buffer<Product>;
2122

22-
PortableHostObject() = default;
23+
PortableHostObject() = delete;
24+
25+
PortableHostObject(edm::Uninitialized) noexcept {}
2326

2427
PortableHostObject(alpaka_common::DevHost const& host)
2528
// allocate pageable host memory

DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
#define DataFormats_SiPixelClusterSoA_interface_SiPixelClustersDevice_h
33

44
#include <cstdint>
5+
56
#include <alpaka/alpaka.hpp>
6-
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
7-
#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h"
7+
8+
#include "DataFormats/Common/interface/Uninitialized.h"
89
#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
10+
#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h"
911
#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersSoA.h"
1012
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
13+
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
1114

1215
template <typename TDev>
1316
class SiPixelClustersDevice : public PortableDeviceCollection<SiPixelClustersSoA, TDev> {
1417
public:
15-
SiPixelClustersDevice() = default;
18+
SiPixelClustersDevice(edm::Uninitialized) : PortableDeviceCollection<SiPixelClustersSoA, TDev>{edm::kUninitialized} {}
1619

1720
template <typename TQueue>
1821
explicit SiPixelClustersDevice(size_t maxModules, TQueue queue)

DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
#define DataFormats_SiPixelClusterSoA_interface_SiPixelClustersHost_h
33

44
#include <alpaka/alpaka.hpp>
5-
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
5+
6+
#include "DataFormats/Common/interface/Uninitialized.h"
67
#include "DataFormats/Portable/interface/PortableHostCollection.h"
78
#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersSoA.h"
9+
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
810

911
// TODO: The class is created via inheritance of the PortableCollection.
1012
// This is generally discouraged, and should be done via composition.
1113
// See: https://github.com/cms-sw/cmssw/pull/40465#discussion_r1067364306
1214
class SiPixelClustersHost : public PortableHostCollection<SiPixelClustersSoA> {
1315
public:
14-
SiPixelClustersHost() = default;
16+
SiPixelClustersHost(edm::Uninitialized) : PortableHostCollection<SiPixelClustersSoA>{edm::kUninitialized} {}
1517

1618
template <typename TQueue>
1719
explicit SiPixelClustersHost(size_t maxModules, TQueue queue)

DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsDevice.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <alpaka/alpaka.hpp>
77

8+
#include "DataFormats/Common/interface/Uninitialized.h"
89
#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
910
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsSoA.h"
1011
#include "DataFormats/SiPixelRawData/interface/SiPixelErrorCompact.h"
@@ -14,7 +15,9 @@
1415
template <typename TDev>
1516
class SiPixelDigiErrorsDevice : public PortableDeviceCollection<SiPixelDigiErrorsSoA, TDev> {
1617
public:
17-
SiPixelDigiErrorsDevice() = default;
18+
SiPixelDigiErrorsDevice(edm::Uninitialized)
19+
: PortableDeviceCollection<SiPixelDigiErrorsSoA, TDev>{edm::kUninitialized} {}
20+
1821
template <typename TQueue>
1922
explicit SiPixelDigiErrorsDevice(size_t maxFedWords, TQueue queue)
2023
: PortableDeviceCollection<SiPixelDigiErrorsSoA, TDev>(maxFedWords, queue), maxFedWords_(maxFedWords) {}

DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsHost.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <alpaka/alpaka.hpp>
77

8+
#include "DataFormats/Common/interface/Uninitialized.h"
89
#include "DataFormats/Portable/interface/PortableHostCollection.h"
910
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsSoA.h"
1011
#include "DataFormats/SiPixelRawData/interface/SiPixelErrorCompact.h"
@@ -13,7 +14,8 @@
1314

1415
class SiPixelDigiErrorsHost : public PortableHostCollection<SiPixelDigiErrorsSoA> {
1516
public:
16-
SiPixelDigiErrorsHost() = default;
17+
SiPixelDigiErrorsHost(edm::Uninitialized) : PortableHostCollection<SiPixelDigiErrorsSoA>{edm::kUninitialized} {}
18+
1719
template <typename TQueue>
1820
explicit SiPixelDigiErrorsHost(int maxFedWords, TQueue queue)
1921
: PortableHostCollection<SiPixelDigiErrorsSoA>(maxFedWords, queue), maxFedWords_(maxFedWords) {}

DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55

66
#include <alpaka/alpaka.hpp>
77

8+
#include "DataFormats/Common/interface/Uninitialized.h"
89
#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
910
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisSoA.h"
1011
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
1112

1213
template <typename TDev>
1314
class SiPixelDigisDevice : public PortableDeviceCollection<SiPixelDigisSoA, TDev> {
1415
public:
15-
SiPixelDigisDevice() = default;
16+
SiPixelDigisDevice(edm::Uninitialized) : PortableDeviceCollection<SiPixelDigisSoA, TDev>{edm::kUninitialized} {}
17+
1618
template <typename TQueue>
1719
explicit SiPixelDigisDevice(size_t maxFedWords, TQueue queue)
1820
: PortableDeviceCollection<SiPixelDigisSoA, TDev>(maxFedWords + 1, queue) {}

DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef DataFormats_SiPixelDigiSoA_interface_SiPixelDigisHost_h
22
#define DataFormats_SiPixelDigiSoA_interface_SiPixelDigisHost_h
33

4+
#include "DataFormats/Common/interface/Uninitialized.h"
45
#include "DataFormats/Portable/interface/PortableHostCollection.h"
56
#include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisSoA.h"
67

@@ -9,7 +10,8 @@
910
// See: https://github.com/cms-sw/cmssw/pull/40465#discussion_r1067364306
1011
class SiPixelDigisHost : public PortableHostCollection<SiPixelDigisSoA> {
1112
public:
12-
SiPixelDigisHost() = default;
13+
SiPixelDigisHost(edm::Uninitialized) : PortableHostCollection<SiPixelDigisSoA>{edm::kUninitialized} {}
14+
1315
template <typename TQueue>
1416
explicit SiPixelDigisHost(size_t maxFedWords, TQueue queue)
1517
: PortableHostCollection<SiPixelDigisSoA>(maxFedWords + 1, queue) {}

0 commit comments

Comments
 (0)