The sample tree barrier distributed with the RSIM code assumes a
power-of-2 number of processors, limiting the configurations for which
the parallel programs distributed can be run. This can be fixed with just
a few changes.
Problem Fix
Any use based on x->arr[other] in the function
TreeBarrier should first be conditioned on whether
or not other is within the array bounds. For example, the
line:
while (!x->arr[other].flag[which]) {;}
should be replaced with:
if (other < x->n)
while (!x->arr[other].flag[which]) {;}
and the line:
x->arr[other].flag[which]=0;
should be replaced with:
if (other < x->n)
x->arr[other].flag[which]=0;