Skip to content

Commit

Permalink
A bit more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Jul 18, 2024
1 parent ccd29f4 commit d33ac32
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 280 deletions.
2 changes: 1 addition & 1 deletion RecoTracker/LST/plugins/alpaka/LSTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
const bool verbose_, nopLSDupClean_, tcpLSTriplets_;
edm::EDPutTokenT<LSTOutput> lstOutputToken_;

SDL::LST<Device> lst_;
SDL::LST<Acc3D> lst_;
};

} // namespace ALPAKA_ACCELERATOR_NAMESPACE
Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/interface/LST.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace SDL {
template <typename>
class LST;

template <typename TDev>
template <typename TAcc>
class LST {
public:
LST() = default;

template <typename TQueue>
void run(TQueue& queue,
bool verbose,
const LSTESData<TDev>* deviceESData,
const LSTESData<alpaka::Dev<TAcc>>* deviceESData,
const std::vector<float> see_px,
const std::vector<float> see_py,
const std::vector<float> see_pz,
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace SDL {
const std::vector<float> ph2_y,
const std::vector<float> ph2_z);

void getOutput(SDL::Event<TDev>& event);
void getOutput(SDL::Event<TAcc>& event);
std::vector<unsigned int> getHitIdxs(const short trackCandidateType,
const unsigned int TCIdx,
const unsigned int* TCHitIndices,
Expand Down
21 changes: 12 additions & 9 deletions RecoTracker/LSTCore/interface/alpaka/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#endif

namespace SDL {

using namespace ALPAKA_ACCELERATOR_NAMESPACE;

// Half precision wrapper functions.
#if defined(FP16_Base)
#define __F2H __float2half
Expand All @@ -19,7 +22,7 @@ namespace SDL {
typedef float FPX;
#endif

alpaka_common::Vec3D const elementsPerThread(alpaka_common::Vec3D::all(static_cast<alpaka_common::Idx>(1)));
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.
Expand All @@ -33,31 +36,31 @@ namespace SDL {
#endif

// 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));
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 alpaka_common::WorkDiv3D createWorkDiv(const Vec& blocksPerGrid,
ALPAKA_FN_HOST ALPAKA_FN_INLINE WorkDiv3D createWorkDiv(const Vec& blocksPerGrid,
const Vec& threadsPerBlock,
const Vec& elementsPerThreadArg) {
Vec adjustedBlocks = blocksPerGrid;
Vec adjustedThreads = threadsPerBlock;

// Serial execution, so all launch parameters set to 1.
#if defined(ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED)
adjustedBlocks = Vec::all(static_cast<alpaka_common::Idx>(1));
adjustedThreads = Vec::all(static_cast<alpaka_common::Idx>(1));
adjustedBlocks = Vec::all(static_cast<Idx>(1));
adjustedThreads = Vec::all(static_cast<Idx>(1));
#endif

// Threads enabled, set number of blocks to 1.
#if defined(ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLED)
adjustedBlocks = Vec::all(static_cast<alpaka_common::Idx>(1));
adjustedBlocks = Vec::all(static_cast<Idx>(1));
#endif

return alpaka_common::WorkDiv3D(adjustedBlocks, adjustedThreads, elementsPerThreadArg);
return WorkDiv3D(adjustedBlocks, adjustedThreads, elementsPerThreadArg);
}

// 15 MeV constant from the approximate Bethe-Bloch formula
Expand Down
Loading

0 comments on commit d33ac32

Please sign in to comment.