Skip to content
Merged
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
8 changes: 8 additions & 0 deletions Geometry/CommonTopologies/interface/SimplePixelTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ namespace pixelTopology {
static constexpr uint16_t last_barrel_detIndex = 864;

static constexpr uint32_t maxPixInModule = 6000;
static constexpr uint32_t maxPixInModuleForMorphing = 0;
static constexpr uint32_t maxIterClustering = 16;

static constexpr uint32_t maxNumClustersPerModules = phase2PixelTopology::maxNumClustersPerModules;
static constexpr uint32_t maxHitsInModule = phase2PixelTopology::maxNumClustersPerModules;

Expand Down Expand Up @@ -471,6 +474,9 @@ namespace pixelTopology {
static constexpr uint16_t last_barrel_detIndex = 1184;

static constexpr uint32_t maxPixInModule = 6000;
static constexpr uint32_t maxPixInModuleForMorphing = maxPixInModule * 2 / 5;
static constexpr uint32_t maxIterClustering = 24;

static constexpr uint32_t maxNumClustersPerModules = phase1PixelTopology::maxNumClustersPerModules;
static constexpr uint32_t maxHitsInModule = phase1PixelTopology::maxNumClustersPerModules;

Expand Down Expand Up @@ -582,6 +588,8 @@ namespace pixelTopology {
static constexpr uint32_t maxNumberOfQuadruplets = maxNumberOfTuples;

static constexpr uint32_t maxPixInModule = 10000;
static constexpr uint32_t maxPixInModuleForMorphing = maxPixInModule * 1 / 10;
static constexpr uint32_t maxIterClustering = 32;

static constexpr uint32_t maxNumOfActiveDoublets =
maxNumberOfDoublets / 4; // TODO need to think a better way to avoid this duplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering {
template <typename TrackerTraits>
struct FindClus {
// assume that we can cover the whole module with up to 16 blockDimension-wide iterations
static constexpr uint32_t maxIterGPU = 16;

// this must be larger than maxPixInModule / maxIterGPU, and should be a multiple of the warp size
// this must be larger than maxPixInModule / maxIterClustering, and should be a multiple of the warp size
static constexpr uint32_t maxElementsPerBlock =
cms::alpakatools::round_up_by(TrackerTraits::maxPixInModule / maxIterGPU, 128);
cms::alpakatools::round_up_by(TrackerTraits::maxPixInModule / TrackerTraits::maxIterClustering, 64);
static constexpr uint32_t maxElementsPerBlockMorph = cms::alpakatools::round_up_by(
(TrackerTraits::maxPixInModule + TrackerTraits::maxPixInModuleForMorphing) / TrackerTraits::maxIterClustering,
64);
static_assert(maxElementsPerBlockMorph >= maxElementsPerBlock);

ALPAKA_FN_ACC void operator()(Acc1D const& acc,
SiPixelDigisSoAView digi_view,
Expand Down Expand Up @@ -259,11 +262,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering {
}
}

using Hist = cms::alpakatools::HistoContainer<uint16_t,
TrackerTraits::clusterBinning,
TrackerTraits::maxPixInModule,
TrackerTraits::clusterBits,
uint16_t>;
using Hist =
cms::alpakatools::HistoContainer<uint16_t,
TrackerTraits::clusterBinning,
TrackerTraits::maxPixInModule + TrackerTraits::maxPixInModuleForMorphing,
TrackerTraits::clusterBits,
uint16_t>;
constexpr int warpSize = cms::alpakatools::warpSize;
auto& hist = alpaka::declareSharedVar<Hist, __COUNTER__>(acc);
auto& ws = alpaka::declareSharedVar<typename Hist::Counter[warpSize], __COUNTER__>(acc);
Expand Down Expand Up @@ -568,15 +572,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering {
#endif

[[maybe_unused]] const uint32_t blockDimension = alpaka::getWorkDiv<alpaka::Block, alpaka::Elems>(acc)[0u];
// assume that we can cover the whole module with up to maxIterGPU blockDimension-wide iterations
ALPAKA_ASSERT_ACC((hist.size() / blockDimension) < maxIterGPU);
// assume that we can cover the whole module with up to maxIterClustering blockDimension-wide iterations
ALPAKA_ASSERT_ACC((hist.size() / blockDimension) < TrackerTraits::maxIterClustering);

// number of elements per thread
constexpr uint32_t maxElements =
cms::alpakatools::requires_single_thread_per_block_v<Acc1D> ? maxElementsPerBlock : 1;
const uint32_t maxElements = cms::alpakatools::requires_single_thread_per_block_v<Acc1D>
? (enableDigiMorphing ? maxElementsPerBlockMorph : maxElementsPerBlock)
: 1;

#ifdef GPU_DEBUG
const auto nElementsPerThread = alpaka::getWorkDiv<alpaka::Thread, alpaka::Elems>(acc)[0u];
if (nElementsPerThread > maxElements)
printf("This is WRONG: nElementsPerThread > maxElements : %d > %d\n", nElementsPerThread, maxElements);
else if (thisModuleId % 500 == 1)
printf("This is OK: nElementsPerThread <= maxElements : %d <= %d\n", nElementsPerThread, maxElements);
#endif

ALPAKA_ASSERT_ACC((alpaka::getWorkDiv<alpaka::Thread, alpaka::Elems>(acc)[0u] <= maxElements));

constexpr unsigned int maxIter = maxIterGPU * maxElements;
const unsigned int maxIter = TrackerTraits::maxIterClustering * maxElements;

// nearest neighbours (nn)
constexpr int maxNeighbours = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
digiMorphingConfig_.applyDigiMorphing = iConfig.getParameter<bool>("DoDigiMorphing");
digiMorphingConfig_.maxFakesInModule = iConfig.getParameter<uint32_t>("MaxFakesInModule");

if (digiMorphingConfig_.maxFakesInModule > TrackerTraits::maxPixInModuleForMorphing) {
throw cms::Exception("Configuration")
<< "[SiPixelDigiMorphing]:"
<< " maxFakesInModule should be <= " << TrackerTraits::maxPixInModuleForMorphing
<< " (TrackerTraits::maxPixInModuleForMorphing)"
<< " while " << digiMorphingConfig_.maxFakesInModule << " was provided at config level.\n";
}

// regions
if (!iConfig.getParameter<edm::ParameterSet>("Regions").getParameterNames().empty()) {
regions_ = std::make_unique<PixelUnpackingRegions>(iConfig, consumesCollector());
Expand All @@ -233,7 +241,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
desc.add<double>("VCaltoElectronOffset", -60.f);
desc.add<double>("VCaltoElectronOffset_L1", -670.f);
desc.add<bool>("DoDigiMorphing", false);
desc.add<uint32_t>("MaxFakesInModule", TrackerTraits::maxPixInModule * 2 / 5);
desc.add<uint32_t>("MaxFakesInModule", TrackerTraits::maxPixInModuleForMorphing);

desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,20 +570,23 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

{
const int blocks = 64;
const auto elementsPerBlockFindClus = FindClus<TrackerTraits>::maxElementsPerBlock;
const auto workDivMaxNumModules = cms::alpakatools::make_workdiv<Acc1D>(blocks, elementsPerBlockFindClus);

const auto elementsPerBlockFindClus = digiMorphingConfig.applyDigiMorphing
? FindClus<TrackerTraits>::maxElementsPerBlockMorph
: FindClus<TrackerTraits>::maxElementsPerBlock;
const auto workDivFindClus = cms::alpakatools::make_workdiv<Acc1D>(blocks, elementsPerBlockFindClus);

// allocate a transient collection for the fake pixels recovered by the digi morphing algorithm
auto fakes_d = SiPixelDigisSoACollection(blocks * digiMorphingConfig.maxFakesInModule, queue);

#ifdef GPU_DEBUG
std::cout << " FindClus kernel launch with " << numberOfModules << " blocks of " << elementsPerBlockFindClus
alpaka::wait(queue);
std::cout << "FindClus kernel launch with " << blocks << " blocks of " << elementsPerBlockFindClus
<< " threadsPerBlockOrElementsPerThread\n";
#endif

// Use device buffer created by producer and the module count stored in digiMorphingConfig
alpaka::exec<Acc1D>(queue,
workDivMaxNumModules,
workDivFindClus,
FindClus<TrackerTraits>{},
digis_d->view(),
fakes_d.view(),
Expand Down