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
7 changes: 7 additions & 0 deletions DataFormats/BeamSpot/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsBeamSpotTrivialSerialisationPortable">
<use name="DataFormats/BeamSpot"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
4 changes: 4 additions & 0 deletions DataFormats/BeamSpot/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DataFormats/BeamSpot/interface/alpaka/BeamSpotDevice.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(BeamSpotDevice);
7 changes: 7 additions & 0 deletions DataFormats/EcalDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsEcalDigiTrivialSerialisationPortable">
<use name="DataFormats/EcalDigi"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
6 changes: 6 additions & 0 deletions DataFormats/EcalDigi/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "DataFormats/EcalDigi/interface/alpaka/EcalDigiDeviceCollection.h"
#include "DataFormats/EcalDigi/interface/alpaka/EcalDigiPhase2DeviceCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(EcalDigiDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(EcalDigiPhase2DeviceCollection);
6 changes: 6 additions & 0 deletions DataFormats/EcalRecHit/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>
<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsEcalRecHitTrivialSerialisationPortable">
<use name="DataFormats/EcalRecHit"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
6 changes: 6 additions & 0 deletions DataFormats/EcalRecHit/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "DataFormats/EcalRecHit/interface/alpaka/EcalRecHitDeviceCollection.h"
#include "DataFormats/EcalRecHit/interface/alpaka/EcalUncalibratedRecHitDeviceCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(EcalRecHitDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(EcalUncalibratedRecHitDeviceCollection);
7 changes: 7 additions & 0 deletions DataFormats/HGCalDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsHGCalDigiTrivialSerialisationPortable">
<use name="DataFormats/HGCalDigi"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
8 changes: 8 additions & 0 deletions DataFormats/HGCalDigi/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "DataFormats/HGCalDigi/interface/alpaka/HGCalDigiDevice.h"
#include "DataFormats/HGCalDigi/interface/alpaka/HGCalECONDPacketInfoDevice.h"
#include "DataFormats/HGCalDigi/interface/alpaka/HGCalFEDPacketInfoDevice.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(hgcaldigi::HGCalDigiDevice);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(hgcaldigi::HGCalECONDPacketInfoDevice);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(hgcaldigi::HGCalFEDPacketInfoDevice);
7 changes: 7 additions & 0 deletions DataFormats/HGCalReco/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsHGCalRecoTrivialSerialisationPortable">
<use name="DataFormats/HGCalReco"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
8 changes: 8 additions & 0 deletions DataFormats/HGCalReco/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "DataFormats/HGCalReco/interface/alpaka/HGCalSoAClustersDeviceCollection.h"
#include "DataFormats/HGCalReco/interface/alpaka/HGCalSoARecHitsExtraDeviceCollection.h"
#include "DataFormats/HGCalReco/interface/alpaka/HGCalSoARecHitsDeviceCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(HGCalSoAClustersDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(HGCalSoARecHitsExtraDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(HGCalSoARecHitsDeviceCollection);
7 changes: 7 additions & 0 deletions DataFormats/HcalDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsHcalDigiTrivialSerialisationPortable">
<use name="DataFormats/HcalDigi"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
5 changes: 5 additions & 0 deletions DataFormats/HcalDigi/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "DataFormats/HcalDigi/interface/alpaka/HcalDigiDeviceCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(hcal::Phase0DigiDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(hcal::Phase1DigiDeviceCollection);
7 changes: 7 additions & 0 deletions DataFormats/HcalRecHit/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsHcalRecHitTrivialSerialisationPortable">
<use name="DataFormats/HcalRecHit"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
4 changes: 4 additions & 0 deletions DataFormats/HcalRecHit/plugins/alpaka/TrivialSerialisation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DataFormats/HcalRecHit/interface/alpaka/HcalRecHitDeviceCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(hcal::RecHitDeviceCollection);
7 changes: 7 additions & 0 deletions DataFormats/ParticleFlowReco/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/TrivialSerialisation.cc" name="DataFormatsParticleFlowRecoTrivialSerialisationPortable">
<use name="DataFormats/ParticleFlowReco"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
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/alpaka/CaloRecHitDeviceCollection.h"
#include "DataFormats/ParticleFlowReco/interface/alpaka/PFClusterDeviceCollection.h"
#include "DataFormats/ParticleFlowReco/interface/alpaka/PFRecHitFractionDeviceCollection.h"
#include "DataFormats/ParticleFlowReco/interface/alpaka/PFRecHitDeviceCollection.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(reco::CaloRecHitDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(reco::PFClusterDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(reco::PFRecHitFractionDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(reco::PFRecHitDeviceCollection);
35 changes: 35 additions & 0 deletions DataFormats/Portable/interface/PortableDeviceCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#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/memory.h"

Expand Down Expand Up @@ -146,4 +147,38 @@ class PortableDeviceCollection {
View view_; //!
};

