Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to SoATemplate #109

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d764312
Merge tag 'CMSSW_14_2_0_pre1' into CMSSW_14_1_0_pre3_LST_X_LSTCore_re…
ariostas Sep 16, 2024
f68981e
Updated setup script to CMSSW_14_2_0_pre1
ariostas Sep 16, 2024
d5da756
Moved segments to SoA+PortableCollection
ariostas Sep 18, 2024
a7e3ec3
Fixed standalone compilation
ariostas Sep 18, 2024
acff43f
Switched to only using views
ariostas Sep 20, 2024
37fe122
Fixed indexing issues
ariostas Sep 23, 2024
77ff0e5
Fixed memset
ariostas Sep 23, 2024
9e2a402
Format code
ariostas Sep 23, 2024
3858cf3
Fixed cxxopts compilation
ariostas Sep 23, 2024
96be4f7
Initialize only required columns
ariostas Sep 25, 2024
94df11b
migrate TrackCandidate to SoA from DataFormats/SoATemplate: kernels i…
slava77devel Aug 29, 2024
18a1f6e
drop -Wshadow in standalone builds: DataFormats/SoATemplate and relat…
slava77devel Aug 29, 2024
3e98eb4
code checks
slava77devel Aug 29, 2024
a5822d0
add a check that device and host match for host=device
slava77devel Aug 29, 2024
8864fd1
sync DALPAKA flags in standalone builds with cmsdist scram-tools.file…
slava77devel Aug 29, 2024
af1f68f
code checks
slava77devel Aug 29, 2024
155fc82
switch to TrackCandidates = ::lst::TrackCandidatesSoA::View
slava77devel Aug 29, 2024
20f6f9c
Migrated MDs to SoA+PortableCollection
ariostas Sep 30, 2024
52377d1
Fixed makefile
ariostas Oct 1, 2024
a296da7
get rid of TrackCandidates* trackCandidatesD_ and simplify syntax
slava77devel Oct 1, 2024
efef777
Removed unnecessary CopyToHost
ariostas Oct 4, 2024
f430d1b
Formatted and removed unnecessary CopyToHost
ariostas Oct 4, 2024
69804f0
move TrackCandidatesDeviceCollection and related aliases to interface…
slava77devel Oct 4, 2024
8338254
Merge pull request #90 from slava77/CMSSW_14_1_0_pre5/LSTb6-SoA-TCs
ariostas Oct 8, 2024
8fba6cb
Merge branch 'CMSSW_14_1_0_pre3_LST_X_LSTCore_realfiles_batch7' into …
ariostas Oct 10, 2024
129a2d4
Adjusted naming convention
ariostas Oct 10, 2024
66612e8
Moved MD SoA definition to its own header
ariostas Oct 10, 2024
3b4fa9e
Made view sizes clearer
ariostas Oct 10, 2024
36a8c43
Moved MiniDoubletsDeviceCollection definition
ariostas Oct 14, 2024
d3156d1
Fixed formatting
ariostas Oct 16, 2024
fc3fc6a
Merge pull request #101 from SegmentLinking/mds_soa
slava77 Oct 16, 2024
6b37c07
Merge branch 'CMSSW_14_1_0_pre3_LST_X_LSTCore_realfiles_batch7' into …
ariostas Oct 16, 2024
0e0b5e1
Match conventions from previous PRs
ariostas Oct 16, 2024
cb84b9c
Merge pull request #93 from SegmentLinking/segments_soa
slava77 Oct 18, 2024
6f1ea3f
simplify a bit TC SoAs
slava77devel Oct 10, 2024
1bbe663
migrate triplets to SoATemplate
slava77devel Oct 22, 2024
fd99b50
Made view sizes clearer
ariostas Oct 22, 2024
9b8d26d
migrate quintuplets to SoATemplate
slava77devel Oct 22, 2024
534ac1b
migrate ranges to SoATemplate
ariostas Oct 24, 2024
018204d
migrate hits to SoATemplate
ariostas Oct 24, 2024
5e2bf7b
migrate EndcapGeometry to SoATemplate
ariostas Oct 24, 2024
00013dd
migrate pT3 and pT5 to SoATemplate
slava77devel Oct 24, 2024
ccc4bf4
Merge pull request #104 from slava77/CMSSW_14_2_0_pre1/LSTb7-SoA-TC-T5
ariostas Oct 25, 2024
043dfe0
migrate modules to SoATemplate
ariostas Oct 25, 2024
891a97d
Merge branch 'CMSSW_14_1_0_pre3_LST_X_LSTCore_realfiles_batch7' into …
ariostas Oct 25, 2024
d08032a
Consistency fixes
ariostas Oct 25, 2024
48d01f3
Review fixes
ariostas Oct 28, 2024
f8e7884
Merge pull request #106 from SegmentLinking/more_soa_migrations
slava77 Oct 28, 2024
cb1557e
Merge branch 'CMSSW_14_1_0_pre3_LST_X_LSTCore_realfiles_batch7' into …
slava77devel Oct 28, 2024
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
1 change: 0 additions & 1 deletion RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// LST includes
#include "RecoTracker/LSTCore/interface/Module.h"
#include "RecoTracker/LSTCore/interface/alpaka/LST.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down
50 changes: 50 additions & 0 deletions RecoTracker/LSTCore/interface/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
#define RecoTracker_LSTCore_interface_Constants_h

