home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / parallel / 1905 < prev    next >
Encoding:
Text File  |  1992-08-12  |  14.3 KB  |  389 lines

  1. Newsgroups: comp.parallel
  2. Path: sparky!uunet!gumby!destroyer!gatech!hubcap!fpst
  3. From: Jeffrey B. Graham <strand@CERF.NET>
  4. Subject: Latest Strand88 Newsletter
  5. Message-ID: <1992Aug13.201806.26005@hubcap.clemson.edu>
  6. Sender: fpst@hubcap.clemson.edu (Steve Stevenson)
  7. Organization: Clemson University
  8. Date: Wed, 12 Aug 92 10:43:49 PDT
  9. Approved: parallel@hubcap.clemson.edu
  10. Lines: 377
  11.  
  12.                   STRAND88 NEWSLETTER VOLUME 1, ISSUE 4
  13.  
  14.                                July, 1992
  15.  
  16.  
  17.      THIS ISSUE'S TOPIC - MULTIPLE LANGUAGE PROGRAMMING WITH STRAND88  
  18.  
  19.         by Professor J. John Florentin of Birkbeck College, London
  20.  
  21.  
  22.                             INTRODUCTION
  23.  
  24. The techniques of parallel programming are evolving slowly.
  25. Initially parallel programs were a collection of sequential
  26. programs written in traditional sequential languages. These
  27. languages were extended with communication instructions to effect
  28. inter-process communication. In this approach programmers have to
  29. ensure that data is exchanged between processes only at logically
  30. appropriate times. Such synchronizing communication is feasible in
  31. problems with completely regular patterns of execution, but it is
  32. difficult to control in problem-solving computations where the
  33. execution pattern is strongly data-dependent and irregular.
  34.  
  35. Logical control of synchronization was then added using features
  36. such as the rendezvous [1]. A further development was to devise new
  37. programming languages in which control of synchronization was a key
  38. element of the programming model. Typical of these are dataflow and
  39. functional languages, [2] and [3].
  40.  
  41. More recently, concurrent logic languages using the stream, or
  42. pipelining, abstraction have been developed as a progression from
  43. sequential logic languages [4]. An important feature of these
  44. languages is that one form of the data decomposition which is
  45. essential to useful parallel execution is abstracted and
  46. represented in the language itself. Abstracting and representing
  47. data decomposition allows the programmer to comprehend the parallel
  48. execution and to exercise some control over it. This programmer
  49. control can overcome some of the performance limitations found when
  50. running programs written in existing dataflow languages.
  51.  
  52. The Strand concurrent programming language, [5], is a further
  53. development of this trend. Strand concentrates on representing data
  54. decomposition and links it directly to process synchronization.
  55. Strand takes a minimalist approach and it drops most of the
  56. characteristic features of logic languages, including parameter
  57. passing by unification and backtracking.
  58.  
  59. Originally the foreign language interface was provided to cater to  
  60. users with existing code which they did not want to re-write. After
  61. some experience this multiple language approach has come to be
  62. adopted for new programs.
  63.  
  64. THE STRAND CONCURRENT PROGRAMMING LANGUAGE
  65.  
  66. Strand has a syntax based on logic languages like Prolog. Its
  67. semantics are, however, quite different. A Strand program consists
  68. of a collection of process definitions together with a call to
  69. these processes. A simple illustration defining a process 'twice'
  70. is:
  71.  
  72.      twice(X,Y) :-
  73.           x > 0 |
  74.                Y is 2*X.
  75.  
  76.      twice(X,Y) :-
  77.           x <= 0 |
  78.                Y := 0.
  79.  
  80.  
  81. Here, X is an input parameter and Y is an output parameter. The
  82. definition has separate cases. These cases are tested when a call
  83. is made. A call to 'twice' might be 'twice (2,Z)', when Z would
  84. receive the value 4.
  85.  
  86. A call 'twice(2,W), twice (W,Y)' sets up a network of two
  87. concurrent 'twice' processes which communicate through the shared
  88. variable W, see fig 1. Strand automatically manages the data
  89. transfer and also invokes the second 'twice' only at the
  90. appropriate time.
  91.  
  92.  
  93.   X      +---------+         W         +---------+     Y
  94. -------> |  twice  |  ---------------> |  twice  | -------->
  95.          +---------+                   +---------+
  96.  
  97.          Figure 1 : PROCESS INVOCATION IN STRAND
  98.  
  99.       
  100. A call is effected in stages whose simplest form is:
  101.  
  102.       (i) the parameter list of the call is pattern-matched against
  103.           the definition head parameters using simple rules which
  104.           will not be detailed here;
  105.  
  106.      (ii) when a parameter list match is successful, the
  107.           corresponding guard conditions are tested;
  108.  
  109.     (iii) if at least one guard test succeeds, one corresponding
  110.           case body is chosen and executed; if no guard succeeds a
  111.           program fault occurs.
  112.  
  113. A more interesting behavior for process invocation occurs when one
  114. of the above stages is held in suspension. For example, a call of
  115. 'twice(X,W)' can occur because parallel computing is always in
  116. real-time mode and the value of X may not be known when the call is
  117. made. In this situation the call proceeds until the value of X is
  118. needed in the guard test or in the execution of the body. At the
  119. point where the value of X is needed there is an orderly suspension.
  120.  
  121. Other matching rules induce suspension before the guard test
  122. commences. An example would occur if there were a special case of
  123. twice for X=3:
  124.  
  125.      twice(3,Y) :-
  126.           Y := 0.
  127.  
  128. A call of 'twice(X,Y)' would suspend, waiting to see whether X
  129. became instantiated to 3.
  130.  
  131. STRAND PROCESSES
  132.  
  133. Strand processes are created dynamically and are short-lived. In
  134. the usual patterns of Strand programming, new processes are created
  135. continually. The efficiency of this approach can be kept up because
  136. of the simplicity of most processes resulting in a "lightweight
  137. process" implementation.
  138.  
  139.  
  140. DATA SHARING PARALLELISM IN STRAND
  141.  
  142. A process allowing parallel processing is -
  143.  
  144.      quad(X,Y) :-
  145.           twice(X,V1),
  146.           twice(X,V2),
  147.           sum(V1,V2,Y).
  148.  
  149. Both instances of the 'twice' process can compute in parallel (see
  150. Figure 2).
  151.  
  152.  
  153.                    +---------+  
  154.                /-->|  twice  |->\
  155.               /    +---------+   \ V1
  156.              /                    \      +-------+   Y
  157.      X ---->                        ---> |  sum  |------->
  158.              \                    /      +-------+
  159.               \    +---------+   / V2
  160.                \-->|  twice  |->/
  161.                    +---------+
  162.  
  163.                         Figure 2
  164.  
  165.  
  166. STREAM PROCESSING IN STRAND
  167.  
  168. Stream processing is the basis for pipeline parallelism where the
  169. data is "salami sliced" into a list of items which is processed by
  170. several operations. A process 'stwice' which operates on a list of
  171. numbers and produces a list of numbers is as follows:
  172.  
  173.      stwice([Hx|Tx],Ly) :-
  174.           W is 2*Hx,
  175.           Ly := [W|Ly1],
  176.           stwice(Tx,Ly1).
  177.  
  178.      stwice([],Ly) :-
  179.           Ly := [].
  180.  
  181. Here, Hx is the first data item on the input list and Tx is the
  182. tail. All three calls on the right hand side potentially execute in
  183. parallel. On a call: 'stwice([1,2,3],Ly)', each data item is
  184. processed by recursive looping.
  185.  
  186. On a call: 'stwice([1|Tx],Ly)', the first item, 1, is processed and
  187. then a call 'stwice(Tx,Ly1)' is left in suspension. It can be
  188. brought out of suspension by instantiating 'Tx : = [2|Tx1]'. This
  189. instantiation can occur some considerable time after the first
  190. version of stwice is left in suspension. In this situation stwice
  191. appears to be a persistent object.
  192.  
  193.  
  194. STREAM PARALLELISM
  195.  
  196. A call of 'stwice(Lx,V), stwice(V,Ly)' appears to be a network of
  197. two processes inter-connected by the shared variable V, as shown in
  198. Figure 3. Both processes are initially in suspension. An instantiation
  199. 'Lx : = [1|Tx]' brings the first stwice out of suspension. As the
  200. first stwice computes the first item in the list V, the number 2
  201. becomes available to fill this slot. This availability causes the
  202. second stwice to come out of suspension and execute one iteration to
  203. produce the first item, 4, of the output list Ly.
  204.  
  205.  
  206.  [1,2,3,..]   +---------+      V       +---------+   [4,8,12,..] 
  207.    ---------> | stwice  |  ----------> | stwice  | ------------->
  208.               +---------+              +---------+
  209.  
  210.                            Figure 3
  211.  
  212.  
  213. The result of entering the first item of Lx is that both processes
  214. execute one iteration in sequence and then leave two suspended
  215. descendant processes.
  216.  
  217. Alternatively, if Lx had been instantiated to 'Lx := [1,2,3|Tx]',
  218. then the first stwice would be processing the input, 2, while the
  219. second stwice was simultaneously processing the first intermediate
  220. result, 2. Parallel execution would need separate physical
  221. processors. This is the basis of stream parallelism, which is
  222. exploited practically in more complex ways in Strand programming.
  223.  
  224. COMMENTS ON STREAM PARALLELISM
  225.  
  226. 1.   Streams are not confined to linear lists. The stream construct
  227.      works whenever a recursive function and a recursive data
  228.      structure are dovetailed precisely. For example, it is
  229.      possible to fan out parallel processing across a tree in this
  230.      way.
  231.  
  232. 2.   The name of the tail of a stream, like T in [H|T], can be
  233.      regarded as the name of the channel to the process suspended
  234.      on T. Process definitions are often arranged so that channels
  235.      can be closed down by instantiating 'T : = [ ]'. Thus channels
  236.      are abstract and can be created and destroyed dynamically.
  237.  
  238.  
  239. STREAMS AND SYNCHRONIZATION
  240.  
  241. 1.   Processes can be suspended awaiting simple data items as in
  242.      the definition of 'twice(3,Y)' above. They can also wait on the
  243.      continuation of a stream as in the stwice example above.
  244.      Processes can also await input events at several parameter
  245.      positions, some of which might be simple items and some of
  246.      which might be streams.
  247.  
  248. 2.   Different cases of a process definition may be set so that it
  249.      is not necessary that input arrives at all parameter positions
  250.      to bring a process out of suspension, and start execution.
  251.      This allows a programming style with a varying response to
  252.      different event combination patterns.
  253.  
  254.  
  255. To illustrate this, consider the skeleton definition sketched in
  256. Figure 4: 
  257.  
  258.      complex(go,[H1|T1],In2,Out) :-
  259.           do(H1,Flag),
  260.           complex(Flag,In1,In2,Out),
  261.           etc...
  262.  
  263.      complex(go,In1,[H2|T2],Out) :-
  264.           do(H2,Flag),
  265.           complex(Flag,In1,In2,Out),
  266.           etc...
  267.  
  268.  
  269.           In1   _____
  270.           [...]      \
  271.                       \     +----------+   Out
  272.           In2-------------> |  complex |----------->
  273.           [...]       /     +----------+
  274.           go ________/
  275.  
  276.                             Figure 4
  277.  
  278.  
  279. A suspended process 'complex(Flag,In1,In2,Out)' awaits the arrival
  280. of the constant 'go' in parameter position 1 plus either a message
  281. in position 2 or a message in position 3.
  282.  
  283. THE ALLOCATION OF PROCESSES TO PROCESSORS IN STRAND88
  284.  
  285. Present implementations of STRAND88 do not allocate newly created
  286. processes to physical processors automatically under the control of
  287. an internal scheduler. Process calls have to be annotated to guide
  288. the run-time system. This annotation will not affect the
  289. non-deterministic meaning of the program; as an illustration, the
  290. previous definition of stwice may be annotated to:
  291.  
  292.      stwice([Hx|Tx],Ly) :-
  293.           W is 2*Hx,
  294.           Ly1 := [W|Ly],
  295.           stwice(Tx,Ly1)@N.
  296.  
  297. The annotation '@N' means that the regenerated process should be
  298. run at processor node N. The value of N may be computed at run
  299. time. The processes 'W is 2*Hx' and 'Ly1 := [W|Ly]' run on the same
  300. node as the original call. Thus the grain size is determined by
  301. bunching small processes onto a physical node.
  302.  
  303. A further alternative is:
  304.  
  305.      stwice([Hx|Tx],Ly) :-
  306.           W is 2*Hx,
  307.           Ly1 := [W|Ly],
  308.           stwice(Tx,Ly1)@next.
  309.  
  310.  
  311. The annotation '@next' means that the programmer is assuming a
  312. virtual, or logical, machine with ring-connected processor nodes.
  313. The regenerated process will be passed around the ring. The
  314. run-time system has a machine-dependent routine which is able to
  315. map the programmer's logical ring onto the available physical
  316. processors. Similarly, the programmer may assume a logical infinite
  317. mesh-connected machine.
  318.  
  319.  
  320. FOREIGN CODE IN STRAND88
  321.  
  322. STRAND88 incorporates foreign code by replacing a call to a
  323. STRAND88 process by a call to a routine written in the foreign
  324. language. STRAND88 continues to manage the data transfer and the
  325. process invocation, so the foreign language routines run
  326. concurrently in a correct manner.
  327.  
  328. STRAND88 and the foreign code have to be coupled so that their
  329. features cooperate properly. For example, STRAND88 has lists as
  330. data structures while Fortran has arrays. Interface routines are
  331. needed to translate between the data structures which might have to
  332. incorporate data buffers. Interface routines are supplied in
  333. library form.
  334.  
  335. MULTIPLE LANGUAGE PROGRAMMING
  336.  
  337. The design of the STRAND88 harness can incorporate all of the
  338. synchronizing and data decomposition constructs described in the
  339. sections on stream and data sharing parallelism above. These
  340. constructs do not have to be considered when writing C or Fortran
  341. code.
  342.  
  343. BIBLIOGRAPHY
  344.  
  345. [1]  Reference Manual for the Ada Programming Languages, US Dept of
  346.      Defense, US Govt Printing Office, ANSI/MIL-STD-1815A edition,
  347.      Jan 1983
  348.  
  349. [2]  'Data Flow Languages', William B. Ackerman, Computer Vol 15,
  350.      No 2 pp 15-25, February 1982
  351.  
  352. [3]  Introduction to Functional Programming, Richard Bird and
  353.      Philip Wadler, Prentice Hall, London 1988
  354.  
  355. [4]  'The Family of Concurrent Logic Programming Languages', E.
  356.      Shapiro, ACM Computing Surveys, Vol 2 1, No 3 September 1989,
  357.      pp 412-5100
  358.  
  359. [5]  Strand: New Concepts in Parallel Programming, Ian Foster and
  360.      Stephen Taylor, Prentice Hall, New Jersey 1990
  361.  
  362. [6]  'Converting sequential applications software for parallel
  363.      execution with STRAND88 harnesses', A. Dinn and G. Phillis,
  364.      Report, Strand Software Technologies, Greycaine Road, Watford,
  365.      Herts WD2 4JP, England, January 12, 1990.
  366.  
  367.  
  368. Strand88 is a highly portable and scalable parallel programming language
  369. designed for efficient execution on many hardware platforms: shared-memory
  370. multiprocessors, distributed-memory multiprocessors, and networks of
  371. workstations.
  372.  
  373. Strand88 is currently ported to the following platforms:
  374.  
  375.      iPSC/860, iPSC2/386, Sequent Balance/Symmetry, Sun SparcStation, 
  376.      Sun 600MP Multiprocessing Workstation, Transputer/Helios,
  377.      Alliant FX/2800, Meiko Computing Surface, MIPS RISCstation, nCube 2,
  378.  
  379.  
  380.  
  381.      Encore Multimax and System 9x, Cogent XTM Workstation, MacII,
  382.      IBM PS/2, NeXT, Pyramid, and TI TMS320C40 Digital Signal Processor.
  383.  
  384. Dr. Stuart Bar-On & Jeff Graham, of Parallel Performance Group, Inc., at
  385. (619) 634-0882, or (619) 483-4325, E-Mail: 4956839@mcimail.com, will send
  386. information and answer any questions you may have about Strand88.
  387.  
  388.  
  389.