9 #include <alpaka/alpaka.hpp> 53 DetIdGPU
detId = {cablingMap.rawId()[
index], cablingMap.rocInDet()[
index], cablingMap.moduleId()[
index]};
62 int slopeRow = 0, slopeCol = 0;
63 int rowOffset = 0, colOffset = 0;
66 if (
side == -1 && layer != 1) {
67 if (rocIdInDetUnit < 8) {
79 if (rocIdInDetUnit < 8) {
94 if (rocIdInDetUnit < 8) {
106 if (rocIdInDetUnit < 8) {
121 uint32_t gRow = rowOffset + slopeRow *
local.row;
122 uint32_t gCol = colOffset + slopeCol *
local.col;
129 template <
bool debug = false>
131 uint8_t errorType = 0;
136 printf(
"Error in Fed: %i, invalid channel Id (errorType = 35\n)",
fedId);
142 printf(
"Error in Fed: %i, invalid ROC Id (errorType = 36)\n",
fedId);
148 printf(
"Error in Fed: %i, invalid dcol/pixel value (errorType = 37)\n",
fedId);
154 printf(
"Error in Fed: %i, dcol/pixel read out of order (errorType = 38)\n",
fedId);
160 printf(
"Cabling check returned unexpected result, status = %i\n",
status);
171 ALPAKA_FN_ACC
bool dcolIsValid(uint32_t dcol, uint32_t pxid) {
return ((dcol < 26) & (2 <= pxid) & (pxid < 162)); }
174 template <
bool debug = false>
175 ALPAKA_FN_ACC uint8_t
180 bool errorFound =
false;
187 if (
index > 1 &&
index <= cablingMap.size()) {
188 if (!(link == cablingMap.link()[
index] && 1 == cablingMap.roc()[
index]))
193 printf(
"Invalid ROC = 25 found (errorType = 25)\n");
198 printf(
"Gap word found (errorType = 26)\n");
203 printf(
"Dummy word found (errorType = 27)\n");
208 printf(
"Error fifo nearly full (errorType = 28)\n");
214 printf(
"Timeout on a channel (errorType = 29)\n");
217 printf(
"...2nd errorType=29 error, skip\n");
225 printf(
"TBM error trailer (errorType = 30)\n");
226 int stateMatch_bits = 4;
227 int stateMatch_shift = 8;
228 uint32_t stateMatch_mask = ~(~uint32_t(0) << stateMatch_bits);
229 int stateMatch = (errorWord >> stateMatch_shift) & stateMatch_mask;
230 if (stateMatch != 1 && stateMatch != 8) {
232 printf(
"FED error 30 with unexpected State Bits (errorType = 30)\n");
242 printf(
"Event number error (errorType = 31)\n");
250 return errorFound ? errorType : 0;
254 template <
bool debug = false>
255 ALPAKA_FN_ACC uint32_t
257 uint32_t rID = 0xffffffff;
290 template <
bool debug = false>
292 template <
typename TAcc>
295 const unsigned char *modToUnp,
296 const uint32_t wordCounter,
297 const uint32_t *
word,
308 auto dvgi = digisView[gIndex];
323 uint32_t
ww =
word[gIndex];
332 uint8_t errorType = checkROC<debug>(
ww,
fedId, link, cablingMap);
335 uint32_t
rawId = getErrRawID<debug>(
fedId,
ww, errorType, cablingMap);
336 if (
rawId != 0xffffffff)
348 printf(
"spurious roc %d found on link %d, detector %d (index %d)\n",
roc, link,
rawId, gIndex);
351 uint8_t
error = conversionError<debug>(
fedId, 2);
360 if (useQualityInfo) {
361 skipROC = cablingMap.badRocs()[
index];
365 skipROC = modToUnp[
index];
383 side = (panel == 1) ? -1 : 1;
394 uint8_t
error = conversionError<debug>(
fedId, 3);
398 printf(
"BPIX1 Error status: %i\n",
error);
406 uint32_t
col = dcol * 2 + pxid % 2;
410 uint8_t
error = conversionError<debug>(
fedId, 3);
414 printf(
"Error status: %i %d %d %d %d\n",
error, dcol, pxid,
fedId,
roc);
420 dvgi.xx() = globalPix.
row;
421 dvgi.yy() = globalPix.
col;
424 dvgi.moduleId() =
detId.moduleId;
425 dvgi.rawIdArr() =
rawId;
431 template <
typename TrackerTraits>
433 template <
typename TAcc>
441 [[maybe_unused]]
const uint32_t blockIdxLocal(alpaka::getIdx<alpaka::Grid, alpaka::Blocks>(acc)[0u]);
443 [[maybe_unused]]
const uint32_t
gridDimension(alpaka::getWorkDiv<alpaka::Grid, alpaka::Blocks>(acc)[0u]);
455 auto &&
ws = alpaka::declareSharedVar<uint32_t[32], __COUNTER__>(acc);
458 acc, clus_view.clusModuleStart() + 1, clus_view.clusModuleStart() + 1, 1024,
ws);
461 acc, clus_view.clusModuleStart() + 1024 + 1, clus_view.clusModuleStart() + 1024 + 1, leftModules,
ws);
465 acc, clus_view.clusModuleStart() + 2048 + 1, clus_view.clusModuleStart() + 2048 + 1, 1024,
ws);
467 clus_view.clusModuleStart() + 3072 + 1,
468 clus_view.clusModuleStart() + 3072 + 1,
475 clus_view[
i].clusModuleStart() += clus_view[1024].clusModuleStart();
477 alpaka::syncBlockThreads(acc);
481 clus_view[
i].clusModuleStart() += clus_view[2048].clusModuleStart();
483 alpaka::syncBlockThreads(acc);
486 clus_view[
i].clusModuleStart() += clus_view[3072].clusModuleStart();
488 alpaka::syncBlockThreads(acc);
504 if (
i == bpix2 ||
i == fpix1)
505 printf(
"moduleStart %d %d\n",
i, clus_view[
i].
moduleStart());
511 if (clus_view[
i].clusModuleStart() > MAX_HITS)
512 clus_view[
i].clusModuleStart() = MAX_HITS;
519 template <
typename TrackerTraits>
524 const unsigned char *modToUnp,
527 const uint32_t wordCounter,
528 const uint32_t fedCounter,
532 nDigis = wordCounter;
535 std::cout <<
"decoding " << wordCounter <<
" digis." << std::endl;
545 const int threadsPerBlockOrElementsPerThread =
546 cms::alpakatools::requires_single_thread_per_block_v<Acc1D> ? 32 : 512;
549 const auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(
blocks, threadsPerBlockOrElementsPerThread);
550 assert(0 == wordCounter % 2);
552 auto word_d = cms::alpakatools::make_device_buffer<uint32_t[]>(
queue, wordCounter);
556 auto fedId_d = cms::alpakatools::make_device_buffer<uint8_t[]>(
queue, wordCounter / 2);
557 alpaka::memcpy(
queue, word_d, wordFed.
word(), wordCounter);
558 alpaka::memcpy(
queue, fedId_d, wordFed.
fedId(), wordCounter / 2);
561 alpaka::exec<Acc1D>(
queue,
570 digiErrors_d->view(),
574 alpaka::exec<Acc1D>(
queue,
583 digiErrors_d->view(),
590 std::cout <<
"RawToDigi_kernel was run smoothly!" << std::endl;
600 const int threadsPerBlockOrElementsPerThread = []() {
601 if constexpr (std::is_same_v<Device, alpaka_common::DevHost>) {
609 threadsPerBlockOrElementsPerThread);
610 const auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(
blocks, threadsPerBlockOrElementsPerThread);
613 alpaka::exec<Acc1D>(
queue,
622 alpaka::exec<Acc1D>(
queue,
633 std::cout <<
"CountModules kernel launch with " <<
blocks <<
" blocks of " << threadsPerBlockOrElementsPerThread
634 <<
" threadsPerBlockOrElementsPerThread\n";
638 queue, workDiv, CountModules<TrackerTraits>{}, digis_d->view(), clusters_d->view(), wordCounter);
640 auto moduleStartFirstElement =
642 alpaka::memcpy(
queue, nModules_Clusters_h, moduleStartFirstElement);
644 const auto elementsPerBlockFindClus = FindClus<TrackerTraits>::maxElementsPerBlock;
645 const auto workDivMaxNumModules =
646 cms::alpakatools::make_workdiv<Acc1D>(
numberOfModules, elementsPerBlockFindClus);
649 <<
" threadsPerBlockOrElementsPerThread\n";
652 queue, workDivMaxNumModules, FindClus<TrackerTraits>{}, digis_d->view(), clusters_d->view(), wordCounter);
657 constexpr auto threadsPerBlockChargeCut = 256;
658 const auto workDivChargeCut = cms::alpakatools::make_workdiv<Acc1D>(
numberOfModules, threadsPerBlockChargeCut);
660 alpaka::exec<Acc1D>(
queue,
673 const auto workDivOneBlock = cms::alpakatools::make_workdiv<Acc1D>(1u, 1024u);
683 alpaka::getDev(
queue), clusters_d->const_view().clusModuleStart() +
startBPIX2, 1u);
685 alpaka::memcpy(
queue, nModules_Clusters_h_1, clusModuleStartLastElement);
688 alpaka::memcpy(
queue, nModules_Clusters_h_2, bpix2ClusterStart);
692 std::cout <<
"SiPixelClusterizerAlpaka results:" << std::endl
693 <<
" > no. of digis: " << nDigis << std::endl
694 <<
" > no. of active modules: " << nModules_Clusters_h[0] << std::endl
695 <<
" > no. of clusters: " << nModules_Clusters_h[1] << std::endl
696 <<
" > bpix2 offset: " << nModules_Clusters_h[2] << std::endl;
702 template <
typename TrackerTraits>
707 const uint32_t numDigis) {
713 const auto threadsPerBlockOrElementsPerThread = 512;
716 const auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(
blocks, threadsPerBlockOrElementsPerThread);
723 std::cout <<
"CountModules kernel launch with " <<
blocks <<
" blocks of " << threadsPerBlockOrElementsPerThread
724 <<
" threadsPerBlockOrElementsPerThread\n";
727 queue, workDiv, CountModules<pixelTopology::Phase2>{}, digis_view, clusters_d->view(), numDigis);
729 auto moduleStartFirstElement =
731 alpaka::memcpy(
queue, nModules_Clusters_h, moduleStartFirstElement);
733 const auto elementsPerBlockFindClus = FindClus<TrackerTraits>::maxElementsPerBlock;
734 const auto workDivMaxNumModules =
735 cms::alpakatools::make_workdiv<Acc1D>(
numberOfModules, elementsPerBlockFindClus);
739 <<
" threadsPerBlockOrElementsPerThread\n";
742 queue, workDivMaxNumModules, FindClus<TrackerTraits>{}, digis_view, clusters_d->view(), numDigis);
748 alpaka::exec<Acc1D>(
queue,
749 workDivMaxNumModules,
762 const auto workDivOneBlock = cms::alpakatools::make_workdiv<Acc1D>(1u, 1024u);
771 alpaka::getDev(
queue), clusters_d->const_view().clusModuleStart() +
startBPIX2, 1u);
773 alpaka::memcpy(
queue, nModules_Clusters_h_1, clusModuleStartLastElement);
776 alpaka::memcpy(
queue, nModules_Clusters_h_2, bpix2ClusterStart);
780 std::cout <<
"SiPixelPhase2DigiToCluster: results \n" 781 <<
" > no. of digis: " << numDigis << std::endl
782 <<
" > no. of active modules: " << nModules_Clusters_h[0] << std::endl
783 <<
" > no. of clusters: " << nModules_Clusters_h[1] << std::endl
784 <<
" > bpix2 offset: " << nModules_Clusters_h[2] << std::endl;
const uint32_t gridDimension(alpaka::getWorkDiv< alpaka::Grid, alpaka::Blocks >(acc)[0u])
void makePhase1ClustersAsync(Queue &queue, const SiPixelClusterThresholds clusterThresholds, const SiPixelMappingSoAConstView &cablingMap, const unsigned char *modToUnp, const SiPixelGainCalibrationForHLTSoAConstView &gains, const WordFedAppender &wordFed, const uint32_t wordCounter, const uint32_t fedCounter, bool useQualityInfo, bool includeErrors, bool debug)
constexpr uint32_t moduleStartBit
constexpr uint32_t getRow(uint32_t ww)
constexpr uint32_t ERROR_mask
constexpr uint32_t getCol(uint32_t ww)
constexpr uint32_t layerMask
constexpr uint32_t numRowsInRoc
ALPAKA_FN_ACC int side(int ieta, int iphi)
constexpr uint32_t ROC_shift
static const int kSubdetOffset
static constexpr uint16_t numberOfModules
void makePhase2ClustersAsync(Queue &queue, const SiPixelClusterThresholds clusterThresholds, SiPixelDigisSoAView &digis_view, const uint32_t numDigis)
constexpr uint16_t numberOfModules
ALPAKA_FN_ACC uint32_t getErrRawID(uint8_t fedId, uint32_t errWord, uint32_t errorType, const SiPixelMappingSoAConstView &cablingMap)
constexpr uint32_t panelMask
ALPAKA_FN_ACC void operator()(const TAcc &acc, const SiPixelMappingSoAConstView &cablingMap, const unsigned char *modToUnp, const uint32_t wordCounter, const uint32_t *word, const uint8_t *fedIds, SiPixelDigisSoAView digisView, SiPixelDigiErrorsSoAView err, bool useQualityInfo, bool includeErrors) const
constexpr uint32_t getPxId(uint32_t ww)
static constexpr uint32_t const * layerStart
ALPAKA_FN_ACC ::pixelDetails::Pixel frameConversion(bool bpix, int side, uint32_t layer, uint32_t rocIdInDetUnit, ::pixelDetails::Pixel local)
static const int kSubdetMask
ALPAKA_FN_ACC bool dcolIsValid(uint32_t dcol, uint32_t pxid)
T1 atomicInc(T1 *a, T2 b)
constexpr uint32_t getDCol(uint32_t ww)
constexpr uint32_t OMIT_ERR_shift
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::conditional_t< std::is_same_v< Device, alpaka::DevCpu >, SiPixelDigisHost, SiPixelDigisDevice< Device > > SiPixelDigisSoACollection
constexpr uint32_t getADC(uint32_t ww)
std::vector< Block > Blocks
constexpr uint32_t getLink(uint32_t ww)
constexpr unsigned int MAX_ROC
constexpr uint32_t ROC_mask
constexpr uint32_t moduleMask
constexpr uint32_t maxROCIndex
constexpr uint16_t invalidModuleId
ALPAKA_FN_ACC ::pixelDetails::DetIdGPU getRawId(const SiPixelMappingSoAConstView &cablingMap, uint8_t fed, uint32_t link, uint32_t roc)
constexpr uint32_t getROC(uint32_t ww)
constexpr float gains[NGAINS]
ALPAKA_FN_ACC uint8_t checkROC(uint32_t errorWord, uint8_t fedId, uint32_t link, const SiPixelMappingSoAConstView &cablingMap)
constexpr uint32_t LINK_shift
constexpr uint32_t panelStartBit
ALPAKA_FN_ACC bool isBarrel(uint32_t rawId)
ALPAKA_FN_ACC bool rocRowColIsValid(uint32_t rocRow, uint32_t rocCol)
constexpr uint32_t layerStartBit
uint16_t *__restrict__ uint16_t const *__restrict__ uint32_t const *__restrict__ moduleStart
static constexpr uint32_t layerStart[numberOfLayers+1]
constexpr uint32_t OMIT_ERR_mask
ALPAKA_FN_ACC uint8_t conversionError(uint8_t fedId, uint8_t status)
std::conditional_t< std::is_same_v< Device, alpaka::DevCpu >, SiPixelDigiErrorsHost, SiPixelDigiErrorsDevice< Device > > SiPixelDigiErrorsSoACollection
constexpr uint32_t numColsInRoc
ALPAKA_FN_ACC void operator()(const TAcc &acc, SiPixelClustersSoAView clus_view) const
ALPAKA_ASSERT_ACC(offsets)
constexpr uint32_t LINK_mask
constexpr unsigned int MAX_LINK
constexpr uint16_t invalidModuleId
std::conditional_t< std::is_same_v< Device, alpaka::DevCpu >, SiPixelClustersHost, SiPixelClustersDevice< Device > > SiPixelClustersSoACollection
constexpr uint32_t maxHitsInModule()