Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions DataFormats/BeamSpot/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsBeamSpotTrivialSerialisation">
<use name="DataFormats/BeamSpot"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
4 changes: 4 additions & 0 deletions DataFormats/BeamSpot/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DataFormats/BeamSpot/interface/BeamSpotHost.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(BeamSpotHost);
5 changes: 5 additions & 0 deletions DataFormats/EcalDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsEcalDigiTrivialSerialisation">
<use name="DataFormats/EcalDigi"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
6 changes: 6 additions & 0 deletions DataFormats/EcalDigi/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "DataFormats/EcalDigi/interface/EcalDigiHostCollection.h"
#include "DataFormats/EcalDigi/interface/EcalDigiPhase2HostCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(EcalDigiHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(EcalDigiPhase2HostCollection);
5 changes: 5 additions & 0 deletions DataFormats/EcalRecHit/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsEcalRecHitTrivialSerialisation">
<use name="DataFormats/EcalRecHit"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
6 changes: 6 additions & 0 deletions DataFormats/EcalRecHit/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "DataFormats/EcalRecHit/interface/EcalRecHitHostCollection.h"
#include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHitHostCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(EcalRecHitHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(EcalUncalibratedRecHitHostCollection);
5 changes: 5 additions & 0 deletions DataFormats/HGCalDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsHGCalDigiTrivialSerialisation">
<use name="DataFormats/HGCalDigi"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
8 changes: 8 additions & 0 deletions DataFormats/HGCalDigi/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "DataFormats/HGCalDigi/interface/HGCalDigiHost.h"
#include "DataFormats/HGCalDigi/interface/HGCalECONDPacketInfoHost.h"
#include "DataFormats/HGCalDigi/interface/HGCalFEDPacketInfoHost.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(hgcaldigi::HGCalDigiHost);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(hgcaldigi::HGCalECONDPacketInfoHost);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(hgcaldigi::HGCalFEDPacketInfoHost);
5 changes: 5 additions & 0 deletions DataFormats/HGCalReco/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsHGCalRecoTrivialSerialisation">
<use name="DataFormats/HGCalReco"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
10 changes: 10 additions & 0 deletions DataFormats/HGCalReco/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "DataFormats/HGCalReco/interface/HGCalSoAClustersHostCollection.h"
#include "DataFormats/HGCalReco/interface/HGCalSoARecHitsExtraHostCollection.h"
#include "DataFormats/HGCalReco/interface/HGCalSoARecHitsHostCollection.h"
#include "DataFormats/HGCalReco/interface/MtdHostCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(HGCalSoAClustersHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(HGCalSoARecHitsExtraHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(HGCalSoARecHitsHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(MtdHostCollection);
5 changes: 5 additions & 0 deletions DataFormats/HcalDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsHcalDigiTrivialSerialisation">
<use name="DataFormats/HcalDigi"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
5 changes: 5 additions & 0 deletions DataFormats/HcalDigi/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "DataFormats/HcalDigi/interface/HcalDigiHostCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(hcal::Phase0DigiHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(hcal::Phase1DigiHostCollection);
5 changes: 5 additions & 0 deletions DataFormats/HcalRecHit/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsHcalRecHitTrivialSerialisation">
<use name="DataFormats/HcalRecHit"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
4 changes: 4 additions & 0 deletions DataFormats/HcalRecHit/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DataFormats/HcalRecHit/interface/HcalRecHitHostCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(hcal::RecHitHostCollection);
5 changes: 5 additions & 0 deletions DataFormats/ParticleFlowReco/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsParticleFlowRecoTrivialSerialisation">
<use name="DataFormats/ParticleFlowReco"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
13 changes: 13 additions & 0 deletions DataFormats/ParticleFlowReco/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Include the Eigen core library before including the SoA definitions
#include <Eigen/Core>

#include "DataFormats/ParticleFlowReco/interface/CaloRecHitHostCollection.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterHostCollection.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFractionHostCollection.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecHitHostCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(reco::CaloRecHitHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(reco::PFClusterHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(reco::PFRecHitFractionHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(reco::PFRecHitHostCollection);
2 changes: 1 addition & 1 deletion DataFormats/ParticleFlowReco/src/alpaka/classes_cuda.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Include Eigen core library before include the SoA definitions
// Include the Eigen core library before including the SoA definitions
#include <Eigen/Core>

#include "DataFormats/Common/interface/DeviceProduct.h"
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/ParticleFlowReco/src/alpaka/classes_rocm.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Include Eigen core library before include the SoA definitions
// Include the Eigen core library before including the SoA definitions
#include <Eigen/Core>

