Skip to content

Commit

Permalink
Replace TAcc with the explicit accelerator type
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Dec 11, 2024
1 parent 8b175a1 commit 51f1595
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 95 deletions.
6 changes: 2 additions & 4 deletions RecoTracker/PixelSeeding/plugins/alpaka/BrokenLineFit.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
template <int N, typename TrackerTraits>
class Kernel_BLFastFit {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
Tuples<TrackerTraits> const *__restrict__ foundNtuplets,
TupleMultiplicity<TrackerTraits> const *__restrict__ tupleMultiplicity,
TrackingRecHitSoAConstView<TrackerTraits> hh,
Expand Down Expand Up @@ -173,8 +172,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
template <int N, typename TrackerTraits>
struct Kernel_BLFit {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TupleMultiplicity<TrackerTraits> const *__restrict__ tupleMultiplicity,
double bField,
OutputSoAView<TrackerTraits> results_view,
Expand Down
16 changes: 8 additions & 8 deletions RecoTracker/PixelSeeding/plugins/alpaka/CACell.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
}

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE __attribute__((always_inline)) int addOuterNeighbor(
const TAcc& acc, typename TrackerTraits::cindex_type t, CellNeighborsVector& cellNeighbors) {
ALPAKA_FN_ACC ALPAKA_FN_INLINE int addOuterNeighbor(TAcc const& acc,
typename TrackerTraits::cindex_type t,
CellNeighborsVector& cellNeighbors) {
// use smart cache
if (outerNeighbors().empty()) {
auto i = cellNeighbors.extend(acc); // maybe wasted....
Expand All @@ -90,17 +91,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
(PtrAsInt)(&cellNeighbors[i]),
alpaka::hierarchy::Blocks{}); // if fails we cannot give "i" back...
#endif
} else
} else {
return -1;
}
}
alpaka::mem_fence(acc, alpaka::memory_scope::Grid{});
return outerNeighbors().push_back(acc, t);
}

