begin quoting Bob La Quey as of Tue, Apr 03, 2007 at 11:48:27PM -0700:
[snip]
> Simple example. Say I have loop that runs for M times. Say I have N
> cores. Why not have the complier generate the code (including managing
> memory) to run N loop instances and thus run in approoximately 1/N the
> time? So time to run goes from M to M/N mas o menos.
Building a linked list in a loop this way would require more effort
than less...
> Loops are pretty common so this naive idea could go a long way ...
Check out SR and languages derived from this. They do stuff like this.
If threads in TCL are cheap, this would be a simple thing to add and
try out (if it's not already there).
Say, "ploop" for "parallel loop"...
ploop variablename lowerbound upperbound stepsize body
Let it spawn off M threads with different values of "variablename"
in the lowerbound to upperbound range, inclusive, by stepsize (or
should that be an increment clause?).
SR also had (IIRC) a parallel if -- instead of a short-circuiting or,
it would do a parallel or, and the first one to return true would
abort the rest.
So...
ifany clause1 clause2 clause3 ... body
Doing the same sort of thing for "and", but aborting if any are false:
ifall clause1 clause2 clause3 ... body
etc. etc.
(or maybe "ifany {clause-list} body" and "ifall {clause-list} body" ?)
ploop i lb ub 1 {
ifany task1( i ) task2( i ) task3( i ) task4( i ) do_any_task( i )
ifall check1( i ) check2( i ) check3( i ) print_results( i )
}
--
It's thinking of ways to parallelize code that's going to be hard to teach.
Stewart Stremler
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg