DOC PREVIEW
UT CS 395T - Parallel Data Structures

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Parallel Data StructuresStory so far• Wirth’s motto– Algorithm + Data structure = Program• So far, we have studied – parallelism in regular and irregular algorithms– scheduling techniques for exploiting parallelism on multicores• Now let us study parallel data structuresAlgorithm(Galois program written by Joe)Data structure(library written by Stephanie)Galois library APIGalois programming modelParallel data structure• Class for implementing abstract data type (ADT) used in Joe programs– (eg) Graph, map, collection, accumulator• Need to support concurrent API calls from Joe program– (eg) several concurrently executing iterations of Galois iterator may make calls to methods of ADT• Three concerns– must work smoothly with semantics of Galois iterators– overhead for supporting desired level of concurrency should be small– code should be easy to write and maintainWorking smoothly with Galois iterators• Consider two concurrent iterations of an unordered Galois iterators– orange iteration– green iteration• Iterations may make overlapping invocations to methods of an object• Semantics of Galois iterators: output of program must be same as if the iterations were performed in some sequential order (serializability)–first orange, then green– or vice versaPictoriallyenq(x)deq()/?enq(y)deq()/?enq(z)timeIteration1Iteration2Object: queueMethods: enq(x),deq()/y,Thread1 startsexecuting Stephanie code for m1Thread1 completesStephanie code andresumes Joe codeenq(x) deq()/xenq(y)deq()/y enq(z)Iteration2Must be equivalent to Iteration1enq(x) deq()/zenq(y)deq()/yenq(z)Iteration2Iteration1ORTwo concerns• [Consistency] Method invocations that overlap in time must not interfere with each other– (eg) o.m1() and o.m2()• [Commutativity] Commutativity of method invocations– (eg) o.m3() must commute •either with o.m4() (to obtain green before orange order)•or with o.2() and o.m5() (to obtain orange before green order)• Compare with strict serializability in databases– (Where transactions should appear to execute sequentially)o.m1()o.m3()o.m2()o.m5()o.m4()timeIteration1Iteration2Object: oMethods: m1,m2,m3,m4,m5Some simple mechanisms• Conservative locking• deadlock-free• hard to know what to lock upfront: (eg) DMR• How does this address serializability?lock(o1, o2, …)o1.m()o2.m()…unlock(o1, o2, …)lock(o1, o2, …)o2.m()o1.m()…unlock(o1, o2, …)Iteration1 Iteration2• Two-phase locking• incremental• requires rollback– old idea: Eswaran and Gray (1976)– we will call it catch-and-keeplock(o1)o1.m()lock(o2)o2.m()…unlock(o1, o2, …)lock(o2)o2.m()lock(o1)o1.m()…unlock(o1, o2, …)Iteration1 Iteration2Problem: potential for deadlock• Problem: what if thread t1 needs to acquire a lock on an object o, but that lock is already held by another thread t2?– if t1 just waits for t2 to release the lock, we may get deadlock• Solution: – If a thread tries to acquire a lock that is held by another thread, it reports the problem to the runtime system.– Runtime system will rollback one of the threads, permitting the other to continue.– To permit rollback, runtime system must keep a log of all modifications to objects made by a thread, so that the thread can be rolled back if necessary• log is a list of <object-name, field, old value> tuplesDiscussion• Stephanie’s job– write sequential data structure class– add a lock to each class– instrument methods to log values before overwriting– instrument methods to proceed only after relevant lock is acquired– object-based approach• Holding locks until the end of the iteration prevents cascading roll-backs– compare with TimewarpimplementationPerformance problem• Iterations can execute in parallel only if they access disjoint sets of objects– locking policy is catch-and-keep• In our applications, some objects are accessed by all iterations– (eg) workset, graph• With this implementation, – lock on workset will be held by some iteration for entire execution of iteration• other threads will not be able to get work– lock on graph object will be held by some iteration• even if other threads got work, they cannot access graphCatch-and-release objects1. Use lock to ensure consistency but release lock on object after method invocation is complete2. Check commutativity explicitly in gate-keeper object– Maintains serializability3. Need inverse method to undo the effect of method invocation in case of rollbackGatekeepingLogLogT1T2m1m2m3Base Objectm2m3Abort!Gatekeeping• Gatekeeper ensures that outstanding operations commute with each other– Operation (transaction) = sequence of method invocations by single thread• Catch-and-keep is a simple gatekeeper– And so is transactional memory, also similar ideas in databases• But for max concurrency, we want to allow as many “semantically” commuting invocations as possibleKD-Trees• Spatial data-structure– nearest(point) : point– add(point) : boolean– remove(point) : boolean• Typically implemented as a tree– But finding nearest is a little more complicated• Would like nearest and add to be concurrent if possible– When? Why?Commutativity Conditions Gatekeeping• Solution: keep log of nearest invocations and make sure that no add invalidates them– More general solution is to log all invocations and evaluate commutativity conditions wrt outstanding invocations• Tricky when conditions depend on state of data structure•Forward and general gatekeeping approaches• Other issues:– Gatekeeper itself should be concurrent– Inverse method should have same commutativityas forward methodGatekeeping in Galois• Most commutativityconditions are simple– Equalities and disequalitiesof parameters and return values• Simple implementation– Instrument data structure– Acquire locks on objects in different modes– Abstract locking approach– How is the different than the object-based approach?Partition-based locking• If topology is graph or grid, we can partition the data structure and associate locks with partitions• How do we ensure consistency?• How do we ensure commutativity?Art of Multiprocessor Programming by Maurice Herlihy19timeLinearizability: Intuitively for the single lock queueq.deq(x)q.enq(x)enqdeqlock()unlock()lock() unlock()enqdeqOther Correctness Conditions• Sequential Consistency• LinearizabilityT1 T2MemoryT1 enq(x)T1 ok()T2 enq(y)T2 ok()T2 deq()T2 ok(y)enq(x)enq(y)


View Full Document

UT CS 395T - Parallel Data Structures

Documents in this Course
TERRA

TERRA

23 pages

OpenCL

OpenCL

15 pages

Byzantine

Byzantine

32 pages

Load more
Download Parallel Data Structures
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Parallel Data Structures and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Parallel Data Structures 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?