I think what you're asking is "how can I minimize the number of
barrier synchronizations inserted by an autoparallelizing compiler
into my code to preserve correctness".
Or you could be asking about minimizing context switches, but
the answer to that would be O/S-specific.
I've not done this sort of compiler work, but at first glance it seems
like a straightforward product of dependence analysis. When no
data (or control) dependence exists between consecutive lines of
code, no barrier is necessary. When one does exist, a sync must
That said, it seems like the real work would be in resequencing
the code (at IR level) so that the dependencies could be moved
as far apart as possible (or more precisely, the number of dependency
transitions in the code would be minimized over a given sequence of
BTW, this question might be better answered in comp.compilers.
Henning Fernau wrote:
> When designing a compiler automatically parallelizing
> programs after data-flow analysis, it would be desirable
> if the number of communications (or thread switches when
> run on fewer processors than threads) between threads would
> be minimized.
> How is this problem solved in praxis (if at all)?
Randy Crawford http://cac.engin.umich.edu