Skip to content

Commit

Permalink
Merge pull request #50 from SegmentLinking/CMSSW_14_1_0_pre3_LST_X_LS…
Browse files Browse the repository at this point in the history
…TCore_realfiles_batch3

Batch 3 for updates to LST integration in cms-sw
  • Loading branch information
slava77 authored Jul 10, 2024
2 parents 4cd8924 + 34c56c6 commit 7187927
Show file tree
Hide file tree
Showing 43 changed files with 1,419 additions and 1,639 deletions.
2 changes: 2 additions & 0 deletions Configuration/PyReleaseValidation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ The offsets currently in use are:
* 0.7: trackingMkFit modifier
* 0.701: DisplacedRegionalStep tracking iteration for Run-3
* 0.702: trackingMkFit modifier for Phase-2 (initialStep only)
* 0.703: LST tracking, initialStep+HighPtTripletStep only, on CPU
* 0.704: LST tracking, initialStep+HighPtTripletStep only, on GPU
* 0.78: Complete L1 workflow
* 0.8: BPH Parking (Run-2)
* 0.81: Running also HeavyFlavor DQM
Expand Down
4 changes: 3 additions & 1 deletion Configuration/PyReleaseValidation/python/relval_2026.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
numWFIB.extend([24834.0,24834.911,24834.103]) #2026D98 DDD XML, DD4hep XML, aging
numWFIB.extend([25061.97]) #2026D98 premixing stage1 (NuGun+PU)
numWFIB.extend([24834.702]) #2026D98 mkFit tracking (initialStep)
numWFIB.extend([24834.703,24834.704]) #2026D98 LST tracking (initialStep+HighPtTripletStep only): CPU, GPU
numWFIB.extend([24834.5,24834.9]) #2026D98 pixelTrackingOnly, vector hits
numWFIB.extend([24834.501,24834.502]) #2026D98 Patatrack local reconstruction on CPU, Patatrack local reconstruction on GPU
numWFIB.extend([25034.99,25034.999]) #2026D98 premixing combined stage1+stage2 (ttbar+PU200, ttbar+PU50 for PR test)
Expand Down Expand Up @@ -55,5 +54,8 @@
# NuGun
numWFIB.extend([24861.0]) #Nu Gun 2026D98

# Temporary placement for LST workflow to workaround PR conflicts - to be formatted and placed in an upcoming PR
numWFIB.extend([24834.703,24834.704]) #2026D98 LST tracking (initialStep+HighPtTripletStep only): CPU, GPU

for numWF in numWFIB:
workflows[numWF] = _upgrade_workflows[numWF]
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,8 @@ def condition_(self, fragment, stepList, key, hasHarvest):
return ('2026' in key)
upgradeWFs['lstOnCPUIters01TrackingOnly'] = UpgradeWorkflow_lstOnCPUIters01TrackingOnly(
steps = [
'Reco',
'RecoFakeHLT',
'HARVEST',
'HARVESTFakeHLT',
'RecoGlobal',
'HARVESTGlobal',
'RecoNano',
'RecoNanoFakeHLT',
'HARVESTNano',
'HARVESTNanoFakeHLT',
# Add ALCA steps explicitly, so that they can be properly removed
'ALCA',
'ALCAPhase2'
Expand All @@ -504,7 +496,8 @@ def condition_(self, fragment, stepList, key, hasHarvest):
offset = 0.703,
)
upgradeWFs['lstOnCPUIters01TrackingOnly'].step3 = upgradeWFs['trackingOnly'].step3 | {
'--procModifiers': 'trackingIters01,trackingLST'
'--procModifiers': 'trackingIters01,trackingLST',
'--accelerators' : 'cpu'
}

# LST on GPU, initialStep+highPtTripletStep-only tracking-only
Expand All @@ -517,16 +510,8 @@ def condition_(self, fragment, stepList, key, hasHarvest):
return ('2026' in key)
upgradeWFs['lstOnGPUIters01TrackingOnly'] = UpgradeWorkflow_lstOnGPUIters01TrackingOnly(
steps = [
'Reco',
'RecoFakeHLT',
'HARVEST',
'HARVESTFakeHLT',
'RecoGlobal',
'HARVESTGlobal',
'RecoNano',
'RecoNanoFakeHLT',
'HARVESTNano',
'HARVESTNanoFakeHLT',
# Add ALCA steps explicitly, so that they can be properly removed
'ALCA',
'ALCAPhase2'
Expand All @@ -536,7 +521,8 @@ def condition_(self, fragment, stepList, key, hasHarvest):
offset = 0.704,
)
upgradeWFs['lstOnGPUIters01TrackingOnly'].step3 = upgradeWFs['trackingOnly'].step3 | {
'--procModifiers': 'gpu,trackingIters01,trackingLST'
'--procModifiers': 'trackingIters01,trackingLST',
'--accelerators' : 'gpu-nvidia'
}

#DeepCore seeding for JetCore iteration workflow
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LST/interface/LSTOutput.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RecoTracker_LST_LSTOutput_h
#define RecoTracker_LST_LSTOutput_h
#ifndef RecoTracker_LST_interface_LSTOutput_h
#define RecoTracker_LST_interface_LSTOutput_h

#include <memory>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LST/interface/LSTPhase2OTHitsInput.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RecoTracker_LST_LSTPhase2OTHitsInput_h
#define RecoTracker_LST_LSTPhase2OTHitsInput_h
#ifndef RecoTracker_LST_interface_LSTPhase2OTHitsInput_h
#define RecoTracker_LST_interface_LSTPhase2OTHitsInput_h

#include <memory>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LST/interface/LSTPixelSeedInput.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RecoTracker_LST_LSTPixelSeedInput_h
#define RecoTracker_LST_LSTPixelSeedInput_h
#ifndef RecoTracker_LST_interface_LSTPixelSeedInput_h
#define RecoTracker_LST_interface_LSTPixelSeedInput_h

#include <memory>
#include <vector>
Expand Down
39 changes: 8 additions & 31 deletions RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,18 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

class LSTModulesDevESProducer : public ESProducer {
public:
LSTModulesDevESProducer(const edm::ParameterSet& iConfig);
LSTModulesDevESProducer(edm::ParameterSet const& iConfig) : ESProducer(iConfig) { setWhatProduced(this); }

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
descriptions.addWithDefaultLabel(desc);
}

std::unique_ptr<SDL::LSTESHostData<SDL::Dev>> produceHost(TrackerRecoGeometryRecord const& iRecord);
std::unique_ptr<SDL::LSTESDeviceData<SDL::Dev>> produceDevice(
device::Record<TrackerRecoGeometryRecord> const& iRecord);

private:
edm::ESGetToken<SDL::LSTESHostData<SDL::Dev>, TrackerRecoGeometryRecord> lstESHostToken_;
std::unique_ptr<SDL::LSTESData<SDL::DevHost>> produce(TrackerRecoGeometryRecord const& iRecord) {
return SDL::loadAndFillESHost();
}
};

LSTModulesDevESProducer::LSTModulesDevESProducer(const edm::ParameterSet& iConfig) : ESProducer(iConfig) {
setWhatProduced(this, &LSTModulesDevESProducer::produceHost);
auto cc = setWhatProduced(this, &LSTModulesDevESProducer::produceDevice);
lstESHostToken_ = cc.consumes();
}

void LSTModulesDevESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
descriptions.addWithDefaultLabel(desc);
}

std::unique_ptr<SDL::LSTESHostData<SDL::Dev>> LSTModulesDevESProducer::produceHost(
TrackerRecoGeometryRecord const& iRecord) {
return SDL::loadAndFillESHost();
}

std::unique_ptr<SDL::LSTESDeviceData<SDL::Dev>> LSTModulesDevESProducer::produceDevice(
device::Record<TrackerRecoGeometryRecord> const& iRecord) {
auto const& lstESHostData = iRecord.get(lstESHostToken_);
SDL::QueueAcc& queue = iRecord.queue();
return SDL::loadAndFillESDevice(queue, &lstESHostData);
}

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(LSTModulesDevESProducer);
16 changes: 11 additions & 5 deletions RecoTracker/LST/plugins/alpaka/LSTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
lstPhase2OTHitsInputToken_{
consumes<LSTPhase2OTHitsInput>(config.getParameter<edm::InputTag>("phase2OTHitsInput"))},
lstESToken_{esConsumes()},
verbose_(config.getParameter<int>("verbose")),
verbose_(config.getParameter<bool>("verbose")),
nopLSDupClean_(config.getParameter<bool>("nopLSDupClean")),
tcpLSTriplets_(config.getParameter<bool>("tcpLSTriplets")),
lstOutputToken_{produces()} {}

