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>
449 [[maybe_unused]]
const uint32_t blockIdxLocal(alpaka::getIdx<alpaka::Grid, alpaka::Blocks>(acc)[0u]);
451 [[maybe_unused]]
const uint32_t
gridDimension(alpaka::getWorkDiv<alpaka::Grid, alpaka::Blocks>(acc)[0u]);
462 auto &&
ws = alpaka::declareSharedVar<uint32_t[32], __COUNTER__>(acc);
465 acc, clus_view.clusModuleStart() + 1, clus_view.clusModuleStart() + 1, 1024,
ws);
468 acc, clus_view.clusModuleStart() + 1024 + 1, clus_view.clusModuleStart() + 1024 + 1, leftModules,
ws);
472 acc, clus_view.clusModuleStart() + 2048 + 1, clus_view.clusModuleStart() + 2048 + 1, 1024,
ws);
474 clus_view.clusModuleStart() + 3072 + 1,
475 clus_view.clusModuleStart() + 3072 + 1,
482 clus_view[
i].clusModuleStart() += clus_view[1024].clusModuleStart();
484 alpaka::syncBlockThreads(acc);
488 clus_view[
i].clusModuleStart() += clus_view[2048].clusModuleStart();
490 alpaka::syncBlockThreads(acc);
493 clus_view[
i].clusModuleStart() += clus_view[3072].clusModuleStart();
495 alpaka::syncBlockThreads(acc);
511 if (
i == bpix2 ||
i == fpix1)
512 printf(
"moduleStart %d %d\n",
i, clus_view[
i].
moduleStart());
521 template <
typename TrackerTraits>
526 const unsigned char *modToUnp,
529 const uint32_t wordCounter,
530 const uint32_t fedCounter,
534 nDigis = wordCounter;
537 std::cout <<
"decoding " << wordCounter <<
" digis." << std::endl;
547 const int threadsPerBlockOrElementsPerThread =
548 cms::alpakatools::requires_single_thread_per_block_v<Acc1D> ? 32 : 512;
551 const auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(
blocks, threadsPerBlockOrElementsPerThread);
552 assert(0 == wordCounter % 2);
554 auto word_d = cms::alpakatools::make_device_buffer<uint32_t[]>(
queue, wordCounter);
558 auto fedId_d = cms::alpakatools::make_device_buffer<uint8_t[]>(
queue, wordCounter / 2);
559 alpaka::memcpy(
queue, word_d, wordFed.
word(), wordCounter);
560 alpaka::memcpy(
queue, fedId_d, wordFed.
fedId(), wordCounter / 2);
563 alpaka::exec<Acc1D>(
queue,
572 digiErrors_d->view(),
576 alpaka::exec<Acc1D>(
queue,
585 digiErrors_d->view(),
592 std::cout <<
"RawToDigi_kernel was run smoothly!" << std::endl;
602 const int threadsPerBlockOrElementsPerThread = []() {
603 if constexpr (std::is_same_v<Device, alpaka_common::DevHost>) {
611 threadsPerBlockOrElementsPerThread);
612 const auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(
blocks, threadsPerBlockOrElementsPerThread);
615 alpaka::exec<Acc1D>(
queue,
624 alpaka::exec<Acc1D>(
queue,
635 std::cout <<
"CountModules kernel launch with " <<
blocks <<
" blocks of " << threadsPerBlockOrElementsPerThread
636 <<
" threadsPerBlockOrElementsPerThread\n";
640 queue, workDiv, CountModules<TrackerTraits>{}, digis_d->view(), clusters_d->view(), wordCounter);
642 auto moduleStartFirstElement =
644 alpaka::memcpy(
queue, nModules_Clusters_h, moduleStartFirstElement);
646 const auto elementsPerBlockFindClus = FindClus<TrackerTraits>::maxElementsPerBlock;
647 const auto workDivMaxNumModules =
648 cms::alpakatools::make_workdiv<Acc1D>(
numberOfModules, elementsPerBlockFindClus);
651 <<
" threadsPerBlockOrElementsPerThread\n";
654 queue, workDivMaxNumModules, FindClus<TrackerTraits>{}, digis_d->view(), clusters_d->view(), wordCounter);
659 constexpr auto threadsPerBlockChargeCut = 256;
660 const auto workDivChargeCut = cms::alpakatools::make_workdiv<Acc1D>(
numberOfModules, threadsPerBlockChargeCut);
662 alpaka::exec<Acc1D>(
queue,
675 const auto workDivOneBlock = cms::alpakatools::make_workdiv<Acc1D>(1u, 1024u);
685 alpaka::getDev(
queue), clusters_d->const_view().clusModuleStart() +
startBPIX2, 1u);
687 alpaka::memcpy(
queue, nModules_Clusters_h_1, clusModuleStartLastElement);
690 alpaka::memcpy(
queue, nModules_Clusters_h_2, bpix2ClusterStart);
694 std::cout <<
"SiPixelClusterizerAlpaka results:" << std::endl
695 <<
" > no. of digis: " << nDigis << std::endl
696 <<
" > no. of active modules: " << nModules_Clusters_h[0] << std::endl
697 <<
" > no. of clusters: " << nModules_Clusters_h[1] << std::endl
698 <<
" > bpix2 offset: " << nModules_Clusters_h[2] << std::endl;
704 template <
typename TrackerTraits>
709 const uint32_t numDigis) {
715 const auto threadsPerBlockOrElementsPerThread = 512;
718 const auto workDiv = cms::alpakatools::make_workdiv<Acc1D>(
blocks, threadsPerBlockOrElementsPerThread);
725 std::cout <<
"CountModules kernel launch with " <<
blocks <<
" blocks of " << threadsPerBlockOrElementsPerThread
726 <<
" threadsPerBlockOrElementsPerThread\n";
729 queue, workDiv, CountModules<pixelTopology::Phase2>{}, digis_view, clusters_d->view(), numDigis);
731 auto moduleStartFirstElement =
733 alpaka::memcpy(
queue, nModules_Clusters_h, moduleStartFirstElement);
735 const auto elementsPerBlockFindClus = FindClus<TrackerTraits>::maxElementsPerBlock;
736 const auto workDivMaxNumModules =
737 cms::alpakatools::make_workdiv<Acc1D>(
numberOfModules, elementsPerBlockFindClus);
741 <<
" threadsPerBlockOrElementsPerThread\n";
744 queue, workDivMaxNumModules, FindClus<TrackerTraits>{}, digis_view, clusters_d->view(), numDigis);
750 alpaka::exec<Acc1D>(
queue,
751 workDivMaxNumModules,
764 const auto workDivOneBlock = cms::alpakatools::make_workdiv<Acc1D>(1u, 1024u);
773 alpaka::getDev(
queue), clusters_d->const_view().clusModuleStart() +
startBPIX2, 1u);
775 alpaka::memcpy(
queue, nModules_Clusters_h_1, clusModuleStartLastElement);
778 alpaka::memcpy(
queue, nModules_Clusters_h_2, bpix2ClusterStart);
782 std::cout <<
"SiPixelPhase2DigiToCluster: results \n" 783 <<
" > no. of digis: " << numDigis << std::endl
784 <<
" > no. of active modules: " << nModules_Clusters_h[0] << std::endl
785 <<
" > no. of clusters: " << nModules_Clusters_h[1] << std::endl
786 <<
" > 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()