Skip to content
Open
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
14 changes: 14 additions & 0 deletions DataFormats/CandidateSoA/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<use name="alpaka"/>
<use name="rootcore"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/Portable"/>
<use name="DataFormats/SoATemplate" source_only="1"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name="RecoLocalTracker/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="Geometry/Records"/>
<use name="FWCore/Utilities"/>
<flags ALPAKA_BACKENDS="!serial"/>
<export>
<lib name="1"/>
</export>
33 changes: 33 additions & 0 deletions DataFormats/CandidateSoA/interface/CandidatesDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DataFormats_CandidateSoA_interface_CandidatesDevice_h
#define DataFormats_CandidateSoA_interface_CandidatesDevice_h

#include <cstdint>
#include <alpaka/alpaka.hpp>

#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
#include "DataFormats/CandidateSoA/interface/CandidatesSoA.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

template <typename TDev>
class CandidatesDevice : public PortableDeviceCollection<CandidatesSoA, TDev> {
public:
CandidatesDevice(edm::Uninitialized) : PortableDeviceCollection<CandidatesSoA, TDev>{edm::kUninitialized} {}

template <typename TQueue>
explicit CandidatesDevice(size_t maxFedWords, TQueue queue)
: PortableDeviceCollection<CandidatesSoA, TDev>(maxFedWords + 1, queue) {}

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

void setNModules(uint32_t nModules) { nModules_h = nModules; }

uint32_t nModules() const { return nModules_h; }
uint32_t nDigis() const { return this->view().metadata().size() - 1; }

private:
uint32_t nModules_h = 0;
Comment on lines +24 to +30

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Credo tutto questo si possa togliere.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assolutamente scusa, era legacy (anche nel geoCluster)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E figurati, sto semplificando la CanidateSoA (Host,Device,Collection).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grazie!

};

#endif // DataFormats_CandidateSoA_interface_CandidatesDevice_h
24 changes: 24 additions & 0 deletions DataFormats/CandidateSoA/interface/CandidatesHost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef DataFormats_CandidateSoA_interface_CandidatesHost_h
#define DataFormats_CandidateSoA_interface_CandidatesHost_h

#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "DataFormats/CandidateSoA/interface/CandidatesSoA.h"

class CandidatesHost : public PortableHostCollection<CandidatesSoA> {
public:
CandidatesHost(edm::Uninitialized) : PortableHostCollection<CandidatesSoA>{edm::kUninitialized} {}

template <typename TQueue>
explicit CandidatesHost(size_t maxFedWords, TQueue queue)
: PortableHostCollection<CandidatesSoA>(maxFedWords + 1, queue) {}

void setNModules(uint32_t nModules) { nModules_h = nModules; }

uint32_t nModules() const { return nModules_h; }
uint32_t nDigis() const { return view().metadata().size() - 1; }

private:
uint32_t nModules_h = 0;
};

#endif // DataFormats_CandidateSoA_interface_CandidatesHost_h
19 changes: 19 additions & 0 deletions DataFormats/CandidateSoA/interface/CandidatesSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef DataFormats_CandidateSoA_interface_CandidatesSoA_h
#define DataFormats_CandidateSoA_interface_CandidatesSoA_h

#include "DataFormats/SoATemplate/interface/SoALayout.h"

GENERATE_SOA_LAYOUT(CandidatesLayout,
SOA_COLUMN(uint32_t, candidateIndex),
SOA_COLUMN(float, px),
SOA_COLUMN(float, py),
SOA_COLUMN(float, pz),
SOA_COLUMN(float, pt),
SOA_COLUMN(float, eta),
SOA_COLUMN(float, phi))

using CandidatesSoA = CandidatesLayout<>;
using CandidatesSoAView = CandidatesSoA::View;
using CandidatesSoAConstView = CandidatesSoA::ConstView;

#endif // DataFormats_CandidateSoA_interface_CandidatesSoA_h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef DataFormats_CandidateSoA_interface_alpaka_CandidatesSoACollection_h
#define DataFormats_CandidateSoA_interface_alpaka_CandidatesSoACollection_h

#include <cstdint>

#include <alpaka/alpaka.hpp>

#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/CandidateSoA/interface/CandidatesDevice.h"
#include "DataFormats/CandidateSoA/interface/CandidatesHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

using CandidatesSoACollection =
std::conditional_t<std::is_same_v<Device, alpaka::DevCpu>, CandidatesHost, CandidatesDevice<Device>>;

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

