Skip to content

Commit

Permalink
Format and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Jul 17, 2024
1 parent c4ac510 commit ccd29f4
Show file tree
Hide file tree
Showing 23 changed files with 305 additions and 288 deletions.
9 changes: 6 additions & 3 deletions RecoTracker/LSTCore/interface/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ namespace SDL {
TSize nElements,
TQueue queue) {
#ifdef CACHE_ALLOC
return cms::alpakatools::allocCachedBuf<T, alpaka_common::Idx>(devAccIn, queue, alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
return cms::alpakatools::allocCachedBuf<T, alpaka_common::Idx>(
devAccIn, queue, alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
#else
return alpaka::allocBuf<T, alpaka_common::Idx>(devAccIn, alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
return alpaka::allocBuf<T, alpaka_common::Idx>(devAccIn,
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
#endif
}

// Second allocation wrapper function when queue is not given. Reduces code boilerplate.
template <typename T, typename TAcc, typename TSize>
ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf<alpaka::Dev<TAcc>, T> allocBufWrapper(TAcc const& devAccIn, TSize nElements) {
return alpaka::allocBuf<T, alpaka_common::Idx>(devAccIn, alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
return alpaka::allocBuf<T, alpaka_common::Idx>(devAccIn,
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
}

// If a compile time flag does not define PT_CUT, default to 0.8 (GeV)
Expand Down
7 changes: 4 additions & 3 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ namespace SDL {

// Wrapper function to reduce code boilerplate for defining grid/block sizes.
ALPAKA_FN_HOST ALPAKA_FN_INLINE alpaka_common::Vec3D createVec(int x, int y, int z) {
return alpaka_common::Vec3D(static_cast<alpaka_common::Idx>(x), static_cast<alpaka_common::Idx>(y), static_cast<alpaka_common::Idx>(z));
return alpaka_common::Vec3D(
static_cast<alpaka_common::Idx>(x), static_cast<alpaka_common::Idx>(y), static_cast<alpaka_common::Idx>(z));
}

// Adjust grid and block sizes based on backend configuration
template <typename Vec>
ALPAKA_FN_HOST ALPAKA_FN_INLINE alpaka_common::WorkDiv3D createWorkDiv(const Vec& blocksPerGrid,
const Vec& threadsPerBlock,
const Vec& elementsPerThreadArg) {
const Vec& threadsPerBlock,
const Vec& elementsPerThreadArg) {
Vec adjustedBlocks = blocksPerGrid;
Vec adjustedThreads = threadsPerBlock;

Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/LSTESData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ std::unique_ptr<SDL::LSTESData<alpaka_common::DevHost>> SDL::loadAndFillESHost()
auto moduleConnectionMap = std::make_shared<ModuleConnectionMap>();
::loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);

auto endcapGeometryBuffers =
std::make_shared<EndcapGeometryBuffer<alpaka_common::DevHost>>(cms::alpakatools::host(), endcapGeometry->nEndCapMap);
auto endcapGeometryBuffers = std::make_shared<EndcapGeometryBuffer<alpaka_common::DevHost>>(
cms::alpakatools::host(), endcapGeometry->nEndCapMap);
alpaka::QueueCpuBlocking queue(cms::alpakatools::host());
alpaka::memcpy(
queue, endcapGeometryBuffers->geoMapDetId_buf, endcapGeometry->geoMapDetId_buf, endcapGeometry->nEndCapMap);
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/ModuleMethods.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef ModuleMethods_cuh
#define ModuleMethods_cuh
#ifndef RecoTracker_LSTCore_src_ModuleMethods_h
#define RecoTracker_LSTCore_src_ModuleMethods_h

#include <map>
#include <iostream>
Expand Down
357 changes: 180 additions & 177 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Event.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RecoTracker_LSTCore_src_Event_h
#define RecoTracker_LSTCore_src_Event_h
#ifndef RecoTracker_LSTCore_src_alpaka_Event_h
#define RecoTracker_LSTCore_src_alpaka_Event_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Hit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Hit_cuh
#define Hit_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_Hit_h
#define RecoTracker_LSTCore_src_alpaka_Hit_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Kernels.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Kernels_cuh
#define Kernels_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_Kernels_h
#define RecoTracker_LSTCore_src_alpaka_Kernels_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
90 changes: 45 additions & 45 deletions RecoTracker/LSTCore/src/alpaka/LST.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ namespace {

template <>
void SDL::LST<Device>::prepareInput(const std::vector<float> see_px,
const std::vector<float> see_py,
const std::vector<float> see_pz,
const std::vector<float> see_dxy,
const std::vector<float> see_dz,
const std::vector<float> see_ptErr,
const std::vector<float> see_etaErr,
const std::vector<float> see_stateTrajGlbX,
const std::vector<float> see_stateTrajGlbY,
const std::vector<float> see_stateTrajGlbZ,
const std::vector<float> see_stateTrajGlbPx,
const std::vector<float> see_stateTrajGlbPy,
const std::vector<float> see_stateTrajGlbPz,
const std::vector<int> see_q,
const std::vector<std::vector<int>> see_hitIdx,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z) {
const std::vector<float> see_py,
const std::vector<float> see_pz,
const std::vector<float> see_dxy,
const std::vector<float> see_dz,
const std::vector<float> see_ptErr,
const std::vector<float> see_etaErr,
const std::vector<float> see_stateTrajGlbX,
const std::vector<float> see_stateTrajGlbY,
const std::vector<float> see_stateTrajGlbZ,
const std::vector<float> see_stateTrajGlbPx,
const std::vector<float> see_stateTrajGlbPy,
const std::vector<float> see_stateTrajGlbPz,
const std::vector<int> see_q,
const std::vector<std::vector<int>> see_hitIdx,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z) {
unsigned int count = 0;
auto n_see = see_stateTrajGlbPx.size();
std::vector<float> px_vec;
Expand Down Expand Up @@ -212,11 +212,11 @@ void SDL::LST<Device>::prepareInput(const std::vector<float> see_px,
in_isQuad_vec_ = isQuad_vec;
}

template<>
template <>
std::vector<unsigned int> SDL::LST<Device>::getHitIdxs(const short trackCandidateType,
const unsigned int TCIdx,
const unsigned int* TCHitIndices,
const unsigned int* hitIndices) {
const unsigned int TCIdx,
const unsigned int* TCHitIndices,
const unsigned int* hitIndices) {
std::vector<unsigned int> hits;

unsigned int maxNHits = 0;
Expand Down Expand Up @@ -279,29 +279,29 @@ void SDL::LST<Device>::getOutput(SDL::Event<Device>& event) {
template <>
template <>
void SDL::LST<Device>::run(Queue& queue,
bool verbose,
const LSTESData<Device>* deviceESData,
const std::vector<float> see_px,
const std::vector<float> see_py,
const std::vector<float> see_pz,
const std::vector<float> see_dxy,
const std::vector<float> see_dz,
const std::vector<float> see_ptErr,
const std::vector<float> see_etaErr,
const std::vector<float> see_stateTrajGlbX,
const std::vector<float> see_stateTrajGlbY,
const std::vector<float> see_stateTrajGlbZ,
const std::vector<float> see_stateTrajGlbPx,
const std::vector<float> see_stateTrajGlbPy,
const std::vector<float> see_stateTrajGlbPz,
const std::vector<int> see_q,
const std::vector<std::vector<int>> see_hitIdx,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z,
bool no_pls_dupclean,
bool tc_pls_triplets) {
bool verbose,
const LSTESData<Device>* deviceESData,
const std::vector<float> see_px,
const std::vector<float> see_py,
const std::vector<float> see_pz,
const std::vector<float> see_dxy,
const std::vector<float> see_dz,
const std::vector<float> see_ptErr,
const std::vector<float> see_etaErr,
const std::vector<float> see_stateTrajGlbX,
const std::vector<float> see_stateTrajGlbY,
const std::vector<float> see_stateTrajGlbZ,
const std::vector<float> see_stateTrajGlbPx,
const std::vector<float> see_stateTrajGlbPy,
const std::vector<float> see_stateTrajGlbPz,
const std::vector<int> see_q,
const std::vector<std::vector<int>> see_hitIdx,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z,
bool no_pls_dupclean,
bool tc_pls_triplets) {
auto event = SDL::Event<Device>(verbose, queue, deviceESData);
prepareInput(see_px,
see_py,
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/MiniDoublet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MiniDoublet_cuh
#define MiniDoublet_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_MiniDoublet_h
#define RecoTracker_LSTCore_src_alpaka_MiniDoublet_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef NeuralNetwork_cuh
#define NeuralNetwork_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_NeuralNetwork_h
#define RecoTracker_LSTCore_src_alpaka_NeuralNetwork_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/NeuralNetworkWeights.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef NeuralNetworkWeights_cuh
#define NeuralNetworkWeights_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_NeuralNetworkWeights_h
#define RecoTracker_LSTCore_src_alpaka_NeuralNetworkWeights_h

#include <alpaka/alpaka.hpp>

Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/LSTCore/src/alpaka/PixelTriplet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PixelTriplet_cuh
#define PixelTriplet_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_PixelTriplet_h
#define RecoTracker_LSTCore_src_alpaka_PixelTriplet_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down Expand Up @@ -1824,8 +1824,8 @@ namespace SDL {
} // namespace SDL
#endif

#ifndef PixelQuintuplet_cuh
#define PixelQuintuplet_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h
#define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Quintuplet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Quintuplet_cuh
#define Quintuplet_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_Quintuplet_h
#define RecoTracker_LSTCore_src_alpaka_Quintuplet_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Segment.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Segment_cuh
#define Segment_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_Segment_h
#define RecoTracker_LSTCore_src_alpaka_Segment_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/TrackCandidate.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef TrackCandidate_cuh
#define TrackCandidate_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_TrackCandidate_h
#define RecoTracker_LSTCore_src_alpaka_TrackCandidate_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Triplet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Triplet_cuh
#define Triplet_cuh
#ifndef RecoTracker_LSTCore_src_alpaka_Triplet_h
#define RecoTracker_LSTCore_src_alpaka_Triplet_h

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
Expand Down
3 changes: 1 addition & 2 deletions RecoTracker/LSTCore/standalone/bin/sdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ void run_sdl() {
TStopwatch full_timer;
full_timer.Start();
auto hostESData = SDL::loadAndFillESHost();
auto deviceESData =
cms::alpakatools::CopyToDevice<SDL::LSTESData<DevHost>>::copyAsync(queues[0], *hostESData.get());
auto deviceESData = cms::alpakatools::CopyToDevice<SDL::LSTESData<DevHost>>::copyAsync(queues[0], *hostESData.get());
float timeForMapLoading = full_timer.RealTime() * 1000;

if (ana.do_write_ntuple) {
Expand Down
32 changes: 16 additions & 16 deletions RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ std::vector<unsigned int> getPixelHitTypesFrompLS(SDL::Event<Device>* event, uns
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompLS(
SDL::Event<Device>* event, unsigned pLS) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompLS(SDL::Event<Device>* event,
unsigned pLS) {
return convertHitsToHitIdxsAndHitTypes(event, getPixelHitsFrompLS(event, pLS));
}

Expand All @@ -81,8 +81,8 @@ std::vector<unsigned int> getHitsFromMD(SDL::Event<Device>* event, unsigned int
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromMD(
SDL::Event<Device>* event, unsigned MD) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromMD(SDL::Event<Device>* event,
unsigned MD) {
return convertHitsToHitIdxsAndHitTypes(event, getHitsFromMD(event, MD));
}

Expand All @@ -107,8 +107,8 @@ std::vector<unsigned int> getHitsFromLS(SDL::Event<Device>* event, unsigned int
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromLS(
SDL::Event<Device>* event, unsigned LS) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromLS(SDL::Event<Device>* event,
unsigned LS) {
return convertHitsToHitIdxsAndHitTypes(event, getHitsFromLS(event, LS));
}

Expand Down Expand Up @@ -142,8 +142,8 @@ std::vector<unsigned int> getHitsFromT3(SDL::Event<Device>* event, unsigned int
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromT3(
SDL::Event<Device>* event, unsigned T3) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromT3(SDL::Event<Device>* event,
unsigned T3) {
return convertHitsToHitIdxsAndHitTypes(event, getHitsFromT3(event, T3));
}

Expand Down Expand Up @@ -214,8 +214,8 @@ std::vector<unsigned int> getHitTypesFromT5(SDL::Event<Device>* event, unsigned
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromT5(
SDL::Event<Device>* event, unsigned T5) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromT5(SDL::Event<Device>* event,
unsigned T5) {
return convertHitsToHitIdxsAndHitTypes(event, getHitsFromT5(event, T5));
}

Expand Down Expand Up @@ -303,8 +303,8 @@ std::vector<unsigned int> getHitTypesFrompT3(SDL::Event<Device>* event, unsigned
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompT3(
SDL::Event<Device>* event, unsigned pT3) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompT3(SDL::Event<Device>* event,
unsigned pT3) {
return convertHitsToHitIdxsAndHitTypes(event, getHitsFrompT3(event, pT3));
}

Expand Down Expand Up @@ -400,8 +400,8 @@ std::vector<unsigned int> getHitTypesFrompT5(SDL::Event<Device>* event, unsigned
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompT5(
SDL::Event<Device>* event, unsigned pT5) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompT5(SDL::Event<Device>* event,
unsigned pT5) {
return convertHitsToHitIdxsAndHitTypes(event, getHitsFrompT5(event, pT5));
}

Expand Down Expand Up @@ -432,8 +432,8 @@ std::vector<unsigned int> getLSsFromTC(SDL::Event<Device>* event, unsigned int T
}

//____________________________________________________________________________________________
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromTC(
SDL::Event<Device>* event, unsigned TC) {
std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromTC(SDL::Event<Device>* event,
unsigned TC) {
// Get the type of the track candidate
SDL::trackCandidatesBuffer<alpaka::DevCpu>& trackCandidatesInGPU = (*event->getTrackCandidates());
short type = trackCandidatesInGPU.trackCandidateType[TC];
Expand Down
Loading

0 comments on commit ccd29f4

Please sign in to comment.