RSIM Bug Report #20

Version of RSIM1.0
Bug number20
Bug class2
Date3/21/98
Reported byauthors
Affectstree barriers for non-power of 2 processor counts
Filesapps/utils/lib/sync/treebar.c

Problem Description

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;