PcloudStimProd: make sh_ptrs to Pcloud*StimBuff atomic<>

This change is a bit pedantic, but since these vars aren't accessed
in any hotpath, it's fine to be pedantic. We made these sh_ptrs
atomic so we can use acquire and release side effects when loading
and storing them. This doesn't eliminate the problem of seeing
inconsistent state across microcontrollers, but it helps with simple
accesses like these ones we already do.
This commit is contained in:
2025-11-26 00:11:40 -04:00
parent edab71b823
commit 5cce473e01
4 changed files with 46 additions and 31 deletions
@@ -650,9 +650,14 @@ bool OpenClCollatingAndMeshingEngine::setupCollateDgramsArgs(
// Set ambienceHighVal argument (arg 4)
uint32_t ambienceHighVal = 0;
if (ambienceStimFrame.has_value() && parent.ambienceStimulusBuffer) {
ambienceHighVal = parent.ambienceStimulusBuffer->ambienceHighVal;
std::shared_ptr<PcloudAmbienceStimulusBuffer> ambienceBuff = nullptr;
if (ambienceStimFrame.has_value()
&& (ambienceBuff = parent.ambienceStimulusBuffer.load(
std::memory_order_acquire)))
{
ambienceHighVal = ambienceBuff->ambienceHighVal;
}
err = clSetKernelArg(collateKernel, 4, sizeof(uint32_t), &ambienceHighVal);
if (err != CL_SUCCESS)
{