1 Introduction
Total Page:16
File Type:pdf, Size:1020Kb
Abstract In this pap er we present a concurrent execution semantics for Parallel Program Graphs PPGs a general parallel program representation that includes Program Dep endence Graphs PDGs and sequential programs We b elieve that this semantics is natural to the programmers way of thinking and that it also provides a suitable execution mo del for ecient implementation on real architectures To demonstrate the robustness of our semantics we prove a Reordering Theorem which states that a PPGs semantics do es not dep end on the order in which parallel no des are executed and an Equivalence Theorem which states that the semantics of a sequential program is identical to the semantics of its PDG Intro duction The Program Dependence Graph PDG is a p opular representation of control and data dep endences derived from a sequential program PDGs have b een shown to b e useful for solving a variety of problems including optimization vectorization co de generation for VLIW machines merging versions of programs and automatic detection and management of parallelism A PDG no de represents an arbitrary sequential computation eg a basic blo ck a statement or an op eration An edge in a PDG represents a control dependence or a data dependence PDGs reveal the inherent parallelism in a program written in a sequential programming language by removing articial sequencing constraints from the program text In this pap er we intro duce the Paral lel Program Graph PPG as a more general in termediate representation of parallel programs than PDGs PPGs contain mgoto edges that represent parallel ow of control and synchronization edges that imp ose ordering constraints on execution instances of PPG no des As they execute the PPG no des p erform read and write accesses to a shared memory If read and write accesses to the same lo cation are not prop erly guarded by mgoto edges or by synchronization edges then the PPGs execution may incur an access anomaly If a read access is p erformed in parallel with a write access that changes the lo cations value then the result of the read access is undened all memory accesses are assumed to b e nonatomic Similarly the result of two parallel write accesses with dierent values is also undened Note that nonatomicity implies that memory accesses cannot b e used for synchronization the mgoto edges and synchronization edges are the only mechanisms available in the PPG for co ordinating execution instances of PPG no des Given the widespread use of the PDG there is a strong motivation to understand its parallel execution semantics The semantics of PDGs has b een examined in past work by Selke and by Cartwright and Felleisen Both those approaches assumed a restricted programming language the language W and presented a valueoriented semantics for PDGs The valueoriented nature of the semantics makes it inconvenient to mo del store oriented op erations such as an up date of an array element or of a p ointerdereferenced lo cation Also the control structures in the language W are restricted to ifthenelse and whiledo the semantics did not cover programs with arbitrary control ow However PDGs can b e used to represent arbitrary unstructured control ow and arbitrary data read and write accesses as found in imp erative programming languages like Fortran C and Pascal This generality leads to many subtleties and p otential ambiguities in interpreting a PDGs parallel execution In this pap er we resolve these subtleties and ambiguities by dening a parallel imp erative semantics for PPGs and hence for PDGs in their full generality To demonstrate the robustness of our semantics we prove a Reordering Theorem which states that a PPGs semantics do es not dep end on the order in which parallel no des are executed and an Equivalence Theorem which states that the semantics of a sequential program is identical to the semantics of its PDG Our semantics accounts for the p ossibility of program exceptions like race conditions and deadlo ck and that the theorems also take these p ossibilities into account We b elieve that the semantics presented in this pap er is natural to the programmers way of thinking and lends itself to ecient concurrent execution mo dels for PPGs The semantics is dened with resp ect to a global scheduling system The scheduling system allows a programmer or a debugging system to follow the progress of a PPGs execution in a stepbystep manner if so desired Parallel no des may b e executed in any orderthe Reordering Theorem guarantees that all no de orderings yield the same semantics The global scheduling system is dened as a centralized scheduling algorithm so as to provide a simple and convenient mental abstraction for the programmer a distributed scheduler would probably b e the preferred way to actually implement such a scheduling system on a parallel architecture Our semantics is imperative the execution of a PPG no de is dened by read and write accesses into a shared global memory This is in contrast to the value oriented semantics prop osed for PDGs in where a PDG no de is viewed as a function that consumes input values from its input data dep endence edges and pro duces output values on its output data dep endence edges It is well known that a valueoriented mo del can b e inecient to implement in practice b ecause the extra copying overhead required for storeoriented op erations like the up date of an array element can b e prohibitive It is also awkward to force the programmer to think of storeoriented op erations in a value oriented way Our semantics for PPGs is strict the entire program execution is assumed to return error if any statement in the program returns This is in contrast to the nonstrict semantics prop osed for PDGs in similar to the nonstrict semantics of functional languages We b elieve that a strict semantics is more natural for PPGs b ecause the source programming languages typically used for PDGs eg Fortran Pascal C also have a strict semantics Further a strict semantics is more ecient to implement than a nonstrict semantics b ecause it do es not require supp ort for demanddriven evaluation In summary we b elieve that our parallel imp erative and strict semantics is more appropriate for PPGs and PDGs than other semantics that have b een prop osed b ecause it is a logical extension of the semantics of the PDGs source languages b ecause it is applicable to general PDGs as they are used in practice and b ecause it can b e implemented more eciently The rest of the pap er is organized as follows Section denes the PPG representation as well as the virtual paral lel architecture that serves as the target execution mo del for PPGs Section denes the global scheduling system for PPGs Section presents the concurrent execution semantics for PPGs and also proves the Reordering Theorem Section relates PDGs to PPGs and also proves the Equivalence Theorem Section discusses related work and Section contains the conclusions of this pap er and an outline of p ossible directions for future work Denition of the Parallel Program Graph PPG Denition A Paral lel Program Graph PPG G N E E star t consists of mg oto sy nc a set of no des N a set of mgoto multiple goto edges E a set of synchronization mg oto edges E and a designated start no de star t N sy nc We distinguish b etween a PPG no de and an execution instance of a PPG no de ie a dynamic instantiation of that no de Given an execution instance I of PPG no de a its a execution history H I is dened as the sequence of PPG no de and lab el values that a caused execution instance I to o ccur A PPGs execution b egins with a single execution a instance I of the start no de with H I an empty sequence star t star t An mgoto edge in E is a triple of the form a b L which denes a PPG edge from mg oto i no de a to no de b with branch lab el or branch condition L In general there may b e i multiple outgoing mgoto edges from no de a with branch lab el L fa b L a b Lg 1 k The semantics of mgoto edges is as follows Consider an execution instance I of no de a a that evaluates no de as branch lab el to b e L After completion execution instance I a creates a new execution instance I of each target no de b and then terminates itself b i i The execution history of I is simply H I H I a L where is the sequence b b a i i concatenation op erator A synchronization edge in E is a triple of the form a c f which denes a PPG sy nc edge from no de a to no de c with synchronization condition f f H H is a Bo olean 1 2 function on execution histories Given two execution instances I and I of no des a and c a c f H I H I returns true if and only if execution instance I must complete execution a c a b efore execution instance I can b e started Note that the synchronization condition c dep ends only on execution histories and not on any program data values 2 A PPG no de represents an arbitrary sequential computation The mgoto edges sp ecify how execution instances of PPG no des are created unravelled and the synchronization edges sp ecify how execution instances need to b e synchronized A formal denition of the execution semantics of mgoto edges and synchronization edges is presented later in Sections and The parallel computation mo del assumed in this pap er can b e viewed as a virtual paral lel architecture This abstract architecture consists of an unb ounded numb er of asynchronous virtual pro cessors that communicate through a shared global memory In our mo del all read and write accesses to the shared memory ie all interpro cessor communications