From 479229d0daeb2a1c7bd65c6ab73b276f33d34c24 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sat, 18 Apr 2026 15:21:40 -0400 Subject: [PATCH] Lg1:pcloudStimProd: Add ambience trigger debugging --- .../livoxGen1/pcloudStimulusProducer.cpp | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp b/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp index 734f524..cb6700e 100644 --- a/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp +++ b/stimBuffApis/livoxGen1/pcloudStimulusProducer.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -14,9 +15,32 @@ #include "livoxGen1.h" #include "pcloudStimulusProducer.h" +#ifndef SMO_DEBUG_PCLOUD_AMBIENCE_INTRIN +#define SMO_DEBUG_PCLOUD_AMBIENCE_INTRIN 0 +#endif + namespace smo { namespace stim_buff { +#if SMO_DEBUG_PCLOUD_AMBIENCE_INTRIN +namespace { + +char ambienceComparatorOpChar(ParamComparatorOp op) +{ + switch (op) + { + case OP_CMP_GT: + return '>'; + case OP_CMP_LT: + return '<'; + } + + return '?'; +} + +} // namespace +#endif + extern const SmoCallbacks* smoHooksPtr; // OpenCL kernels are used to collate and produce our StimFrames. @@ -551,6 +575,28 @@ public: [[maybe_unused]] std::shared_ptr context, bool success, StimulusFrame& /*stimulusFrame*/) { +#if SMO_DEBUG_PCLOUD_AMBIENCE_INTRIN + uint32_t logLightPassbandCount = 0; + uint32_t logDarkPassbandCount = 0; + bool logLightAmbience = false; + bool logDarkAmbience = false; + if (success) + { + if (context->lightAmbienceStimFrame.has_value()) + { + logLightPassbandCount = *reinterpret_cast( + context->lightAmbienceStimFrame->get().slotDesc.vaddr); + logLightAmbience = true; + } + if (context->darkAmbienceStimFrame.has_value()) + { + logDarkPassbandCount = *reinterpret_cast( + context->darkAmbienceStimFrame->get().slotDesc.vaddr); + logDarkAmbience = true; + } + } +#endif + // Release intensity frame if it was used if (context->intensityStimFrame.has_value()) { context->intensityStimFrame->get().lock.writeRelease(); @@ -591,6 +637,77 @@ public: } } +#if SMO_DEBUG_PCLOUD_AMBIENCE_INTRIN + if (logLightAmbience) + { + auto lightBuff = + pcloudProducer.lightAmbienceStimulusBuffer.load( + std::memory_order_acquire); + if (lightBuff) + { + std::cerr << __func__ << ": pcloudLightAmbience " + << "passbandCount=" << logLightPassbandCount + << " (per-slot avg intensity " + << ambienceComparatorOpChar( + lightBuff->passbandCountGtComparator.op) + << " " << lightBuff->passbandCountGtComparator.value + << ")"; + if (lightBuff->negtrinInterestConfig.has_value()) + { + const auto& nc = *lightBuff->negtrinInterestConfig; + std::cerr << " negtrinInterestThr=" << nc.threshold; + if (nc.percentage != 0U) + { + std::cerr << " (from " << nc.percentage << "%)"; + } + std::cerr << " meetsNegtrinInterest=" + << (lightBuff->shouldTriggerNegtrinEvent( + logLightPassbandCount) + ? "yes" : "no"); + } + else + { + std::cerr << " negtrinInterest(n/a)"; + } + std::cerr << std::endl; + } + } + if (logDarkAmbience) + { + auto darkBuff = + pcloudProducer.darkAmbienceStimulusBuffer.load( + std::memory_order_acquire); + if (darkBuff) + { + std::cerr << __func__ << ": pcloudDarkAmbience " + << "passbandCount=" << logDarkPassbandCount + << " (per-slot avg intensity " + << ambienceComparatorOpChar( + darkBuff->passbandCountLtComparator.op) + << " " << darkBuff->passbandCountLtComparator.value + << ")"; + if (darkBuff->postrinInterestConfig.has_value()) + { + const auto& pc = *darkBuff->postrinInterestConfig; + std::cerr << " postrinInterestThr=" << pc.threshold; + if (pc.percentage != 0U) + { + std::cerr << " (from " << pc.percentage << "%)"; + } + std::cerr << " meetsPostrinInterest=" + << (darkBuff->shouldTriggerPostrinEvent( + logDarkPassbandCount) + ? "yes" : "no"); + } + else + { + std::cerr << " postrinInterest(n/a)"; + } + std::cerr << std::endl; + } + } +#endif + #if 0 // Print execution durations auto assemblyDuration = pcloudProducer.ioUringAssemblyEngine.getAssemblyDuration();