Parallel Stack Frames
COTTRELL, JAMES
cottrell at NBS-VMS.ARPA
Sat Mar 1 07:37:46 AEST 1986
/* Eugene Brooks writes:
> The idea of creating a new context with each entry to a {} block,
> or at least for some very special ones, has some merit worth
> thinking about. Suppose you have extended C for parallel programming.
Is this what your `vectorizing C compiler' does :-) Isn't this
announcement a little over a month early :-) :-)
> main()
> {
> int i;
> int shared;
>
> forall(i from 0 to 9) {
> int private;
> /* lines of code */
> }
> }
>
> if the forall loop is looked at as a fork of 10 lines of control
> which join up at the closing brace then the opening brace must do
> something special to the stack frame so that 10 seperate copies of
> 'private' are generated. The int 'shared' is on the stack of the parent
> and can be read or written by all of the lines of control but the
> stack splits into 10 segments at the opening brace of the forall loop.
This is one school of thought on P.P., small grain. I myself prefer
explicit declaration of parallelism, i.e. a larger grain. Thus I would
write something like:
int shared[10];
int *private = &shared[0];
main()
{ int n = 0;
somehow_declare_shared(shared,sizeof(shared));
while (n++ < 10)
if (fork()) ++private;
else child();
while (n--) wait();
}
child()
{ child plays with *private;
}
As you know, the usefulness of your construct depends on the size of
what's inside the loop compared to what's outside it. That is, how
much of your code can be parallelized vs how much is sequential.
jim cottrell at nbs
*/
------
More information about the Comp.lang.c
mailing list