hn.today

The Lost Atomic Update on Loongson CPU

jia.je3 points0 comments
Screenshot of The Lost Atomic Update on Loongson CPU

While packaging the math library normaliz on a LoongArch server, maintainers hit an infinite loop: an OpenMP-parallel loop never terminated because a shared counter never reached its expected total. Debugging showed the code used #pragma omp atomic increments compiled to the LoongArch64 amadd.d instruction, but per-run counter totals diverged unpredictably. Human-driven reduction failed to produce a minimal reproducer, so the bug was shelved until AI-assisted investigation resumed months later. The AI-aided approach quickly produced a stable minimal test and revealed the root cause: the CPU’s atomic add sometimes loses updates, so atomics that should be indivisible occasionally fail under specific runtime conditions.

Further tests showed CAS and a wide range of atomic operations can suffer the same lost-update behavior. The trigger was linked to vectorized memcpy using LASX instructions (xvld); LSX vector loads and ordinary scalar reads usually did not trigger it, though later work found certain memory-address relationships can make scalar reads trigger the bug at lower probability. Loongson received the report, produced a firmware patch within two weeks that fixes the erratum with almost no performance loss, and provided test firmware that reproduces the fix; a public firmware release was expected before October 1.

Read on jia.je0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Hardware

Boards of Casio

Boards of Casio

Casio's CZP-1 synthesizer can now load custom patches via JSON files and share sounds through URLs, enabling easier sound customization and sharing. This process involves downloading patch data, loading it into the device, and using web links to exchange sounds seamlessly. (ambionix.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.