void acquire(device::Event const& event, device::EventSetup const& setup) override {
Expand Down Expand Up @@ -61,7 +63,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
phase2OTHits.detId(),
phase2OTHits.x(),
phase2OTHits.y(),
phase2OTHits.z());
phase2OTHits.z(),
nopLSDupClean_,
tcpLSTriplets_);
}

void produce(device::Event& event, device::EventSetup const&) override {
Expand All @@ -74,15 +78,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("pixelSeedInput", edm::InputTag{"lstPixelSeedInputProducer"});
desc.add<edm::InputTag>("phase2OTHitsInput", edm::InputTag{"lstPhase2OTHitsInputProducer"});
desc.add<int>("verbose", 0);
desc.add<bool>("verbose", false);
desc.add<bool>("nopLSDupClean", false);
desc.add<bool>("tcpLSTriplets", false);
descriptions.addWithDefaultLabel(desc);
}

private:
edm::EDGetTokenT<LSTPixelSeedInput> lstPixelSeedInputToken_;
edm::EDGetTokenT<LSTPhase2OTHitsInput> lstPhase2OTHitsInputToken_;
device::ESGetToken<SDL::LSTESDeviceData<SDL::Dev>, TrackerRecoGeometryRecord> lstESToken_;
const int verbose_;
device::ESGetToken<SDL::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
const bool verbose_, nopLSDupClean_, tcpLSTriplets_;
edm::EDPutTokenT<LSTOutput> lstOutputToken_;

SDL::LST<SDL::Acc> lst_;
Expand Down
7 changes: 2 additions & 5 deletions RecoTracker/LST/src/alpaka/ES_ModulesDev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@

// Temporary hack: The DevHost instantiation is needed in both CPU and GPU plugins,
// whereas the (non-host-)Device instantiation only in the GPU plugin
TYPELOOKUP_DATA_REG(SDL::LSTESHostData<SDL::Dev>);
TYPELOOKUP_DATA_REG(SDL::LSTESDeviceData<SDL::DevHost>);
TYPELOOKUP_DATA_REG(ALPAKA_ACCELERATOR_NAMESPACE::ESDeviceProduct<std::unique_ptr<SDL::LSTESHostData<SDL::Dev>>>);
TYPELOOKUP_ALPAKA_TEMPLATED_DATA_REG(SDL::LSTESHostData);
TYPELOOKUP_ALPAKA_TEMPLATED_DATA_REG(SDL::LSTESDeviceData);
TYPELOOKUP_DATA_REG(SDL::LSTESData<SDL::DevHost>);
TYPELOOKUP_ALPAKA_TEMPLATED_DATA_REG(SDL::LSTESData);
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<use name="boost_header"/>
<use name="root"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<flags CXXFLAGS="-DLST_IS_CMSSW_PACKAGE -DCACHE_ALLOC -DT4FromT3 -DUSE_RZCHI2 -DUSE_T5_DNN -DPT_CUT=0.8 -DDUP_pLS -DDUP_T5 -DDUP_pT5 -DDUP_pT3 -DCrossclean_T5 -DCrossclean_pT3 -Wshadow"/>
<flags CXXFLAGS="-DCACHE_ALLOC -DT4FromT3 -DUSE_RZCHI2 -DUSE_T5_DNN -DPT_CUT=0.8 -DDUP_pLS -DDUP_T5 -DDUP_pT5 -DDUP_pT3 -DCrossclean_T5 -DCrossclean_pT3"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
Expand Down
98 changes: 62 additions & 36 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Constants_cuh
#define Constants_cuh
#ifndef RecoTracker_LSTCore_interface_alpaka_Constants_h
#define RecoTracker_LSTCore_interface_alpaka_Constants_h

