Skip to content

Commit

Permalink
Merge pull request #93 from SegmentLinking/segments_soa
Browse files Browse the repository at this point in the history
Migrate segments to SoA+PortableCollection
  • Loading branch information
slava77 authored Oct 18, 2024
2 parents fc3fc6a + 0e0b5e1 commit cb84b9c
Show file tree
Hide file tree
Showing 17 changed files with 557 additions and 574 deletions.
12 changes: 12 additions & 0 deletions RecoTracker/LSTCore/interface/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,25 @@ namespace lst {
typedef float FPX;
#endif

// Needed for files that are compiled by g++ to not throw an error.
// uint4 is defined only for CUDA, so we will have to revisit this soon when running on other backends.
#if !defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && !defined(ALPAKA_ACC_GPU_HIP_ENABLED)
struct uint4 {
unsigned int x;
unsigned int y;
unsigned int z;
unsigned int w;
};
#endif

// Defining the constant host device variables right up here
// Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future.
struct Params_pLS {
static constexpr int kLayers = 2, kHits = 4;
};
struct Params_LS {
static constexpr int kLayers = 2, kHits = 4;
using ArrayUxLayers = edm::StdArray<unsigned int, kLayers>;
};
struct Params_T3 {
static constexpr int kLayers = 3, kHits = 6;
Expand Down
67 changes: 67 additions & 0 deletions RecoTracker/LSTCore/interface/SegmentsSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef RecoTracker_LSTCore_interface_SegmentsSoA_h
#define RecoTracker_LSTCore_interface_SegmentsSoA_h

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

#include "RecoTracker/LSTCore/interface/Constants.h"

namespace lst {

GENERATE_SOA_LAYOUT(SegmentsSoALayout,
SOA_COLUMN(FPX, dPhis),
SOA_COLUMN(FPX, dPhiMins),
SOA_COLUMN(FPX, dPhiMaxs),
SOA_COLUMN(FPX, dPhiChanges),
SOA_COLUMN(FPX, dPhiChangeMins),
SOA_COLUMN(FPX, dPhiChangeMaxs),
SOA_COLUMN(uint16_t, innerLowerModuleIndices),
SOA_COLUMN(uint16_t, outerLowerModuleIndices),
SOA_COLUMN(Params_LS::ArrayUxLayers, mdIndices),
SOA_COLUMN(unsigned int, innerMiniDoubletAnchorHitIndices),
SOA_COLUMN(unsigned int, outerMiniDoubletAnchorHitIndices)
//SOA_SCALAR(unsigned int, nMemoryLocations)
)

GENERATE_SOA_LAYOUT(SegmentsOccupancySoALayout,
SOA_COLUMN(unsigned int, nSegments), //number of segments per inner lower module
SOA_COLUMN(unsigned int, totOccupancySegments))

GENERATE_SOA_LAYOUT(SegmentsPixelSoALayout,
SOA_COLUMN(unsigned int, seedIdx),
SOA_COLUMN(int, charge),
SOA_COLUMN(int, superbin),
SOA_COLUMN(uint4, pLSHitsIdxs),
SOA_COLUMN(PixelType, pixelType),
SOA_COLUMN(char, isQuad),
SOA_COLUMN(char, isDup),
SOA_COLUMN(bool, partOfPT5),
SOA_COLUMN(float, ptIn),
SOA_COLUMN(float, ptErr),
SOA_COLUMN(float, px),
SOA_COLUMN(float, py),
SOA_COLUMN(float, pz),
SOA_COLUMN(float, etaErr),
SOA_COLUMN(float, eta),
SOA_COLUMN(float, phi),
SOA_COLUMN(float, score),
SOA_COLUMN(float, circleCenterX),
SOA_COLUMN(float, circleCenterY),
SOA_COLUMN(float, circleRadius))

using SegmentsSoA = SegmentsSoALayout<>;
using SegmentsOccupancySoA = SegmentsOccupancySoALayout<>;
using SegmentsPixelSoA = SegmentsPixelSoALayout<>;

using Segments = SegmentsSoA::View;
using SegmentsConst = SegmentsSoA::ConstView;
using SegmentsOccupancy = SegmentsOccupancySoA::View;
using SegmentsOccupancyConst = SegmentsOccupancySoA::ConstView;
using SegmentsPixel = SegmentsPixelSoA::View;
using SegmentsPixelConst = SegmentsPixelSoA::ConstView;

using SegmentsHostCollection = PortableHostMultiCollection<SegmentsSoA, SegmentsOccupancySoA, SegmentsPixelSoA>;

} // namespace lst

#endif
11 changes: 0 additions & 11 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

Vec3D constexpr elementsPerThread(Vec3D::all(static_cast<Idx>(1)));

// Needed for files that are compiled by g++ to not throw an error.
// uint4 is defined only for CUDA, so we will have to revisit this soon when running on other backends.
#if !defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && !defined(ALPAKA_ACC_GPU_HIP_ENABLED)
struct uint4 {
unsigned int x;
unsigned int y;
unsigned int z;
unsigned int w;
};
#endif

// Adjust grid and block sizes based on backend configuration
template <typename Vec, typename TAcc = Acc<typename Vec::Dim>>
ALPAKA_FN_HOST ALPAKA_FN_INLINE WorkDiv<typename Vec::Dim> createWorkDiv(const Vec& blocksPerGrid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RecoTracker_LSTCore_interface_alpaka_MiniDoubletsSoA_h
#define RecoTracker_LSTCore_interface_alpaka_MiniDoubletsSoA_h
#ifndef RecoTracker_LSTCore_interface_alpaka_MiniDoubletsDeviceCollection_h
#define RecoTracker_LSTCore_interface_alpaka_MiniDoubletsDeviceCollection_h

#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"

Expand Down
12 changes: 12 additions & 0 deletions RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef RecoTracker_LSTCore_interface_alpaka_SegmentsDeviceCollection_h
#define RecoTracker_LSTCore_interface_alpaka_SegmentsDeviceCollection_h

#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"

#include "RecoTracker/LSTCore/interface/SegmentsSoA.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
using SegmentsDeviceCollection = PortableCollection3<SegmentsSoA, SegmentsOccupancySoA, SegmentsPixelSoA>;
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst

#endif
Loading

0 comments on commit cb84b9c

Please sign in to comment.