#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "DataFormats/Common/interface/StdArray.h"

#if defined(FP16_Base)
#if defined ALPAKA_ACC_GPU_CUDA_ENABLED
#include <cuda_fp16.h>
#elif defined ALPAKA_ACC_GPU_HIP_ENABLED
#include <hip/hip_fp16.h>
#endif
#endif

#ifdef CACHE_ALLOC
#include "HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h"
Expand Down Expand Up @@ -55,27 +64,68 @@ namespace lst {

constexpr unsigned int size_superbins = 45000;

// Half precision wrapper functions.
#if defined(FP16_Base)
#define __F2H __float2half
#define __H2F __half2float
typedef __half float FPX;
#else
#define __F2H
#define __H2F
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_Modules {
using ArrayU16xMaxConnected = edm::StdArray<uint16_t, max_connected_modules>;
};
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;
using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};
struct Params_pT3 {
static constexpr int kLayers = 5, kHits = 10;
using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};
struct Params_T5 {
static constexpr int kLayers = 5, kHits = 10;
using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};
struct Params_pT5 {
static constexpr int kLayers = 7, kHits = 14;
using ArrayU8xLayers = edm::StdArray<uint8_t, kLayers>;
using ArrayU16xLayers = edm::StdArray<uint16_t, kLayers>;
using ArrayUxHits = edm::StdArray<unsigned int, kHits>;
};

using ArrayIx2 = edm::StdArray<int, 2>;
using ArrayUx2 = edm::StdArray<unsigned int, 2>;

} //namespace lst

#endif
58 changes: 0 additions & 58 deletions RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h

This file was deleted.

10 changes: 10 additions & 0 deletions RecoTracker/LSTCore/interface/EndcapGeometryDevHostCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef RecoTracker_LSTCore_interface_EndcapGeometryDevHostCollection_h
#define RecoTracker_LSTCore_interface_EndcapGeometryDevHostCollection_h

#include "RecoTracker/LSTCore/interface/EndcapGeometryDevSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace lst {
using EndcapGeometryDevHostCollection = PortableHostCollection<EndcapGeometryDevSoA>;
} // namespace lst
#endif
18 changes: 18 additions & 0 deletions RecoTracker/LSTCore/interface/EndcapGeometryDevSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef RecoTracker_LSTCore_interface_EndcapGeometryDevSoA_h
#define RecoTracker_LSTCore_interface_EndcapGeometryDevSoA_h

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

namespace lst {

GENERATE_SOA_LAYOUT(EndcapGeometryDevSoALayout, SOA_COLUMN(unsigned int, geoMapDetId), SOA_COLUMN(float, geoMapPhi))

using EndcapGeometryDevSoA = EndcapGeometryDevSoALayout<>;

using EndcapGeometryDev = EndcapGeometryDevSoA::View;
using EndcapGeometryDevConst = EndcapGeometryDevSoA::ConstView;

} // namespace lst