namespace cms::alpakatools {
template <typename TDevice>
struct CopyToHost<CandidatesDevice<TDevice>> {
template <typename TQueue>
static auto copyAsync(TQueue &queue, CandidatesDevice<TDevice> const &srcData) {
CandidatesHost dstData(srcData.view().metadata().size() - 1, queue);
alpaka::memcpy(queue, dstData.buffer(), srcData.buffer());
dstData.setNModules(srcData.nModules());
return dstData;
}
};
} // namespace cms::alpakatools

ASSERT_DEVICE_MATCHES_HOST_COLLECTION(CandidatesSoACollection, CandidatesHost);

#endif // DataFormats_CandidateSoA_interface_alpaka_CandidatesSoACollection_h
10 changes: 10 additions & 0 deletions DataFormats/CandidateSoA/src/alpaka/classes_cuda.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef DataFormats_CandidateSoA_Alpaka_Classes_cuda_h
#define DataFormats_CandidateSoA_Alpaka_Classes_cuda_h

#include "DataFormats/Common/interface/DeviceProduct.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/CandidateSoA/interface/CandidatesSoA.h"
#include "DataFormats/CandidateSoA/interface/alpaka/CandidatesSoACollection.h"

#endif // DataFormats_CandidateSoA_src_alpaka_classes_cuda_h
9 changes: 9 additions & 0 deletions DataFormats/CandidateSoA/src/alpaka/classes_cuda_def.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<lcgdict>
<!-- CandidatesSoA-related collections -->
<class name="alpaka_cuda_async::PortableCollection<CandidatesSoA>" persistent="false"/>
<!-- CandidatesSoACollection inherits from PortableCollection<CandidatesSoA> -->
<class name="alpaka_cuda_async::CandidatesSoACollection" persistent="false"/>
<class name="edm::DeviceProduct<alpaka_cuda_async::CandidatesSoACollection>" persistent="false"/>
<class name="edm::Wrapper<edm::DeviceProduct<alpaka_cuda_async::CandidatesSoACollection>>" persistent="false"/>

</lcgdict>
11 changes: 11 additions & 0 deletions DataFormats/CandidateSoA/src/alpaka/classes_rocm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef DataFormats_CandidateSoA_Alpaka_Classes_cuda_h
#define DataFormats_CandidateSoA_Alpaka_Classes_cuda_h

#include "DataFormats/Common/interface/DeviceProduct.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/CandidateSoA/interface/CandidatesDevice.h"
#include "DataFormats/CandidateSoA/interface/CandidatesSoA.h"
#include "DataFormats/CandidateSoA/interface/alpaka/CandidatesSoACollection.h"

#endif // DataFormats_CandidateSoA_src_alpaka_classes_cuda_h
9 changes: 9 additions & 0 deletions DataFormats/CandidateSoA/src/alpaka/classes_rocm_def.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<lcgdict>
<!-- CandidatesSoA-related collections -->
<class name="alpaka_rocm_async::PortableCollection<CandidatesSoA>" persistent="false"/>
<!-- CandidatesSoACollection inherits from PortableCollection<CandidatesSoA> -->
<class name="alpaka_rocm_async::CandidatesSoACollection" persistent="false"/>
<class name="edm::DeviceProduct<alpaka_rocm_async::CandidatesSoACollection>" persistent="false"/>
<class name="edm::Wrapper<edm::DeviceProduct<alpaka_rocm_async::CandidatesSoACollection>>" persistent="false"/>

</lcgdict>
4 changes: 4 additions & 0 deletions DataFormats/CandidateSoA/src/classes.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DataFormats/Portable/interface/PortableHostCollectionReadRules.h"
#include "DataFormats/CandidateSoA/interface/CandidatesSoA.h"

SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection<CandidatesSoA>);
8 changes: 8 additions & 0 deletions DataFormats/CandidateSoA/src/classes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef DataFormats_CandidatesSoA_src_classes_h
#define DataFormats_CandidatesSoA_src_classes_h

#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/CandidateSoA/interface/CandidatesHost.h"
#include "DataFormats/CandidateSoA/interface/CandidatesSoA.h"

