Parallel implementation of path expressions

Parallel implementation of path expressions

Volume 7, number 6 r I” I- .’ INFORMATIONPKcxESSmGLtiM~ , , ~_, .. ‘-\ *..->. _a “October 1978 - I I B I - I " 'I .‘. ;:, . I ’...

699KB Sizes 29 Downloads 101 Views

Volume 7, number 6

r

I”

I-

.’

INFORMATIONPKcxESSmGLtiM~

,

,

~_,

..

‘-\

*..->.

_a

“October 1978

-

I I

B I

-

I

" 'I .‘.

;:,

.

I



,.

PiRALLELIMPLEMENTATIONOFPAi&X.PRESS?ONS Ludwik CZAJA hastytut InformqykiUniwersytetu Warszawskiego,00-901 Warszawa,PKiN VlIIp. Poled Received 11 April 1978; revised version received 20 June 1978

Pamliei system, concurrency table, path expressions

1.

Introduction

Is*[l] a ‘%chematic”implementation of parallel cystirns F_ubeen described. Here, we use it assuming sy, = 2.7 where I is the total number of requests since the beginning of the parallel system’s run (3.Y admitted here as a measure of queueing of processors requesting for actions, is not essential as long as there is no priority among processors or actions; any relative measure would work. As it has been exemplified in [l] in case of priorities, it is technically convenient if the total measure of a current ‘Yurn of releacii$-’ of suspended processors, is of the form: priority measure + queueing measure, with “priority measure” being an integer and “queucing measure” - a fraction). Thus, we have the imp. :mentation: request (Pi, fz,): r = r + I; C[i, j] = 2~‘; trytomoveon terminate (pr, al) : stop(pi, aj); C[i, j] *=0; trytomoveon where: (a) P = (PI, ...#pn) mdA = {al, .. .. a,) m sets of processors and actions respectively. Processor pi ’ calls for executing action uj by request @I, ai) and signalsthe termination of this executing by terminate bit aj);

* (b) C is a concuwetgy ta%lZe (introduced in [ 11):

its rows correspond to pl, . . . . p,,, its columns to al, ...#o, and its current contents is: I

processorpi is not requesting for aj, 2-Q if pi & requesting for QIbut has C[i, j] = q ’ been suspended at the instant of time when r was equal to re (and not servicedup to current), 00 if pi is executing aj; 0

if

(c) trytomoveon is a piece of program which checks if, in the current state of the system, there exists a pair (Pb al) such that processor ok may start executiiig action al; if so, trytomoveon selects such a pair and performs start (pb ar) (which is the s&m& for p& to initiate Al)and C[k, rJ I=00and repeats these activities until there is no such a pair; (d) programs “request” and c‘terminate” are critical regions. Note, that if 2-’ exceeds the range of machine numbers, it may ‘bereset to initial value I II by setting r = 0 and multiplying the table C by a suitable constant. In this paper we assume “trytomoveon” to have a form: repeat I? forever (or a system of such repeat statements - in case of multiple path expressions) and thus, to be allocated a special, reserved, processor (or a number of them), called a control processor(s), working in parallel with executive processors - the ones that execute actions al, .... a,. R is the prefix form of a path expression R (see [2]), controlling allowable execution sequences of actions from A. To keep this paper in “letter’s size”, we leave some parsing-time “global? analysis of path expressions to a separate paper. Here, we assume as an outcome of this analysis: (i) all nondeterminisms removed, e.g. a; b + a; c transformed into a; (b + c) ; (ii) removed unnecessary path expressions (in the case of multiple path expressions), especiilllywhen they give rise to delayed decision (symbolized by “t”) as to which path is to be taken, e.g. the system of path expressions: patha +b;eend 291

INFORMATION PROCESSINGLETTERS

Volume7, number 6

path c; a end

is trmsfolmed into path b; c; a end;

(u) sbmation and deadlock situations detectable at parsing-time, are detected (see [2]).

2. Implementcationof single path expressions

The simplest path expression 12) is of the form path R end, where R is a regular expression over the alphabetA = {al, . ... a,,,) and “f’, “+” are interpreted as sequencing and exclusive selection operators. The star is defined as usually in terms of the former and path, end are interpreted as outermost star. A path expression specifies allowable execution sequences of actions from 14. All the actions occurring in a path expression are mutually exclusive in time and the scheduling discipline of suspended processors is FCFS. Thus, for any parallel problem describable by a single path expreaion: (a) concurrency table C contains at most one symbol 00 at a time; (b) the greatest entry in a column / of the table C corresponds to the processor waiting longest for executing aj. .Sypose that a path expression path R end is converaad (zt a parse-time) into the statement repeat 2 forever, where R is the prefix form of R, with the following correspondence of operator names: SUC in E corresponds to ; in R; SEL in R corresponds to + in R; STAR in R corresponds to * in R. Moreover, each action name aj occurring in R, in R occurs as ID(aj). Thus1 for instance path a; (b + c; d) end is converted into: repeat SUC(ID(4, SEL(ID(b), SUC(ID(c),ID@)))) forever. The interpretation of “*” has not been precisely specified in [2]. We admit the one consistent with the law: 00

I?erformaj repeatedly as long as a processor pI =quested for aj befire any of remaining processors Pl P **9 Pf-1, Pr+t, ‘*a, Pn requested for f&; then perfDrm ak. l

292

October 1978,

To implement this, the notion of dynamic successor is needed: Let X; Y be a sub-exipression of a-regular expression 2. We say that Y is a dynamic sidccessor of X (in 2). Also, Y is a dynamic successor of any X’s sub-expression W if W satisfies: there is no other X’s sub-expression of the form VI; IQ such that W is a sub-expression of VI. For instance, in the regular expression (a + @; c + e) ; (f + g)); d, d is the dynamic successor of (a + @;c +e); @+g)), a, (f+g),fandg. The dy namic successor of b is c. The dynamic successor of c, ‘b;c, e and (b;c + e) is q+g). Now, we assume that X’ is converted into STAR(X, I’), where Y is the dynamic successor of X, determined at a parse-time. For instance, a*; b is converted into SUC(STAR(ID(a), ID(b)), ID(b)). Of course, the second parameter of STAR is ultimately implemented as a reference to the dynamic successor of the first parameter. Considering SUC, SEL, STAR, ID as names of suitable procedures, we assume the statement repeat E forever to be perftirmed by a special, reserved processor. Thus, we come to the following arrangement of the system: (i) Processors pl, .,., pn, the executive ones, perform actions al, ... . a,. Processor pi requests for aj and signals termination of ai by the statements: request (pi, a/) : (r := r t 1; C[i, j] := 2~‘)’ terminate (pi, llj): Stop (pi, aj); {C[i, i] := 0) where brackets { , ) embed critical regions. (ii) A special processor, the control one, performs the statement: repeat E forever which is regarded to be a “trytomoveon” statement. The control processor however, performs in paraZZe1 with executive processors. ‘This implies that any access to concurrency table C and variable r (but not the whole repeat statement) must be critical regions. Now, we define procedures SUC, SEL, STAR, ID. The parameters are called by name, but - to simplify notation - we deviate slightly from Algol60, permitting procedure statement to be the actual parameter. The “case”, “while” and “repeat” statements are also used and, for clarity, we use in programs some commonly understood notation, e.g. quantifiers. We need some auxiliary notions: (a) If X is a regular expression in the prefix form, then op(X) denotes the outermost operation in X, e.g. op(SEL(ID(& ID(b))) is SEL,

volume7, number 6

INF:ORMAiTION.qRO~~SSING LETTERS

(b) If X Is ID@), then q(X) is a Since alctionsare numbered, bh-a&D(+)) we sorrretimeswill mean j. ($3 If X is SW(X,, X2) or,SEL(Xi;‘Xz),then left(X) is Xr and right(X) is Xs. (d) max&[k, j] is the maximal entry in the column j of matrix C.

-October 1978

(e) { , ) embed critical regions. ff) An rizstanta~wuso~d&@gb~ye+ yqglgr expressions X and Y is defined by the folI5win~::’ recursive procedure: ‘* : ,’