template <typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE __attribute__((always_inline)) int addTrack(TAcc const& acc,
tindex_type t,
CellTracksVector& cellTracks) {
ALPAKA_FN_ACC ALPAKA_FN_INLINE int addTrack(TAcc const& acc, tindex_type t, CellTracksVector& cellTracks) {
if (tracks().empty()) {
auto i = cellTracks.extend(acc); // maybe wasted....
if (i > 0) {
Expand Down Expand Up @@ -282,8 +282,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

// trying to free the track building process from hardcoded layers, leaving
// the visit of the graph based on the neighborhood connections between cells.
template <int DEPTH, typename TAcc>
ALPAKA_FN_ACC ALPAKA_FN_INLINE void find_ntuplets(TAcc const& acc,
template <int DEPTH>
ALPAKA_FN_ACC ALPAKA_FN_INLINE void find_ntuplets(Acc1D const& acc,
const HitsConstView& hh,
CACellT* __restrict__ cells,
CellTracksVector& cellTracks,
Expand Down
3 changes: 1 addition & 2 deletions RecoTracker/PixelSeeding/plugins/alpaka/CAFishbone.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets {
template <typename TrackerTraits>
class CAFishbone {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc2D const& acc,
HitsConstView<TrackerTraits> hh,
CACellT<TrackerTraits>* cells,
uint32_t const* __restrict__ nCells,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
const Vec2D blks{numberOfBlocks, 1u};
const Vec2D thrs{blockSize, stride};
const auto workDiv2D = cms::alpakatools::make_workdiv<Acc2D>(blks, thrs);

alpaka::exec<Acc2D>(queue,
workDiv2D,
CAFishbone<TrackerTraits>{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_checkOverflows {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
TupleMultiplicity<TrackerTraits> const *tupleMultiplicity,
HitToTuple<TrackerTraits> const *hitToTuple,
Expand Down Expand Up @@ -168,8 +167,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_fishboneCleaner {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
CACellT<TrackerTraits> const *cells,
uint32_t const *__restrict__ nCells,
TkSoAView<TrackerTraits> tracks_view) const {
Expand All @@ -191,8 +189,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_earlyDuplicateRemover {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
CACellT<TrackerTraits> const *cells,
uint32_t const *__restrict__ nCells,
TkSoAView<TrackerTraits> tracks_view,
Expand Down Expand Up @@ -230,8 +227,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_fastDuplicateRemover {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
CACellT<TrackerTraits> const *__restrict__ cells,
uint32_t const *__restrict__ nCells,
TkSoAView<TrackerTraits> tracks_view,
Expand Down Expand Up @@ -319,8 +315,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_connect {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc2D const &acc,
cms::alpakatools::AtomicPairCounter *apc1,
cms::alpakatools::AtomicPairCounter *apc2, // just to zero them
HitsConstView<TrackerTraits> hh,
Expand Down Expand Up @@ -381,11 +376,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
} // loop on outer cells
}
};

template <typename TrackerTraits>
class Kernel_find_ntuplets {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
HitsConstView<TrackerTraits> hh,
TkSoAView<TrackerTraits> tracks_view,
CACellT<TrackerTraits> *__restrict__ cells,
Expand Down Expand Up @@ -422,16 +417,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
typename Cell::TmpTuple stack;
stack.reset();
bool bpix1Start = params.startAt0(pid);
thisCell.template find_ntuplets<maxDepth, TAcc>(acc,
hh,
cells,
*cellTracks,
tracks_view.hitIndices(),
*apc,
tracks_view.quality(),
stack,
params.minHitsPerNtuplet_,
bpix1Start);
thisCell.template find_ntuplets<maxDepth>(acc,
hh,
cells,
*cellTracks,
tracks_view.hitIndices(),
*apc,
tracks_view.quality(),
stack,
params.minHitsPerNtuplet_,
bpix1Start);
ALPAKA_ASSERT_ACC(stack.empty());
}
}
Expand All @@ -441,8 +436,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_mark_used {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
CACellT<TrackerTraits> *__restrict__ cells,
uint32_t const *nCells) const {
using Cell = CACellT<TrackerTraits>;
Expand All @@ -457,8 +451,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_countMultiplicity {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
TupleMultiplicity<TrackerTraits> *tupleMultiplicity) const {
for (auto it : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
Expand All @@ -479,8 +472,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_fillMultiplicity {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
TupleMultiplicity<TrackerTraits> *tupleMultiplicity) const {
for (auto it : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
Expand All @@ -501,8 +493,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_classifyTracks {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
QualityCuts<TrackerTraits> cuts) const {
for (auto it : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
Expand Down Expand Up @@ -548,8 +539,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_doStatsForTracks {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc, TkSoAView<TrackerTraits> tracks_view, Counters *counters) const {
ALPAKA_FN_ACC void operator()(Acc1D const &acc, TkSoAView<TrackerTraits> tracks_view, Counters *counters) const {
for (auto idx : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
if (tracks_view.hitIndices().size(idx) == 0)
break; //guard
Expand All @@ -566,8 +556,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_countHitInTracks {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
HitToTuple<TrackerTraits> *hitToTuple) const {
for (auto idx : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
Expand All @@ -582,8 +571,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_fillHitInTracks {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
HitToTuple<TrackerTraits> *hitToTuple) const {
for (auto idx : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
Expand All @@ -598,8 +586,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_fillHitDetIndices {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
HitsConstView<TrackerTraits> hh) const {
// copy offsets
Expand All @@ -617,8 +604,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_fillNLayers {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
cms::alpakatools::AtomicPairCounter *apc) const {
// clamp the number of tracks to the capacity of the SoA
Expand All @@ -636,8 +622,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_doStatsForHitInTracks {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
HitToTuple<TrackerTraits> const *__restrict__ hitToTuple,
Counters *counters) const {
auto &c = *counters;
Expand All @@ -654,8 +639,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_countSharedHit {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
int *__restrict__ nshared,
HitContainer<TrackerTraits> const *__restrict__ ptuples,
Quality const *__restrict__ quality,
Expand Down Expand Up @@ -693,8 +677,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {

template <typename TrackerTraits>
class Kernel_markSharedHit {
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
int const *__restrict__ nshared,
HitContainer<TrackerTraits> const *__restrict__ tuples,
Quality *__restrict__ quality,
Expand All @@ -721,8 +704,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_rejectDuplicate {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
uint16_t nmin,
bool dupPassThrough,
Expand Down Expand Up @@ -778,8 +760,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_sharedHitCleaner {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
HitsConstView<TrackerTraits> hh,
TkSoAView<TrackerTraits> tracks_view,
int nmin,
Expand Down Expand Up @@ -829,11 +810,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
}
}
};

template <typename TrackerTraits>
class Kernel_tripletCleaner {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
uint16_t nmin,
bool dupPassThrough,
Expand Down Expand Up @@ -892,8 +873,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_simpleTripletCleaner {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
TkSoAView<TrackerTraits> tracks_view,
uint16_t nmin,
bool dupPassThrough,
Expand Down Expand Up @@ -938,8 +918,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {
template <typename TrackerTraits>
class Kernel_print_found_ntuplets {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc,
ALPAKA_FN_ACC void operator()(Acc1D const &acc,
HitsConstView<TrackerTraits> hh,
TkSoAView<TrackerTraits> tracks_view,
HitToTuple<TrackerTraits> const *__restrict__ phitToTuple,
Expand Down Expand Up @@ -980,8 +959,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caHitNtupletGeneratorKernels {

class Kernel_printCounters {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const &acc, Counters const *counters) const {
ALPAKA_FN_ACC void operator()(Acc1D const &acc, Counters const *counters) const {
auto const &c = *counters;
printf(
"||Counters | nEvents | nHits | nCells | nTuples | nFitTacks | nLooseTracks | nGoodTracks | nUsedHits | "
Expand Down
Loading

0 comments on commit 51f1595

Please sign in to comment.