#endif // DataFormats_SiPixelClusterSoA_src_classes_h
7 changes: 7 additions & 0 deletions DataFormats/CandidateSoA/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<lcgdict>
<class name="CandidatesSoA"/>
<class name="CandidatesSoA::View"/>
<class name="PortableHostCollection<CandidatesSoA>"/>
<class name="CandidatesHost"/>
<class name="edm::Wrapper<CandidatesHost>" splitLevel="0"/>
</lcgdict>
13 changes: 13 additions & 0 deletions DataFormats/ClusterGeometrySoA/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<use name="alpaka"/>
<use name="rootcore"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/Portable"/>
<use name="DataFormats/SoATemplate" source_only="1"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name="RecoLocalTracker/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="Geometry/Records"/>
<flags ALPAKA_BACKENDS="!serial"/>
<export>
<lib name="1"/>
</export>
35 changes: 35 additions & 0 deletions DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysDevice_h
#define DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysDevice_h

#include <cstdint>

#include <alpaka/alpaka.hpp>

#include "DataFormats/Portable/interface/PortableDeviceCollection.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysSoA.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

template <typename TDev>
class ClusterGeometrysDevice : public PortableDeviceCollection<ClusterGeometrysSoA, TDev> {
public:
ClusterGeometrysDevice(edm::Uninitialized)
: PortableDeviceCollection<ClusterGeometrysSoA, TDev>{edm::kUninitialized} {}

template <typename TQueue>
explicit ClusterGeometrysDevice(size_t maxFedWords, TQueue queue)
: PortableDeviceCollection<ClusterGeometrysSoA, TDev>(maxFedWords + 1, queue) {}

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

void setNModules(uint32_t nModules) { nModules_h = nModules; }

uint32_t nModules() const { return nModules_h; }
uint32_t nDigis() const { return this->view().metadata().size() - 1; }

private:
uint32_t nModules_h = 0;
};

#endif // DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysDevice_h
27 changes: 27 additions & 0 deletions DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysHost.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysHost_h
#define DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysHost_h

#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysSoA.h"

// TODO: The class is created via inheritance of the PortableDeviceCollection.
// This is generally discouraged, and should be done via composition.
// See: https://github.com/cms-sw/cmssw/pull/40465#discussion_r1067364306
class ClusterGeometrysHost : public PortableHostCollection<ClusterGeometrysSoA> {
public:
ClusterGeometrysHost(edm::Uninitialized) : PortableHostCollection<ClusterGeometrysSoA>{edm::kUninitialized} {}

template <typename TQueue>
explicit ClusterGeometrysHost(size_t maxFedWords, TQueue queue)
: PortableHostCollection<ClusterGeometrysSoA>(maxFedWords + 1, queue) {}

void setNModules(uint32_t nModules) { nModules_h = nModules; }

uint32_t nModules() const { return nModules_h; }
uint32_t nDigis() const { return view().metadata().size() - 1; }

private:
uint32_t nModules_h = 0;
};

#endif // DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysHost_h
33 changes: 33 additions & 0 deletions DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysSoA_h
#define DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysSoA_h

#include "DataFormats/SoATemplate/interface/SoALayout.h"

GENERATE_SOA_LAYOUT(ClusterGeometrysLayout,
SOA_COLUMN(uint32_t, clusterIds),
SOA_COLUMN(float, pitchX),
SOA_COLUMN(float, pitchY),
SOA_COLUMN(float, thickness),
SOA_COLUMN(float, tanLorentzAngles),
SOA_COLUMN(float, transformXX),
SOA_COLUMN(float, transformXY),
SOA_COLUMN(float, transformXZ),
SOA_COLUMN(float, transformYX),
SOA_COLUMN(float, transformYY),
SOA_COLUMN(float, transformYZ),
SOA_COLUMN(float, transformZX),
SOA_COLUMN(float, transformZY),
SOA_COLUMN(float, transformZZ),
SOA_COLUMN(float, x),
SOA_COLUMN(float, y),
SOA_COLUMN(float, z),
SOA_COLUMN(uint32_t, sizeX),
SOA_COLUMN(uint32_t, sizeY),
SOA_COLUMN(uint32_t, clusterOffset),
SOA_COLUMN(uint32_t, moduleId))

using ClusterGeometrysSoA = ClusterGeometrysLayout<>;
using ClusterGeometrysSoAView = ClusterGeometrysSoA::View;
using ClusterGeometrysSoAConstView = ClusterGeometrysSoA::ConstView;