#include <alpaka/alpaka.hpp>

Expand Down Expand Up @@ -104,54 +104,80 @@ namespace SDL {
constexpr float PT_CUT = 0.8f;
#endif

const unsigned int MAX_BLOCKS = 80;
const unsigned int MAX_CONNECTED_MODULES = 40;
constexpr unsigned int MAX_BLOCKS = 80;
constexpr unsigned int MAX_CONNECTED_MODULES = 40;

const unsigned int N_MAX_PIXEL_SEGMENTS_PER_MODULE = 50000;
constexpr unsigned int N_MAX_PIXEL_SEGMENTS_PER_MODULE = 50000;

const unsigned int N_MAX_PIXEL_MD_PER_MODULES = 2 * N_MAX_PIXEL_SEGMENTS_PER_MODULE;
constexpr unsigned int N_MAX_PIXEL_MD_PER_MODULES = 2 * N_MAX_PIXEL_SEGMENTS_PER_MODULE;

const unsigned int N_MAX_PIXEL_TRIPLETS = 5000;
const unsigned int N_MAX_PIXEL_QUINTUPLETS = 15000;
constexpr unsigned int N_MAX_PIXEL_TRIPLETS = 5000;
constexpr unsigned int N_MAX_PIXEL_QUINTUPLETS = 15000;

const unsigned int N_MAX_PIXEL_TRACK_CANDIDATES = 30000;
const unsigned int N_MAX_NONPIXEL_TRACK_CANDIDATES = 1000;
constexpr unsigned int N_MAX_PIXEL_TRACK_CANDIDATES = 30000;
constexpr unsigned int N_MAX_NONPIXEL_TRACK_CANDIDATES = 1000;

const unsigned int size_superbins = 45000;
constexpr unsigned int size_superbins = 45000;

//defining the constant host device variables right up here
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniMulsPtScaleBarrel[6] = {0.0052, 0.0038, 0.0034, 0.0034, 0.0032, 0.0034};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniRminMeanBarrel[6] = {
// 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;
};
struct Params_T3 {
static constexpr int kLayers = 3, kHits = 6;
};
struct Params_pT3 {
static constexpr int kLayers = 5, kHits = 10;
};
struct Params_T5 {
static constexpr int kLayers = 5, kHits = 10;
};
struct Params_pT5 {
static constexpr int kLayers = 7, kHits = 14;
};

// 15 MeV constant from the approximate Bethe-Bloch formula
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMulsInGeV = 0.015;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleBarrel[6] = {
0.0052, 0.0038, 0.0034, 0.0034, 0.0032, 0.0034};
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006};
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniRminMeanBarrel[6] = {
25.007152356, 37.2186993757, 52.3104270826, 68.6658656666, 85.9770373007, 108.301772384};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniRminMeanEndcap[5] = {
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniRminMeanEndcap[5] = {
130.992832231, 154.813883559, 185.352604327, 221.635123002, 265.022076742};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float k2Rinv1GeVf = (2.99792458e-3 * 3.8) / 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float kR1GeVf = 1. / (2.99792458e-3 * 3.8);
ALPAKA_STATIC_ACC_MEM_GLOBAL const float sinAlphaMax = 0.95;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float ptCut = PT_CUT;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float deltaZLum = 15.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float pixelPSZpitch = 0.15;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float strip2SZpitch = 5.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float pt_betaMax = 7.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL const float magnetic_field = 3.8112;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float k2Rinv1GeVf = (2.99792458e-3 * 3.8) / 2;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kR1GeVf = 1. / (2.99792458e-3 * 3.8);
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float sinAlphaMax = 0.95;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float ptCut = PT_CUT;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float deltaZLum = 15.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float pixelPSZpitch = 0.15;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float stripPSZpitch = 2.4;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float strip2SZpitch = 5.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float width2S = 0.009;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float widthPS = 0.01;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float pt_betaMax = 7.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float magnetic_field = 3.8112;
// Since C++ can't represent infinity, SDL_INF = 123456789 was used to represent infinity in the data table
ALPAKA_STATIC_ACC_MEM_GLOBAL const float SDL_INF = 123456789.0;
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float SDL_INF = 123456789.0;
} //namespace SDL

namespace T5DNN {
// Working points matching LST fake rate (43.9%) or signal acceptance (82.0%)
ALPAKA_STATIC_ACC_MEM_GLOBAL const float LSTWP1 = 0.3418833f; // 94.0% TPR, 43.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float LSTWP2 = 0.6177366f; // 82.0% TPR, 20.0% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float LSTWP1 = 0.3418833f; // 94.0% TPR, 43.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float LSTWP2 = 0.6177366f; // 82.0% TPR, 20.0% FPR
// Other working points
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP70 = 0.7776195f; // 70.0% TPR, 10.0% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP75 = 0.7181118f; // 75.0% TPR, 13.5% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP80 = 0.6492643f; // 80.0% TPR, 17.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP85 = 0.5655319f; // 85.0% TPR, 23.8% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP90 = 0.4592205f; // 90.0% TPR, 32.6% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP95 = 0.3073708f; // 95.0% TPR, 47.7% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP97p5 = 0.2001348f; // 97.5% TPR, 61.2% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP99 = 0.1120605f; // 99.0% TPR, 75.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL const float WP99p9 = 0.0218196f; // 99.9% TPR, 95.4% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP70 = 0.7776195f; // 70.0% TPR, 10.0% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP75 = 0.7181118f; // 75.0% TPR, 13.5% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP80 = 0.6492643f; // 80.0% TPR, 17.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP85 = 0.5655319f; // 85.0% TPR, 23.8% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP90 = 0.4592205f; // 90.0% TPR, 32.6% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP95 = 0.3073708f; // 95.0% TPR, 47.7% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP97p5 = 0.2001348f; // 97.5% TPR, 61.2% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP99 = 0.1120605f; // 99.0% TPR, 75.9% FPR
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float WP99p9 = 0.0218196f; // 99.9% TPR, 95.4% FPR
} // namespace T5DNN
#endif
57 changes: 57 additions & 0 deletions RecoTracker/LSTCore/interface/alpaka/EndcapGeometryBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef RecoTracker_LSTCore_interface_alpaka_EndcapGeometryBuffers_h
#define RecoTracker_LSTCore_interface_alpaka_EndcapGeometryBuffers_h

#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <stdexcept>

#include "HeterogeneousCore/AlpakaInterface/interface/host.h"

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

namespace SDL {

struct EndcapGeometryDev {
const unsigned int* geoMapDetId;
const float* geoMapPhi;

template <typename TBuff>
void setData(const TBuff& endcapgeombuf) {
geoMapDetId = alpaka::getPtrNative(endcapgeombuf.geoMapDetId_buf);
geoMapPhi = alpaka::getPtrNative(endcapgeombuf.geoMapPhi_buf);
}
};

template <typename TDev>
struct EndcapGeometryBuffer : EndcapGeometryDev {
Buf<TDev, unsigned int> geoMapDetId_buf;
Buf<TDev, float> geoMapPhi_buf;

EndcapGeometryBuffer(TDev const& dev, unsigned int nEndCapMap)
: geoMapDetId_buf(allocBufWrapper<unsigned int>(dev, nEndCapMap)),
geoMapPhi_buf(allocBufWrapper<float>(dev, nEndCapMap)) {
setData(*this);
}

template <typename TQueue, typename TDevSrc>
inline void copyFromSrc(TQueue queue, const EndcapGeometryBuffer<TDevSrc>& src) {
alpaka::memcpy(queue, geoMapDetId_buf, src.geoMapDetId_buf);
alpaka::memcpy(queue, geoMapPhi_buf, src.geoMapPhi_buf);
}

template <typename TQueue, typename TDevSrc>
EndcapGeometryBuffer(TQueue queue, const EndcapGeometryBuffer<TDevSrc>& src, unsigned int nEndCapMap)
: EndcapGeometryBuffer(alpaka::getDev(queue), nEndCapMap) {
copyFromSrc(queue, src);
}

inline SDL::EndcapGeometryDev const* data() const { return this; }
};

} // namespace SDL

#endif
Loading

0 comments on commit 7187927

Please sign in to comment.