Skip to content

Commit

Permalink
Merge pull request #70 from slava77/CMSSW_14_1_0_pre5/LSTb4-buf-lite
Browse files Browse the repository at this point in the history
alpaka modernise/improve for batch4
  • Loading branch information
VourMa authored Jul 30, 2024
2 parents fac2958 + d5e0b69 commit 3fc9904
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 89 deletions.
5 changes: 0 additions & 5 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ namespace lst {
};
#endif

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

// Adjust grid and block sizes based on backend configuration
template <typename Vec>
ALPAKA_FN_HOST ALPAKA_FN_INLINE WorkDiv3D createWorkDiv(const Vec& blocksPerGrid,
Expand Down
7 changes: 2 additions & 5 deletions RecoTracker/LSTCore/src/EndcapGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ void lst::EndcapGeometry::fillGeoMapArraysExplicit() {
}

float lst::EndcapGeometry::getdxdy_slope(unsigned int detid) const {
if (dxdy_slope_.find(detid) != dxdy_slope_.end()) {
return dxdy_slope_.at(detid);
} else {
return 0;
}
auto res = dxdy_slope_.find(detid);
return res == dxdy_slope_.end() ? 0.f : res->second;
}
14 changes: 4 additions & 10 deletions RecoTracker/LSTCore/src/TiltedGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ void lst::TiltedGeometry::load(std::string filename) {
}

float lst::TiltedGeometry::getDrDz(unsigned int detid) const {
if (drdzs_.find(detid) != drdzs_.end()) {
return drdzs_.at(detid);
} else {
return 0;
}
auto res = drdzs_.find(detid);
return res == drdzs_.end() ? 0.f : res->second;
}

float lst::TiltedGeometry::getDxDy(unsigned int detid) const {
if (dxdys_.find(detid) != dxdys_.end()) {
return dxdys_.at(detid);
} else {
return 0;
}
auto res = dxdys_.find(detid);
return res == dxdys_.end() ? 0.f : res->second;
}
125 changes: 62 additions & 63 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/MiniDoublet.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoTracker_LSTCore_src_alpaka_MiniDoublet_h
#define RecoTracker_LSTCore_src_alpaka_MiniDoublet_h

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

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
Expand Down Expand Up @@ -994,7 +996,9 @@ namespace lst {

// Declare variables in shared memory and set to 0
int& nTotalMDs = alpaka::declareSharedVar<int, __COUNTER__>(acc);
nTotalMDs = 0;
if (cms::alpakatools::once_per_block(acc)) {
nTotalMDs = 0;
}
alpaka::syncBlockThreads(acc);

// Initialize variables outside of the for loop.
Expand Down Expand Up @@ -1067,7 +1071,7 @@ namespace lst {

// Wait for all threads to finish before reporting final values
alpaka::syncBlockThreads(acc);
if (globalThreadIdx[2] == 0) {
if (cms::alpakatools::once_per_block(acc)) {
rangesInGPU.miniDoubletModuleIndices[*modulesInGPU.nLowerModules] = nTotalMDs;
*rangesInGPU.device_nTotalMDs = nTotalMDs;
}
Expand Down
8 changes: 6 additions & 2 deletions RecoTracker/LSTCore/src/alpaka/Quintuplet.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoTracker_LSTCore_src_alpaka_Quintuplet_h
#define RecoTracker_LSTCore_src_alpaka_Quintuplet_h

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

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
Expand Down Expand Up @@ -3109,8 +3111,10 @@ namespace lst {
// Initialize variables in shared memory and set to 0
int& nEligibleT5Modulesx = alpaka::declareSharedVar<int, __COUNTER__>(acc);
int& nTotalQuintupletsx = alpaka::declareSharedVar<int, __COUNTER__>(acc);
nTotalQuintupletsx = 0;
nEligibleT5Modulesx = 0;
if (cms::alpakatools::once_per_block(acc)) {
nTotalQuintupletsx = 0;
nEligibleT5Modulesx = 0;
}
alpaka::syncBlockThreads(acc);

// Initialize variables outside of the for loop.
Expand Down
6 changes: 5 additions & 1 deletion RecoTracker/LSTCore/src/alpaka/Segment.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoTracker_LSTCore_src_alpaka_Segment_h
#define RecoTracker_LSTCore_src_alpaka_Segment_h

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

#include "RecoTracker/LSTCore/interface/alpaka/Constants.h"
#include "RecoTracker/LSTCore/interface/Module.h"
#include "RecoTracker/LSTCore/interface/EndcapGeometry.h"
Expand Down Expand Up @@ -900,7 +902,9 @@ namespace lst {

// Initialize variables in shared memory and set to 0
int& nTotalSegments = alpaka::declareSharedVar<int, __COUNTER__>(acc);
nTotalSegments = 0;
if (cms::alpakatools::once_per_block(acc)) {
nTotalSegments = 0;
}
alpaka::syncBlockThreads(acc);

// Initialize variables outside of the for loop.
Expand Down
6 changes: 5 additions & 1 deletion RecoTracker/LSTCore/src/alpaka/Triplet.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoTracker_LSTCore_src_alpaka_Triplet_h
#define RecoTracker_LSTCore_src_alpaka_Triplet_h

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

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

Expand Down Expand Up @@ -997,7 +999,9 @@ namespace lst {

// Initialize variables in shared memory and set to 0
int& nTotalTriplets = alpaka::declareSharedVar<int, __COUNTER__>(acc);
nTotalTriplets = 0;
if (cms::alpakatools::once_per_block(acc)) {
nTotalTriplets = 0;
}
alpaka::syncBlockThreads(acc);

// Initialize variables outside of the for loop.
Expand Down

0 comments on commit 3fc9904

Please sign in to comment.