#endif // DataFormats_ClusterGeometrySoA_interface_ClusterGeometrysSoA_h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef DataFormats_ClusterGeometrySoA_interface_alpaka_ClusterGeometrysSoACollection_h
#define DataFormats_ClusterGeometrySoA_interface_alpaka_ClusterGeometrysSoACollection_h

#include <cstdint>

#include <alpaka/alpaka.hpp>

#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysDevice.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

using ClusterGeometrysSoACollection =
std::conditional_t<std::is_same_v<Device, alpaka::DevCpu>, ClusterGeometrysHost, ClusterGeometrysDevice<Device>>;

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

namespace cms::alpakatools {
template <typename TDevice>
struct CopyToHost<ClusterGeometrysDevice<TDevice>> {
template <typename TQueue>
static auto copyAsync(TQueue &queue, ClusterGeometrysDevice<TDevice> const &srcData) {
ClusterGeometrysHost dstData(srcData.view().metadata().size() - 1, queue);
alpaka::memcpy(queue, dstData.buffer(), srcData.buffer());
dstData.setNModules(srcData.nModules());
return dstData;
}
};
} // namespace cms::alpakatools

ASSERT_DEVICE_MATCHES_HOST_COLLECTION(ClusterGeometrysSoACollection, ClusterGeometrysHost);

#endif // DataFormats_ClusterGeometrySoA_interface_alpaka_ClusterGeometrysSoACollection_h
10 changes: 10 additions & 0 deletions DataFormats/ClusterGeometrySoA/src/alpaka/classes_cuda.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef DataFormats_ClusterGeometrySoA_Alpaka_Classes_cuda_h
#define DataFormats_ClusterGeometrySoA_Alpaka_Classes_cuda_h

#include "DataFormats/Common/interface/DeviceProduct.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysSoA.h"
#include "DataFormats/ClusterGeometrySoA/interface/alpaka/ClusterGeometrysSoACollection.h"

#endif // DataFormats_ClusterGeometrySoA_src_alpaka_classes_cuda_h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<lcgdict>
<!-- ClusterGeometrysSoA-related collections -->
<class name="alpaka_cuda_async::PortableCollection<ClusterGeometrysSoA>" persistent="false"/>
<!-- ClusterGeometrysSoACollection inherits from PortableCollection<ClusterGeometrysSoA> -->
<class name="alpaka_cuda_async::ClusterGeometrysSoACollection" persistent="false"/>
<class name="edm::DeviceProduct<alpaka_cuda_async::ClusterGeometrysSoACollection>" persistent="false"/>
<class name="edm::Wrapper<edm::DeviceProduct<alpaka_cuda_async::ClusterGeometrysSoACollection>>" persistent="false"/>

</lcgdict>
11 changes: 11 additions & 0 deletions DataFormats/ClusterGeometrySoA/src/alpaka/classes_rocm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef DataFormats_ClusterGeometrySoA_Alpaka_Classes_cuda_h
#define DataFormats_ClusterGeometrySoA_Alpaka_Classes_cuda_h

#include "DataFormats/Common/interface/DeviceProduct.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysDevice.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysSoA.h"
#include "DataFormats/ClusterGeometrySoA/interface/alpaka/ClusterGeometrysSoACollection.h"

#endif // DataFormats_ClusterGeometrySoA_src_alpaka_classes_cuda_h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<lcgdict>
<!-- ClusterGeometrysSoA-related collections -->
<class name="alpaka_rocm_async::PortableCollection<ClusterGeometrysSoA>" persistent="false"/>
<!-- ClusterGeometrysSoACollection inherits from PortableCollection<ClusterGeometrysSoA> -->
<class name="alpaka_rocm_async::ClusterGeometrysSoACollection" persistent="false"/>
<class name="edm::DeviceProduct<alpaka_rocm_async::ClusterGeometrysSoACollection>" persistent="false"/>
<class name="edm::Wrapper<edm::DeviceProduct<alpaka_rocm_async::ClusterGeometrysSoACollection>>" persistent="false"/>

</lcgdict>
4 changes: 4 additions & 0 deletions DataFormats/ClusterGeometrySoA/src/classes.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "DataFormats/Portable/interface/PortableHostCollectionReadRules.h"
#include "DataFormats/ClusterGeometrySoA/interface/ClusterGeometrysSoA.h"

SET_PORTABLEHOSTCOLLECTION_READ_RULES(PortableHostCollection<ClusterGeometrysSoA>);
Loading