Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/RunningAverage.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDGetToken.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/Event.h"
Expand Down Expand Up @@ -358,14 +359,44 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
auto const& geometry = runCache()->get(iEvent.queue());
auto const& hits = iEvent.get(tokenHit_);

std::array<double, 1> nHitsV = {{double(hits.nHits())}};
std::array<double, 1> emptyV;

uint32_t const maxTuples = maxNumberOfTuples_.evaluate(nHitsV, emptyV);
uint32_t const maxDoublets = maxNumberOfDoublets_.evaluate(nHitsV, emptyV);
/// Don't bother if no hits on BPix1 and no good graph for that
/// (so no staring pair without BPix1 as first layer).
/// TODO: this could be extended to a more general check for
/// no hits on any of the starting layers.

bool hitsOnBPix1 = hits.offsetBPIX2() > 0;
bool startNoBPix1 = hitsOnBPix1; // one would suffice, two for readability
if (not hitsOnBPix1) {
startNoBPix1 = false;
for (const unsigned int& i : globalCache()->startingPairs_) {
if (globalCache()->pairGraph_[2 * i] > 0) {
startNoBPix1 = true;
break;
}
}
}

iEvent.emplace(tokenTrack_,
deviceAlgo_.makeTuplesAsync(hits, geometry, bf, maxDoublets, maxTuples, iEvent.queue()));
if (startNoBPix1) {
std::array<double, 1> nHitsV = {{double(hits.nHits())}};
std::array<double, 1> emptyV;

uint32_t const maxTuples = maxNumberOfTuples_.evaluate(nHitsV, emptyV);
uint32_t const maxDoublets = maxNumberOfDoublets_.evaluate(nHitsV, emptyV);

iEvent.emplace(tokenTrack_,
deviceAlgo_.makeTuplesAsync(hits, geometry, bf, maxDoublets, maxTuples, iEvent.queue()));

} else {
edm::LogWarning("CAHitNtupletAlpaka") << "No hit on BPix1 (" << hits.offsetBPIX2()
<< ") and all the starting pairs has BPix1 as inner layer.\nIt's useless "
"to run the CA. Returning with 0 tracks!";
auto& queue = iEvent.queue();
const auto device = alpaka::getDev(queue);
reco::TracksSoACollection tracks({{0, 0}}, queue);
auto ntracks_d = cms::alpakatools::make_device_view(device, tracks.view().nTracks());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to pass directly the queue:

Suggested change
auto ntracks_d = cms::alpakatools::make_device_view(device, tracks.view().nTracks());
auto ntracks_d = cms::alpakatools::make_device_view(queue, tracks.view().nTracks());

alpaka::memset(queue, ntracks_d, 0);
iEvent.emplace(tokenTrack_, std::move(tracks));
}
}

using CAHitNtupletAlpakaPhase1 = CAHitNtupletAlpaka<pixelTopology::Phase1>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
#ifdef GPU_DEBUG
std::cout << "Allocation for tuple building with: " << std::endl;
std::cout << "- nHits = " << nHits << std::endl;
std::cout << "- maxDoublets = " << maxTuples << std::endl;
std::cout << "- maxTracks = " << maxDoublets << std::endl;
std::cout << "- outerHits = " << outerHits << std::endl;
std::cout << "- maxDoublets = " << maxDoublets << std::endl;
std::cout << "- maxTracks = " << maxTuples << std::endl;

std::cout << "- nCellsToCells = " << nCellsToCells << std::endl;
std::cout << "- nHitsToCells = " << nHitsToCells << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets {
}

auto ind = alpaka::atomicAdd(acc, nCells, 1u, alpaka::hierarchy::Blocks{});
if (ind >= maxNumOfDoublets) {
if (ind >= maxNumOfDoublets or ind >= uint32_t(outerHitHisto->capacity())) {
#ifdef CA_WARNINGS
printf("Warning!!!! Too many cells (limit = %d)!\n", maxNumOfDoublets);
printf("Warning!!!! Too many cells (maxNumOfDoublets = %d - nHitsToCell = %d)!\n",
maxNumOfDoublets,
outerHitHisto->capacity());
#endif
alpaka::atomicSub(acc, nCells, 1u, alpaka::hierarchy::Blocks{});
break;
Expand Down