Thanks, that guided me to the correct fix.I think there is only one copy of these variables and consequently a race when they are updated inside the loop.
The scope of the local variables was not private, so I had to specify that with private() clause, here for OpenMP 4.5 used by gcc 12 of PiOS:
https://www.openmp.org/wp-content/uploa ... f#page=201
firstprivate would initialize the private variables under same name and update non-private originals on exit of parallel execution. That would be fine for min as well as pos determination, but for summation variable cnt it would not help.
In addition I had to remove nowait as well.
The new version
https://raw.githubusercontent.com/Herma ... insert.cpp
now works on all my systems, including the Pi5:By default top updates every 3 seconds, because Pi5 running with 396 CPU% each update adds nearly 12 seconds. If you run this on your Pi5 execution times will be likely a bit longer, because my Pi5 runs at 3GHz permanently (default is 2.4GHz):
Code:
pi@raspberrypi5:~ $ freqmin=cur=3000000=maxpi@raspberrypi5:~ $ So now after parallel execution min, pos and cnt (number of same min value positions) are available. cnt can be used as @ejolson showed to select one of the p different position with same min value with probability 1/p, or used otherwise.
P.S:
With this fix openmp developement can be done on my Pi5 again.
Statistics: Posted by HermannSW — Wed Sep 24, 2025 7:56 am