namespace ngt {

// Specialize MemoryCopyTraits for PortableDeviceCollection
template <typename T, typename TDev>
struct MemoryCopyTraits<PortableDeviceCollection<T, TDev>> {
using value_type = PortableDeviceCollection<T, TDev>;

// Properties are the collection size: T::size_type, or std::array<T::size_type, N> for SoABlocks.
using Properties = decltype(std::declval<value_type>()->metadata().size());

static Properties properties(value_type const& object) { return object->metadata().size(); }

template <typename TQueue>
requires(alpaka::isQueue<TQueue>)
static void initialize(TQueue& queue, value_type& object, Properties const& size) {
// Replace the default-constructed empty object with one where the buffer
// has been allocated in global device memory
object = value_type(queue, size);
}

static std::vector<std::span<std::byte>> regions(value_type& object) {
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) {
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_PortableDeviceCollection_h
25 changes: 25 additions & 0 deletions DataFormats/Portable/interface/PortableDeviceObject.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/memory.h"

Expand Down Expand Up @@ -80,4 +81,28 @@ class PortableDeviceObject {
std::optional<Buffer> buffer_;
};

namespace ngt {

// Specialize MemoryCopyTraits for PortableDeviceObject
template <typename TDev, typename T>
struct MemoryCopyTraits<PortableDeviceObject<TDev, T>> {
template <typename TQueue>
requires(alpaka::isQueue<TQueue>)
static void initialize(TQueue& queue, PortableDeviceObject<TDev, T>& object) {
// Replace the default-constructed empty object with one where the
// buffer has been allocated in global device memory
object = PortableDeviceObject<TDev, T>(queue);
}

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

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

} // namespace ngt

#endif // DataFormats_Portable_interface_PortableDeviceObject_h
11 changes: 10 additions & 1 deletion DataFormats/Portable/interface/PortableHostCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,17 @@ namespace ngt {
// The properties needed to initialize a new PrortableHostCollection are just its size.
static Properties properties(value_type const& object) { return object->metadata().size(); }

// Replace the default-constructed empty object with one where the buffer has been allocated in pageable system memory.
template <typename TQueue>
requires(alpaka::isQueue<TQueue>)
static void initialize(TQueue& queue, value_type& object, Properties const& size) {
// Replace the default-constructed empty object with one where the buffer
// has been allocated in pinned host memory.
object = value_type(queue, 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 host memory.
object = value_type(cms::alpakatools::host(), size);
}

Expand Down
14 changes: 12 additions & 2 deletions DataFormats/Portable/interface/PortableHostObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,21 @@ 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.
// This specialisation requires an initialize() method, but does not need to
// pass any parameters to it.
using Properties = void;

template <typename TQueue>
requires(alpaka::isQueue<TQueue>)
static void initialize(TQueue& queue, PortableHostObject<T>& object) {
// Replace the default-constructed empty object with one where the buffer
// has been allocated in pinned host memory
object = PortableHostObject<T>(queue);
}

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

Expand Down
7 changes: 7 additions & 0 deletions DataFormats/PortableTestObjects/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags EDM_PLUGIN="1"/>
</library>

<library file="alpaka/*.cc" name="DataFormatsPortableTestObjectsPluginsAlpaka">
<use name="DataFormats/PortableTestObjects"/>
<use name="HeterogeneousCore/TrivialSerialisation"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "DataFormats/PortableTestObjects/interface/alpaka/ImageDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/LogitsDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/MaskDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/MultiHeadNetDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/ParticleDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/SimpleNetDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h"
#include "DataFormats/PortableTestObjects/interface/alpaka/TestDeviceObject.h"
#include "HeterogeneousCore/TrivialSerialisation/interface/alpaka/SerialiserFactoryDevice.h"

DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::ImageDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::LogitsDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::MaskDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::MultiHeadNetDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::ParticleDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::SimpleNetDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::TestDeviceCollection);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::TestDeviceCollection2);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::TestDeviceCollection3);
DEFINE_TRIVIAL_SERIALISER_PLUGIN_DEVICE(portabletest::TestDeviceObject);
46 changes: 44 additions & 2 deletions DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h"
#include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersSoA.h"
#include "DataFormats/TrivialSerialisation/interface/MemoryCopyTraits.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

Expand All @@ -18,11 +19,11 @@ class SiPixelClustersDevice : public PortableDeviceCollection<TDev, SiPixelClust
SiPixelClustersDevice(edm::Uninitialized) : PortableDeviceCollection<TDev, SiPixelClustersSoA>{edm::kUninitialized} {}

template <typename TQueue>
explicit SiPixelClustersDevice(size_t maxModules, TQueue queue)
explicit SiPixelClustersDevice(TQueue queue, size_t maxModules)
: PortableDeviceCollection<TDev, SiPixelClustersSoA>(queue, maxModules + 1) {}

// Constructor which specifies the SoA size
explicit SiPixelClustersDevice(size_t maxModules, TDev const &device)
explicit SiPixelClustersDevice(TDev const& device, size_t maxModules)
: PortableDeviceCollection<TDev, SiPixelClustersSoA>(device, maxModules + 1) {}

void setNClusters(uint32_t nClusters, int32_t offsetBPIX2) {
Expand All @@ -38,4 +39,45 @@ class SiPixelClustersDevice : public PortableDeviceCollection<TDev, SiPixelClust
int32_t offsetBPIX2_h = 0;
};

namespace ngt {

// Specialize MemoryCopyTraits for SiPixelClustersDevice
template <typename TDev>
struct MemoryCopyTraits<SiPixelClustersDevice<TDev>> {
using value_type = SiPixelClustersDevice<TDev>;

struct Properties {
int size;
uint32_t nClusters;
int32_t offsetBPIX2;
};

static Properties properties(value_type const& object) {
return {object->metadata().size() - 1, object.nClusters(), object.offsetBPIX2()};
}

template <typename TQueue>
requires(alpaka::isQueue<TQueue>)
static void initialize(TQueue& queue, value_type& object, Properties const& prop) {
// Replace the default-constructed empty object with one where the buffer
// has been allocated in device global memory.
object = value_type(queue, prop.size);
object.setNClusters(prop.nClusters, prop.offsetBPIX2);
}

static std::vector<std::span<std::byte>> regions(value_type& object) {
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) {
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_SiPixelClusterSoA_interface_SiPixelClustersDevice_h
Loading