#include "DataFormats/Common/interface/DeviceProduct.h"
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/ParticleFlowReco/src/classes_serial.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Include Eigen core library before include the SoA definitions
// Include the Eigen core library before including the SoA definitions
#include <Eigen/Core>

#include "DataFormats/ParticleFlowReco/interface/CaloRecHitHostCollection.h"
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/ParticleFlowReco/src/classes_serial.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Include Eigen core library before include the SoA definitions
// Include the Eigen core library before including the SoA definitions
#include <Eigen/Core>

#include "DataFormats/Common/interface/Wrapper.h"
Expand Down
4 changes: 3 additions & 1 deletion DataFormats/Portable/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<use name="alpaka"/>
<use name="rootcling"/>
<use name="FWCore/Utilities/" source_only="1"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/TrivialSerialisation"/>
<use name="FWCore/Utilities" source_only="1"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
6 changes: 4 additions & 2 deletions DataFormats/Portable/interface/PortableCollection.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#ifndef DataFormats_Portable_interface_PortableCollection_h
#define DataFormats_Portable_interface_PortableCollection_h

#include <type_traits>

#include <alpaka/alpaka.hpp>

#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/concepts.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToDevice.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/concepts.h"

namespace traits {

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Portable/interface/PortableCollectionCommon.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef DataFormats_Portable_interface_PortableCollectionCommon_h
#define DataFormats_Portable_interface_PortableCollectionCommon_h

#include <array>
#include <cstddef>
#include <type_traits>
#include <array>

namespace portablecollection {

Expand Down
4 changes: 3 additions & 1 deletion DataFormats/Portable/interface/PortableDeviceCollection.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef DataFormats_Portable_interface_PortableDeviceCollection_h
#define DataFormats_Portable_interface_PortableDeviceCollection_h

#include <array>
#include <cassert>
#include <concepts>
#include <cstddef>
#include <optional>
#include <type_traits>

Expand Down Expand Up @@ -217,7 +219,7 @@ class PortableDeviceMultiCollection {
public:
PortableDeviceMultiCollection() = delete;

explicit PortableDeviceMultiCollection(edm::Uninitialized) noexcept {};
explicit PortableDeviceMultiCollection(edm::Uninitialized) noexcept {}

PortableDeviceMultiCollection(int32_t elements, TDev const& device)
: buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, Layout<>::computeDataSize(elements))},
Expand Down
69 changes: 68 additions & 1 deletion DataFormats/Portable/interface/PortableHostCollection.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#ifndef DataFormats_Portable_interface_PortableHostCollection_h
#define DataFormats_Portable_interface_PortableHostCollection_h

#include <array>
#include <cassert>
#include <concepts>
#include <cstddef>
#include <cstring>
#include <optional>
#include <type_traits>
#include <utility>

#include <alpaka/alpaka.hpp>

#include "DataFormats/Common/interface/Uninitialized.h"
#include "DataFormats/Portable/interface/PortableCollectionCommon.h"
#include "DataFormats/TrivialSerialisation/interface/MemoryCopyTraits.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/host.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
Expand All @@ -27,7 +33,7 @@ class PortableHostCollection {

PortableHostCollection() = delete;

explicit PortableHostCollection(edm::Uninitialized) noexcept {};
explicit PortableHostCollection(edm::Uninitialized) noexcept {}

PortableHostCollection(int32_t elements, alpaka_common::DevHost const& host)
requires(!portablecollection::hasBlocksNumber<Layout>)
Expand Down Expand Up @@ -424,4 +430,65 @@ using PortableHostCollection4 = ::PortableHostMultiCollection<T0, T1, T2, T3>;
template <typename T0, typename T1, typename T2, typename T3, typename T4>
using PortableHostCollection5 = ::PortableHostMultiCollection<T0, T1, T2, T3, T4>;

namespace ngt {

// Specialize the MemoryCopyTraits for PortableHostColletion
template <typename T>
struct MemoryCopyTraits<PortableHostCollection<T>> {
using value_type = PortableHostCollection<T>;
using Properties = int32_t;

// The properties needed to initialize a new PrortableHostCollection are just its size.
static Properties properties(value_type const& object) { return object->metadata().size(); }

static void initialize(value_type& object, Properties const& size) {
// Replace the default-constructed empty object with one where the buffer has been allocated in pageable system memory.
object = value_type(size, cms::alpakatools::host());
}

static std::vector<std::span<std::byte>> regions(value_type& object) {
// The whole PortableHostCollection is stored in a single contiguous memory region.
std::byte* address = reinterpret_cast<std::byte*>(object.buffer().data());
size_t size = alpaka::getExtentProduct(object.buffer());
return {{address, size}};
}

static std::vector<std::span<const std::byte>> regions(value_type const& object) {
// The whole PortableHostCollection is stored in a single contiguous memory region.
const std::byte* address = reinterpret_cast<const std::byte*>(object.buffer().data());
size_t size = alpaka::getExtentProduct(object.buffer());
return {{address, size}};
}
};

// Specialize the MemoryCopyTraits for PortableHostMultiCollection
template <typename T0, typename... Args>
struct MemoryCopyTraits<PortableHostMultiCollection<T0, Args...>> {
using value_type = PortableHostMultiCollection<T0, Args...>;
using Properties = typename PortableHostMultiCollection<T0, Args...>::SizesArray;

// The properties needed to initialize a new PrortableHostMultiCollection are the sizes of all underlying PortableHostCollections.
static Properties properties(PortableHostMultiCollection<T0, Args...> const& object) { return object.sizes(); }

static void initialize(PortableHostMultiCollection<T0, Args...>& object, Properties const& sizes) {
// Replace the default-constructed empty object with one where the buffer has been allocated in pageable system memory.
object = PortableHostMultiCollection<T0, Args...>(sizes, cms::alpakatools::host());
}

static std::vector<std::span<std::byte>> regions(PortableHostMultiCollection<T0, Args...>& object) {
// The whole PortableHostMultiCollection is stored in a single contiguous memory region.
std::byte* address = reinterpret_cast<std::byte*>(object.buffer().data());
size_t size = alpaka::getExtentProduct(object.buffer());
return {{address, size}};
}

static std::vector<std::span<const std::byte>> regions(PortableHostMultiCollection<T0, Args...> const& object) {
// The whole PortableHostMultiCollection is stored in a single contiguous memory region.
const std::byte* address = reinterpret_cast<const std::byte*>(object.buffer().data());
size_t size = alpaka::getExtentProduct(object.buffer());
return {{address, size}};
}
};
} // namespace ngt

#endif // DataFormats_Portable_interface_PortableHostCollection_h
25 changes: 25 additions & 0 deletions DataFormats/Portable/interface/PortableHostObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <alpaka/alpaka.hpp>

#include "DataFormats/Common/interface/Uninitialized.h"
#include "DataFormats/TrivialSerialisation/interface/MemoryCopyTraits.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/host.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
Expand Down Expand Up @@ -115,4 +116,28 @@ class PortableHostObject {
Product* product_ = nullptr;
};

// Specialize the MemoryCopyTraits for PortableHostObject
namespace ngt {

template <typename T>
struct MemoryCopyTraits<PortableHostObject<T>> {
// This specialisation requires a initialize() method, but does not need to pass any parameters to it.
using Properties = void;

static void initialize(PortableHostObject<T>& object) {
// Replace the default-constructed empty object with one where the buffer has been allocated in pageable system memory.
object = PortableHostObject<T>(cms::alpakatools::host());
}

static std::vector<std::span<std::byte>> regions(PortableHostObject<T>& object) {
return {{reinterpret_cast<std::byte*>(object.data()), sizeof(T)}};
}

static std::vector<std::span<const std::byte>> regions(PortableHostObject<T> const& object) {
return {{reinterpret_cast<std::byte const*>(object.data()), sizeof(T)}};
}
};

} // namespace ngt

#endif // DataFormats_Portable_interface_PortableHostObject_h
4 changes: 2 additions & 2 deletions DataFormats/Portable/interface/PortableObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <alpaka/alpaka.hpp>

#include "DataFormats/Portable/interface/PortableHostObject.h"
#include "DataFormats/Portable/interface/PortableDeviceObject.h"
#include "HeterogeneousCore/AlpakaInterface/interface/concepts.h"
#include "DataFormats/Portable/interface/PortableHostObject.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToDevice.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/concepts.h"

namespace traits {

Expand Down
5 changes: 5 additions & 0 deletions DataFormats/PortableTestObjects/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="TrivialSerialisation.cc" name="DataFormatsPortableTestObjectsTrivialSerialisation">
<use name="DataFormats/PortableTestObjects"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
20 changes: 20 additions & 0 deletions DataFormats/PortableTestObjects/plugins/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "DataFormats/PortableTestObjects/interface/ImageHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/LogitsHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/MaskHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/MultiHeadNetHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/ParticleHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/SimpleNetHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/TestHostCollection.h"
#include "DataFormats/PortableTestObjects/interface/TestHostObject.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/SerialiserFactory.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::ImageHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::LogitsHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::MaskHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::MultiHeadNetHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::ParticleHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::SimpleNetHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::TestHostCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::TestHostMultiCollection2);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::TestHostMultiCollection3);
DEFINE_TRIVIAL_SERIALISER_PLUGIN(portabletest::TestHostObject);
Loading