------- Comment #18 from jakub at gcc dot gnu dot org 2010-08-24 11:40 ------- For the auto-tuning, ideally the kernel would tell the thread when it lost CPU, I doubt there is any API for that currently. E.g. if a thread could register with kernel address where the kernel would store some value (e.g. zero) or do atomic increment or decrement upon taking away CPU from the thread. Then, at the start of the spinning libgomp could initialize that flag and check it from time to time (say every few hundred or thousand iterations) whether it has lost the CPU. In the lost CPU case it would continue just with a couple of spins and then go to sleep, and ensure the spincount will get dynamically adjusted next time or something similar.
Currently I'm afraid the only way to dynamically adjust is from time to time read/parse /proc/loadavg and if it went above number of available CPUs or something similar, start throttling down. -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |drepper at redhat dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43706