Thread View: comp.lang.functional
3 messages
3 total messages
Started by J. Michael Ashley
Wed, 18 Jul 1990 21:56
re: Id array comprehensions revisited
Author: J. Michael Ashley
Date: Wed, 18 Jul 1990 21:56
Date: Wed, 18 Jul 1990 21:56
43 lines
2458 bytes
2458 bytes
Wolfgang writes: >>>Using the above rule you get finaly: >>> >>> DEF init1(A,f,i,n) == IF i>n THEN A >>> IF i<=n THEN init1(update(A,i,f(i)),i+1,n) FI >>>Regarding to concurrent initialization assume simplisticaly that init1 >>>is [[not strict]] lazy in its first argument. >If I get it right, this a specific problem of dataflow architectures. init1 >fires only, when *all* arguments are available, so the next recursion level >may only be reached when update(..) is available [...] >You might imagine the evaluation of init1 causes the creation of (n-i)+1 update >"processes". The result of update is not required to bound the recursion, >so init1 may terminate before any f(i) has been evaluated. The bottelneck >appears, if some f(i) is ready, and update requires the updated array of >the i+1 recursion level (this is a inherent problem (also in FORTRAN ...) >you can only solve with some complicated analysis >which ensures the commutativity of all performed updates). Put aside dataflow for a minute. Just assume we have a lazy language. Then the question now is not whether init1 is strict in its first argument, but whether or not update is strict in its first argument. I think it is, so this simple version of init1 is sequential. using dataflow, it is certainly sequential! it's an easy optimization to make init1 run O(log n) using a divide and conquer algorithm. this can be done since i-structures are being used to represent arrays. no analysis is necessary. >However, the (conceptual) fold step can be only applied >to cases which have an outermost list constructor (so if you construct >the index list with a concatenate of two sublists, it will fail for this >case). constructing the index list by concatenating sublists is usually what happens, so the analysis won't work. at any rate, even if it could theoretically work, i bet it would take forever to do the analysis on real codes. mike ashley jashley@lanl.gov
Re: Id array comprehensions revisited
Author: Joe Keane
Date: Thu, 19 Jul 1990 08:19
Date: Thu, 19 Jul 1990 08:19
22 lines
1683 bytes
1683 bytes
I don't think array initialization such as the one described is necessarily linear. If we think of an array as a monolithic object, then yes the updates must happen sequentially. However if the array is somehow divided into pieces, it is clear that we know which updates could affect a given piece, so the pieces can be constructed independently, although it takes time to put them together. There are simple algorithms to do insertion and deletion in arrays, but they become slow with large arrays. To avoid linear time in such operations you have to use more sophisticated data structures, using a divide-and-conquer approach. The array is hierarchically broken down into smaller pieces which are better handled with simple algorithms. This sort of indexing is done by B-trees, 2-3 trees, splay trees, etc. It is interesting that this same change also solves the parallelism problem. The initialization of the array will follow the structure of the data structure, because the different parts at each node in the hierarchy can be done independently. This does it in logarithmic time, which is the best we can do assuming that in a given amount of time a computation can only fork off a limited number of parallel sub-computations.
Re: Id array comprehensions revisited
Author: Wolfgang Grieskamp
Date: Sat, 21 Jul 1990 07:33
Date: Sat, 21 Jul 1990 07:33
54 lines
3290 bytes
3290 bytes
jashley@silver.ucs.indiana.edu (J. Michael Ashley) writes: >Put aside dataflow for a minute. Just assume we have a lazy language. Then >the question now is not whether init1 is strict in its first argument, but >whether or not update is strict in its first argument. I think it is, so >this simple version of init1 is sequential. Yes, thats right. init1 is strict in its first argument, if update is (seufz). But if we assume, that the first argument of init1 is evaluated lazy (what I wanted to say), then there IS no reason why init1 should block through the calculation of update or one of its Arguments. In general sub-calculations may be parallized over recursion levels, if the induction variable(s) do not depend on them. >using dataflow, it is certainly sequential! Maybe. You probably need a hybrid. The pure dataflow model ist just (nice) theory. >it's an easy optimization to make init1 run O(log n) using a divide and >conquer algorithm. this can be done since i-structures are being used to >represent arrays. no analysis is necessary. O(log n) isnt really good. Its mandatory to exploit (at least partial available) linear memory. The key of effience in imperative languages are arrays with access O(1) und update O(1), and effience (BTW, imperative languages too) makes the world go around. You can have O(1) access in functional languages, providing you have builtin or handcoded array structures, and O1(1) update in the lucky exclusive case, if you additionally have sharing analysis or reference counting (I heard, some people have observed the lucky case appears >60% with standard problems). The main problem is not wheter O(xyz) or inherent parallelism, but the underlying machine structure. Having ($$$) MIMDs with shared memory, then it would be a good idea to parallize the initialization maximal (unless you know, the initializer is trivial). Having loosely coupled MIMDs, you must carefully estimate the comm. effort against the initializer effort. I guess, on l.c. MIMDs parallel array initialization is an exotic case, and pipeling of streams is the case of interest. >constructing the index list by concatenating sublists is usually what happens, >so the analysis won't work. at any rate, even if it could theoretically work, >i bet it would take forever to do the analysis on real codes. Dont be so pesimistic, Michael! Its not the question of forever, but, say, 10 user minutes against 0.5 for a medium module. For example, full unification is much more expansive. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Wolfgang Grieskamp -fullOpt => *compiler* thinks: "lazy or not lazy, this is here the question!" wg@opal.cs.tu-berlin.de tub!tubopal!wg wg%opal@DB0TUI11.BITNET
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads