/* fastprefix.c by C.W.Kessler 01/95 * general integer multiprefix-ADD implementation in Fork95 * * straightforward nonrecursive algorithm * takes O(n/p) time on p-processor SB-PRAM * with built-in MPADD-operator running in O(1). * Only one additional shared memory cell required (proposed by J. Roehrig). * This is optimal. * * n must no longer be a power of the number of processors p * * Condition: group-relative Processor ID's '$' must be consecutively * numbered from 0 to groupsize - 1. */ #include #include #include extern sync void output_array( sh int*, sh int ); extern sync void parallel_prefix_add( sh int*, sh int, sh int *, sh int ); sh int *a, *b; sh int n = 100; void main( void ) { pr int i; start { a = (int *) shalloc(n); b = (int *) shalloc(n); /* preset the input array: */ seq prS("\nSource Array:\n"); farm for (i=$; i