._ BooleanprooedureLESS(X Y-J; LESS := if op(X) = ID A op(Y) = ID then {nrax&[k, a@‘)] < mX&[k, arg(Y)]) else LBSS(caaeop(X) of ID, STAR:X; WC: left(X); S’EL:if LESS(left(X),right(X)) then right(X) else left(X) end, caseop(Y) of ID, STAR: Y, SUC : lefu(Y); SEL: if LESS(left(Y), right(Y)) then right(Y) else left(Y) end) (g) An instutaneousequalitybetween regular expressions X and Y is defmed by the following recursiveprocedure:

Boolean procedure EQ(X, Y); EQ := if op(X) = ID A op(Y) = ID then ~max&& argOI = maJ&C[k, arg(y)]) eh? EQ(case op(X) of ID, STAR: X, SUC: left(X); SEL: if LESS(left(X), right(X)) then right(X) else left(X) end, case op(Y) of ID, STAR: Y, SUC: left(Y); SE1 : if LESS(left(Y), right(Y)) then right(Y) else left(U) end) Note, that since all nondeterminisms are removed, maxaC[#, arg(X)] = maxkC[k, arg(Y)J iff columns arg(X) and arg(Y) of matrix C contain solely zeroes (this holds by virtue of (dr) = 2-‘). Definitionsof procedures SUC, SEL, STAR, ID. procedureSUC(X, Y); begin X, Y end procedureSEL(X, Y); hegln while EQ(X, Y) do; commentdummy statement is looped until X differs “instantaneously” from Y; if LESS(X, Y) then Y else X end procedureSTAR(X, Y); commentY is the dynamic successor of X; while LESS(y, x) do X procedureID(X); begin repeatu&U &j$J[il j] < - h 3 fl[it x] > 0; take k (15: k Q n) such that &&&[i, a < C[k, a ; stati&, if); commenthere, the control processor initiates execution of X by pk which is the IOn$eSt 293

waiting for X executive processor;

(3.1). This assumption may be thought of as a conceptual-ones:alI of the control processors may be simulated using e.g. SIMULA’scoroutiries. Consider . the following

C[& fl = 00 end Remadcs.(a) Any row of t’.s table C contains at most one non-zero entry, at a timti (ref. [ 11, corollary 3.2). Thus, C may alwaysbe implemented as a two-column table C’:

C’[‘, 2 ] =i, if there is such i that Crf i] > 0; otherwise C’[&21 = 0. The primary motivation of introducing concurrency table C instead of traditional queue is to grasp the notion of scheduling discipline in more abstract way, SCthat it need not be FCFS or priority FCFS. Generally, a scheduling discipline is specified by the function cpand a rule 3/ of selecting one entry from C (see [ 11). Another motivation is developing a representation of parallel systems in the form of graphs with concurrency matrices as their nodes. This is the subject of a separate paper. (b) Some testings of the table C, e.g. max&[irr,I] < max&[k, fl, may be implemented without the table look-lip, if some registersare introduced. (c) A conditional element in path expressions is of the form: [cl:el, c2:e2 , .. .. cn:en, en + l] (see [2]) and may be implemented like this: convert this element into: COND(c1,e 1, COND(c2,e2, .... COND(cn, en, en+l) .. and define the procedure COND: procedure COND(B, X, Y); if B then X else Y. Also, priorities to some actions, expressed in [2] by replacement of “+” with “‘C’ may be easily imple-

mented introducing a suitable procedure “PRIOR” instead of “SEL”.

Given a svs+emof path expressions: Ik= 1, 2, .... N

convert it into the system of statements: repeat & foxevei

k = 1, 2, .... N

(3.1)

where & is the prefix form of regular expression Rk. Suppose, we have N control processors, the kth one working on the kth repeat statezzent of the system 294

Le"Uj occur in Rk. We say that the kth control processor is r&z& to initiateexech2g b!j if it entered the procedure statement ID@) (occurring in the kth repeat statement (3.1)). It may be reasoned that (in order to conform to the meaning of multiple path expressions [2)) for an executive processor to be allowed to execute action aj, the following must hold: For all k = 1 *** N, if aj occurs in Rk, then: (a) no action occurring in & may be executed, and (b) the kth control processor is ready to initiate executing ~1. To implement this, introduce a table S: its rows correspond to path eXpreSSiOnS Rk or repeat statements (3.1), its columns - to actions al, ... . a,,, and its entries are (for k = 1 **N, j = 1 **m): 8 #, if 4j does not occur in Rk, 0, if Qjoccurs in Rk and the kth control processor is not ready to initiate executing 4, SCkJ] = ( 1, if aj occurs in Rk and the kth control processor is ready to initiate exc~.&i.ng

Defmition.

l

l

Qj,

if aj occurs in & and aj is currently being executed. For instance, the following collocation of “W’ in he table S is for the system: 00,

a

15 c

patha + b;c end path d; b end

3. Implementatbn~of multiple path expressions

path Rk end

October 1978

INFORMATION PROCESSING LETTERS

V&une 7, number 6

d #

#

.

#

The implementation of multiple path expressions is like that of single ones, but: (a) each of control processors has its private collection of SUC, SEL, STAR, ID procedures sharing two - common to all control processors - btablesC and S, (b) procedures SUC, SEL, STAR owned by all the control processors are identical with those defined in Section 2, whereas ID owned by the /cth control pro-

Volume 7, number 6 cessor

is redefined:

INFORMATIONPROCESSINGLETTEERS ’

last onetg en”er thelif-statement).will iniljdtc~~exe.c~ting~~cti~~ X-by pruces-

i

ID(X); be@nS[k, Xj = 1;

prooedure .

,SQt:p;;

*

*peat until vKreJv~[~, XJ # 0 A 3pgte&i,

f&pt

X] > 0;

comment the above condition means: all the

control processors whose repeat statements (3.1) comprise action X, are ready to initiate executing X and an executive processor has requested for execution of X; S[k, X’J :=00; take t (1 < t f n) such that V&&i, x] < C[t, Xl ; ifV’
start (p, X); comment here, the kth control processor initiates executing action X by executive processor pt which waited for it longest; C[t, X-J := OQ end; comment the condition in the if-statement ensures

that only one of control processors (the

’ {October1978

-,-

~ *,

until C# XJ # OQ ; comment dummy state-

* m&t is loc,p~d:‘~n~!‘~x~cut~ng act-ionX by processor pt is over; ’ S[k,xJ

:=o

end

.

Acknowledgment

Mr. A. Kleinberg preparing his MSc.Thesis on path expressions contributed to improvement OFthis paper. He also simulated (using SIMULA-CDC/ . CYBER) a multiprocessor system in order to run the implementation r f path expmssions presented here. I am very r:&efdl to him

References 1: ] L. Czaja, Implementation approach to parallel systems, Information Processing Lett. 7 (5) (1978) 244-249. [ 2 ] A.N. Habermann,Path expressions, Carkgie-Mellon Univ., Pittsburgh, PA 15213 (1975).