#endif
10 changes: 10 additions & 0 deletions RecoTracker/LSTCore/interface/HitsHostCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef RecoTracker_LSTCore_interface_HitsHostCollection_h
#define RecoTracker_LSTCore_interface_HitsHostCollection_h

#include "RecoTracker/LSTCore/interface/HitsSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace lst {
using HitsHostCollection = PortableHostMultiCollection<HitsSoA, HitsRangesSoA>;
} // namespace lst
#endif
43 changes: 43 additions & 0 deletions RecoTracker/LSTCore/interface/HitsSoA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef RecoTracker_LSTCore_interface_HitsSoA_h
#define RecoTracker_LSTCore_interface_HitsSoA_h

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

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

namespace lst {

GENERATE_SOA_LAYOUT(HitsSoALayout,
SOA_COLUMN(float, xs),
SOA_COLUMN(float, ys),
SOA_COLUMN(float, zs),
SOA_COLUMN(uint16_t, moduleIndices),
SOA_COLUMN(unsigned int, idxs),
SOA_COLUMN(unsigned int, detid),
SOA_COLUMN(float, rts),
SOA_COLUMN(float, phis),
SOA_COLUMN(float, etas),
SOA_COLUMN(float, highEdgeXs),
SOA_COLUMN(float, highEdgeYs),
SOA_COLUMN(float, lowEdgeXs),
SOA_COLUMN(float, lowEdgeYs))

GENERATE_SOA_LAYOUT(HitsRangesSoALayout,
SOA_COLUMN(ArrayIx2, hitRanges),
SOA_COLUMN(int, hitRangesLower),
SOA_COLUMN(int, hitRangesUpper),
SOA_COLUMN(int8_t, hitRangesnLower),
SOA_COLUMN(int8_t, hitRangesnUpper))

using HitsSoA = HitsSoALayout<>;
using HitsRangesSoA = HitsRangesSoALayout<>;

using Hits = HitsSoA::View;
using HitsConst = HitsSoA::ConstView;
using HitsRanges = HitsRangesSoA::View;
using HitsRangesConst = HitsRangesSoA::ConstView;

} // namespace lst

#endif
57 changes: 41 additions & 16 deletions RecoTracker/LSTCore/interface/LSTESData.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define RecoTracker_LSTCore_interface_LSTESData_h

#include "RecoTracker/LSTCore/interface/Constants.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h"
#include "RecoTracker/LSTCore/interface/Module.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometryDevHostCollection.h"
#include "RecoTracker/LSTCore/interface/ModulesHostCollection.h"
#include "RecoTracker/LSTCore/interface/PixelMap.h"

#include "HeterogeneousCore/AlpakaInterface/interface/CopyToDevice.h"
Expand All @@ -19,23 +19,23 @@ namespace lst {
uint16_t nLowerModules;
unsigned int nPixels;
unsigned int nEndCapMap;
ModulesBuffer<TDev> modulesBuffers;
EndcapGeometryBuffer<TDev> endcapGeometryBuffers;
std::unique_ptr<const PortableMultiCollection<TDev, ModulesSoA, ModulesPixelSoA>> modules;
std::unique_ptr<const PortableCollection<EndcapGeometryDevSoA, TDev>> endcapGeometry;
std::shared_ptr<const PixelMap> pixelMapping;

LSTESData(uint16_t const& nModulesIn,
uint16_t const& nLowerModulesIn,
unsigned int const& nPixelsIn,
unsigned int const& nEndCapMapIn,
ModulesBuffer<TDev> const& modulesBuffersIn,
EndcapGeometryBuffer<TDev> const& endcapGeometryBuffersIn,
std::unique_ptr<const PortableMultiCollection<TDev, ModulesSoA, ModulesPixelSoA>> modulesIn,
std::unique_ptr<const PortableCollection<EndcapGeometryDevSoA, TDev>> endcapGeometryIn,
std::shared_ptr<const PixelMap> const& pixelMappingIn)
: nModules(nModulesIn),
nLowerModules(nLowerModulesIn),
nPixels(nPixelsIn),
nEndCapMap(nEndCapMapIn),
modulesBuffers(modulesBuffersIn),
endcapGeometryBuffers(endcapGeometryBuffersIn),
modules(std::move(modulesIn)),
endcapGeometry(std::move(endcapGeometryIn)),
pixelMapping(pixelMappingIn) {}
};

Expand All @@ -44,24 +44,49 @@ namespace lst {
} // namespace lst

namespace cms::alpakatools {

// The templated definition in CMSSW doesn't work when using CPU as the device
template <>
struct CopyToDevice<PortableHostCollection<lst::EndcapGeometryDevSoA>> {
template <typename TQueue>
static auto copyAsync(TQueue& queue, PortableHostCollection<lst::EndcapGeometryDevSoA> const& srcData) {
using TDevice = typename alpaka::trait::DevType<TQueue>::type;
PortableCollection<lst::EndcapGeometryDevSoA, TDevice> dstData(srcData->metadata().size(), queue);
alpaka::memcpy(queue, dstData.buffer(), srcData.buffer());
return dstData;
}
};

template <>
struct CopyToDevice<PortableHostMultiCollection<lst::ModulesSoA, lst::ModulesPixelSoA>> {
template <typename TQueue>
static auto copyAsync(TQueue& queue,
PortableHostMultiCollection<lst::ModulesSoA, lst::ModulesPixelSoA> const& srcData) {
using TDevice = typename alpaka::trait::DevType<TQueue>::type;
PortableMultiCollection<TDevice, lst::ModulesSoA, lst::ModulesPixelSoA> dstData(srcData.sizes(), queue);
alpaka::memcpy(queue, dstData.buffer(), srcData.buffer());
return dstData;
}
};

template <>
struct CopyToDevice<lst::LSTESData<alpaka_common::DevHost>> {
template <typename TQueue>
static lst::LSTESData<alpaka::Dev<TQueue>> copyAsync(TQueue& queue,
lst::LSTESData<alpaka_common::DevHost> const& srcData) {
auto deviceModulesBuffers =
lst::ModulesBuffer<alpaka::Dev<TQueue>>(alpaka::getDev(queue), srcData.nModules, srcData.nPixels);
deviceModulesBuffers.copyFromSrc(queue, srcData.modulesBuffers);
auto deviceEndcapGeometryBuffers =
lst::EndcapGeometryBuffer<alpaka::Dev<TQueue>>(alpaka::getDev(queue), srcData.nEndCapMap);
deviceEndcapGeometryBuffers.copyFromSrc(queue, srcData.endcapGeometryBuffers);
auto deviceModules =
std::make_unique<PortableMultiCollection<alpaka::Dev<TQueue>, lst::ModulesSoA, lst::ModulesPixelSoA>>(
CopyToDevice<PortableHostMultiCollection<lst::ModulesSoA, lst::ModulesPixelSoA>>::copyAsync(
queue, *srcData.modules));
auto deviceEndcapGeometry = std::make_unique<PortableCollection<lst::EndcapGeometryDevSoA, alpaka::Dev<TQueue>>>(
CopyToDevice<PortableHostCollection<lst::EndcapGeometryDevSoA>>::copyAsync(queue, *srcData.endcapGeometry));

return lst::LSTESData<alpaka::Dev<TQueue>>(srcData.nModules,
srcData.nLowerModules,
srcData.nPixels,
srcData.nEndCapMap,
std::move(deviceModulesBuffers),
std::move(deviceEndcapGeometryBuffers),
std::move(deviceModules),
std::move(deviceEndcapGeometry),
srcData.pixelMapping);
}
};
Expand Down
10 changes: 10 additions & 0 deletions RecoTracker/LSTCore/interface/MiniDoubletsHostCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef RecoTracker_LSTCore_interface_MiniDoubletsHostCollection_h
#define RecoTracker_LSTCore_interface_MiniDoubletsHostCollection_h

#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"

namespace lst {
using MiniDoubletsHostCollection = PortableHostMultiCollection<MiniDoubletsSoA, MiniDoubletsOccupancySoA>;
} // namespace lst
#endif
Loading