From f7294499f9d0bc00f3369610b1f3a397914c0bff Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 5 Dec 2024 10:06:36 +0100 Subject: [PATCH] Remove the default constructor from PortableCollection --- DataFormats/Common/interface/DeviceProduct.h | 4 +++- .../Portable/interface/PortableDeviceCollection.h | 11 ++++++++--- .../Portable/interface/PortableDeviceObject.h | 5 ++++- .../Portable/interface/PortableHostCollection.h | 11 ++++++++--- DataFormats/Portable/interface/PortableHostObject.h | 5 ++++- .../interface/SiPixelClustersDevice.h | 9 ++++++--- .../interface/SiPixelClustersHost.h | 6 ++++-- .../interface/SiPixelDigiErrorsDevice.h | 4 +++- .../interface/SiPixelDigiErrorsHost.h | 4 +++- .../SiPixelDigiSoA/interface/SiPixelDigisDevice.h | 4 +++- .../SiPixelDigiSoA/interface/SiPixelDigisHost.h | 4 +++- DataFormats/TrackSoA/interface/TracksDevice.h | 12 +++++++++--- DataFormats/TrackSoA/interface/TracksHost.h | 13 +++++++++---- .../interface/TrackingRecHitsDevice.h | 4 +++- .../interface/TrackingRecHitsHost.h | 3 ++- 15 files changed, 72 insertions(+), 27 deletions(-) diff --git a/DataFormats/Common/interface/DeviceProduct.h b/DataFormats/Common/interface/DeviceProduct.h index 926d7ad16e262..1c9ddbc1f588f 100644 --- a/DataFormats/Common/interface/DeviceProduct.h +++ b/DataFormats/Common/interface/DeviceProduct.h @@ -4,6 +4,8 @@ #include #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" + namespace edm { class DeviceProductBase { public: @@ -45,7 +47,7 @@ namespace edm { template class DeviceProduct : public DeviceProductBase { public: - DeviceProduct() = default; + explicit DeviceProduct(edm::AllocateForOverwrite) : data_{edm::allocateForOverwrite} {} template explicit DeviceProduct(std::shared_ptr metadata, Args&&... args) diff --git a/DataFormats/Portable/interface/PortableDeviceCollection.h b/DataFormats/Portable/interface/PortableDeviceCollection.h index 4634374cc2d22..591411a80d040 100644 --- a/DataFormats/Portable/interface/PortableDeviceCollection.h +++ b/DataFormats/Portable/interface/PortableDeviceCollection.h @@ -7,9 +7,10 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" +#include "DataFormats/Portable/interface/PortableCollectionCommon.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" #include "HeterogeneousCore/AlpakaInterface/interface/memory.h" -#include "DataFormats/Portable/interface/PortableCollectionCommon.h" // generic SoA-based product in device memory template >> @@ -24,7 +25,9 @@ class PortableDeviceCollection { using Buffer = cms::alpakatools::device_buffer; using ConstBuffer = cms::alpakatools::const_device_buffer; - PortableDeviceCollection() = default; + PortableDeviceCollection() = delete; + + explicit PortableDeviceCollection(edm::AllocateForOverwrite) noexcept {} PortableDeviceCollection(int32_t elements, TDev const& device) : buffer_{cms::alpakatools::make_device_buffer(device, Layout::computeDataSize(elements))}, @@ -144,7 +147,9 @@ class PortableDeviceMultiCollection { } public: - PortableDeviceMultiCollection() = default; + PortableDeviceMultiCollection() = delete; + + explicit PortableDeviceMultiCollection(edm::AllocateForOverwrite) noexcept {}; PortableDeviceMultiCollection(int32_t elements, TDev const& device) : buffer_{cms::alpakatools::make_device_buffer(device, Layout<>::computeDataSize(elements))}, diff --git a/DataFormats/Portable/interface/PortableDeviceObject.h b/DataFormats/Portable/interface/PortableDeviceObject.h index 9ae0dd529713b..afc2681429452 100644 --- a/DataFormats/Portable/interface/PortableDeviceObject.h +++ b/DataFormats/Portable/interface/PortableDeviceObject.h @@ -7,6 +7,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" #include "HeterogeneousCore/AlpakaInterface/interface/memory.h" @@ -21,7 +22,9 @@ class PortableDeviceObject { using Buffer = cms::alpakatools::device_buffer; using ConstBuffer = cms::alpakatools::const_device_buffer; - PortableDeviceObject() = default; + PortableDeviceObject() = delete; + + PortableDeviceObject(edm::AllocateForOverwrite) {} PortableDeviceObject(TDev const& device) // allocate global device memory diff --git a/DataFormats/Portable/interface/PortableHostCollection.h b/DataFormats/Portable/interface/PortableHostCollection.h index 647ddb8648281..87b73a224294a 100644 --- a/DataFormats/Portable/interface/PortableHostCollection.h +++ b/DataFormats/Portable/interface/PortableHostCollection.h @@ -6,10 +6,11 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" +#include "DataFormats/Portable/interface/PortableCollectionCommon.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" #include "HeterogeneousCore/AlpakaInterface/interface/host.h" #include "HeterogeneousCore/AlpakaInterface/interface/memory.h" -#include "DataFormats/Portable/interface/PortableCollectionCommon.h" // generic SoA-based product in host memory template @@ -21,7 +22,9 @@ class PortableHostCollection { using Buffer = cms::alpakatools::host_buffer; using ConstBuffer = cms::alpakatools::const_host_buffer; - PortableHostCollection() = default; + PortableHostCollection() = delete; + + explicit PortableHostCollection(edm::AllocateForOverwrite) noexcept {}; PortableHostCollection(int32_t elements, alpaka_common::DevHost const& host) // allocate pageable host memory @@ -154,7 +157,9 @@ class PortableHostMultiCollection { } public: - PortableHostMultiCollection() = default; + PortableHostMultiCollection() = delete; + + explicit PortableHostMultiCollection(edm::AllocateForOverwrite) noexcept {}; PortableHostMultiCollection(int32_t elements, alpaka_common::DevHost const& host) // allocate pageable host memory diff --git a/DataFormats/Portable/interface/PortableHostObject.h b/DataFormats/Portable/interface/PortableHostObject.h index e120101fc1795..f3b85ce88e089 100644 --- a/DataFormats/Portable/interface/PortableHostObject.h +++ b/DataFormats/Portable/interface/PortableHostObject.h @@ -7,6 +7,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" #include "HeterogeneousCore/AlpakaInterface/interface/host.h" #include "HeterogeneousCore/AlpakaInterface/interface/memory.h" @@ -19,7 +20,9 @@ class PortableHostObject { using Buffer = cms::alpakatools::host_buffer; using ConstBuffer = cms::alpakatools::const_host_buffer; - PortableHostObject() = default; + PortableHostObject() = delete; + + PortableHostObject(edm::AllocateForOverwrite) noexcept {} PortableHostObject(alpaka_common::DevHost const& host) // allocate pageable host memory diff --git a/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h b/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h index 2593475bf5c3a..75b26a9bebc9d 100644 --- a/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h +++ b/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h @@ -2,17 +2,20 @@ #define DataFormats_SiPixelClusterSoA_interface_SiPixelClustersDevice_h #include + #include -#include "HeterogeneousCore/AlpakaInterface/interface/config.h" -#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h" + +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableDeviceCollection.h" +#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h" #include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersSoA.h" #include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h" +#include "HeterogeneousCore/AlpakaInterface/interface/config.h" template class SiPixelClustersDevice : public PortableDeviceCollection { public: - SiPixelClustersDevice() = default; + SiPixelClustersDevice(edm::AllocateForOverwrite) : PortableDeviceCollection{edm::allocateForOverwrite} {} template explicit SiPixelClustersDevice(size_t maxModules, TQueue queue) diff --git a/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h b/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h index eb086160a6188..653fb4190d0b4 100644 --- a/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h +++ b/DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h @@ -2,16 +2,18 @@ #define DataFormats_SiPixelClusterSoA_interface_SiPixelClustersHost_h #include -#include "HeterogeneousCore/AlpakaInterface/interface/config.h" + +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableHostCollection.h" #include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersSoA.h" +#include "HeterogeneousCore/AlpakaInterface/interface/config.h" // TODO: The class is created via inheritance of the PortableCollection. // This is generally discouraged, and should be done via composition. // See: https://github.com/cms-sw/cmssw/pull/40465#discussion_r1067364306 class SiPixelClustersHost : public PortableHostCollection { public: - SiPixelClustersHost() = default; + SiPixelClustersHost(edm::AllocateForOverwrite) : PortableHostCollection{edm::allocateForOverwrite} {} template explicit SiPixelClustersHost(size_t maxModules, TQueue queue) diff --git a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsDevice.h b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsDevice.h index 36c7d0be7e88a..422149170ab20 100644 --- a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsDevice.h +++ b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsDevice.h @@ -5,6 +5,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableDeviceCollection.h" #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsSoA.h" #include "DataFormats/SiPixelRawData/interface/SiPixelErrorCompact.h" @@ -14,7 +15,8 @@ template class SiPixelDigiErrorsDevice : public PortableDeviceCollection { public: - SiPixelDigiErrorsDevice() = default; + SiPixelDigiErrorsDevice(edm::AllocateForOverwrite) : PortableDeviceCollection{edm::allocateForOverwrite} {} + template explicit SiPixelDigiErrorsDevice(size_t maxFedWords, TQueue queue) : PortableDeviceCollection(maxFedWords, queue), maxFedWords_(maxFedWords) {} diff --git a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsHost.h b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsHost.h index ac706dea4b544..0b446a2014ada 100644 --- a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsHost.h +++ b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsHost.h @@ -5,6 +5,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableHostCollection.h" #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsSoA.h" #include "DataFormats/SiPixelRawData/interface/SiPixelErrorCompact.h" @@ -13,7 +14,8 @@ class SiPixelDigiErrorsHost : public PortableHostCollection { public: - SiPixelDigiErrorsHost() = default; + SiPixelDigiErrorsHost(edm::AllocateForOverwrite) : PortableHostCollection{edm::allocateForOverwrite} {} + template explicit SiPixelDigiErrorsHost(int maxFedWords, TQueue queue) : PortableHostCollection(maxFedWords, queue), maxFedWords_(maxFedWords) {} diff --git a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h index da0914511c99b..1442c7fed2141 100644 --- a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h +++ b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h @@ -5,6 +5,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableDeviceCollection.h" #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisSoA.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" @@ -12,7 +13,8 @@ template class SiPixelDigisDevice : public PortableDeviceCollection { public: - SiPixelDigisDevice() = default; + SiPixelDigisDevice(edm::AllocateForOverwrite) : PortableDeviceCollection{edm::allocateForOverwrite} {} + template explicit SiPixelDigisDevice(size_t maxFedWords, TQueue queue) : PortableDeviceCollection(maxFedWords + 1, queue) {} diff --git a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h index 69633db9db28b..edf6415f66aa9 100644 --- a/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h +++ b/DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h @@ -1,6 +1,7 @@ #ifndef DataFormats_SiPixelDigiSoA_interface_SiPixelDigisHost_h #define DataFormats_SiPixelDigiSoA_interface_SiPixelDigisHost_h +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableHostCollection.h" #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisSoA.h" @@ -9,7 +10,8 @@ // See: https://github.com/cms-sw/cmssw/pull/40465#discussion_r1067364306 class SiPixelDigisHost : public PortableHostCollection { public: - SiPixelDigisHost() = default; + SiPixelDigisHost(edm::AllocateForOverwrite) : PortableHostCollection{edm::allocateForOverwrite} {} + template explicit SiPixelDigisHost(size_t maxFedWords, TQueue queue) : PortableHostCollection(maxFedWords + 1, queue) {} diff --git a/DataFormats/TrackSoA/interface/TracksDevice.h b/DataFormats/TrackSoA/interface/TracksDevice.h index dd2b25c8794be..43bbc8cdba47b 100644 --- a/DataFormats/TrackSoA/interface/TracksDevice.h +++ b/DataFormats/TrackSoA/interface/TracksDevice.h @@ -2,10 +2,13 @@ #define DataFormats_Track_interface_TracksDevice_h #include + #include -#include "DataFormats/TrackSoA/interface/TracksSoA.h" -#include "DataFormats/TrackSoA/interface/TrackDefinitions.h" + +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableDeviceCollection.h" +#include "DataFormats/TrackSoA/interface/TrackDefinitions.h" +#include "DataFormats/TrackSoA/interface/TracksSoA.h" // TODO: The class is created via inheritance of the PortableCollection. // This is generally discouraged, and should be done via composition. @@ -14,7 +17,10 @@ template class TracksDevice : public PortableDeviceCollection, TDev> { public: static constexpr int32_t S = TrackerTraits::maxNumberOfTuples; //TODO: this could be made configurable at runtime - TracksDevice() = default; // necessary for ROOT dictionaries + + TracksDevice(edm::AllocateForOverwrite) + : PortableDeviceCollection, TDev>{edm::allocateForOverwrite} { + } // necessary for ROOT dictionaries using PortableDeviceCollection, TDev>::view; using PortableDeviceCollection, TDev>::const_view; diff --git a/DataFormats/TrackSoA/interface/TracksHost.h b/DataFormats/TrackSoA/interface/TracksHost.h index a8f459eac066c..b3a58dab3ab1b 100644 --- a/DataFormats/TrackSoA/interface/TracksHost.h +++ b/DataFormats/TrackSoA/interface/TracksHost.h @@ -2,11 +2,14 @@ #define DataFormats_Track_TracksHost_H #include + #include -#include "Geometry/CommonTopologies/interface/SimplePixelTopology.h" -#include "DataFormats/TrackSoA/interface/TracksSoA.h" -#include "DataFormats/TrackSoA/interface/TrackDefinitions.h" + +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableHostCollection.h" +#include "DataFormats/TrackSoA/interface/TrackDefinitions.h" +#include "DataFormats/TrackSoA/interface/TracksSoA.h" +#include "Geometry/CommonTopologies/interface/SimplePixelTopology.h" // TODO: The class is created via inheritance of the PortableHostCollection. // This is generally discouraged, and should be done via composition. @@ -15,7 +18,9 @@ template class TracksHost : public PortableHostCollection> { public: static constexpr int32_t S = TrackerTraits::maxNumberOfTuples; //TODO: this could be made configurable at runtime - TracksHost() = default; // Needed for the dictionary; not sure if line above is needed anymore + + TracksHost(edm::AllocateForOverwrite) + : PortableHostCollection>{edm::allocateForOverwrite} {} // necessary for ROOT dictionaries using PortableHostCollection>::view; using PortableHostCollection>::const_view; diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h index e5b59e03d6ad7..5ad0df49e47ae 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h @@ -5,6 +5,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableDeviceCollection.h" #include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h" #include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" @@ -19,7 +20,8 @@ class TrackingRecHitDevice : public PortableDeviceCollection, TDev>::const_view; using PortableDeviceCollection, TDev>::buffer; - TrackingRecHitDevice() = default; + TrackingRecHitDevice(edm::AllocateForOverwrite) + : PortableDeviceCollection, TDev>{edm::allocateForOverwrite} {} // Constructor which specifies the SoA size, number of BPIX1 hits, and the modules entry points template diff --git a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h index e7212ce9a6252..6fd8234175ee7 100644 --- a/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h +++ b/DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsHost.h @@ -5,6 +5,7 @@ #include +#include "DataFormats/Common/interface/AllocateForOverwrite.h" #include "DataFormats/Portable/interface/PortableHostCollection.h" #include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsSoA.h" #include "HeterogeneousCore/AlpakaInterface/interface/config.h" @@ -19,7 +20,7 @@ class TrackingRecHitHost : public PortableHostCollection>::const_view; using PortableHostCollection>::buffer; - TrackingRecHitHost() = default; + TrackingRecHitHost(edm::AllocateForOverwrite) : PortableHostCollection>{edm::allocateForOverwrite} {} // Constructor which specifies only the SoA size, to be used when copying the results from the device to the host template