Parallel Data Structures. Story so far Wirth’s motto –Algorithm + Data structure = Program So far, we have studied –parallelism in regular and irregular.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
What is Concurrent Process (CP)? Multiple users access databases and use computer systems Multiple users access databases and use computer systems simultaneously.
Transaction Program unit that accesses the database
Database Systems (資料庫系統)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Lock-Based Concurrency Control
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture X: Transactions.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. –Because disk accesses are.
Chapter 6 Process Synchronization: Part 2. Problems with Semaphores Correct use of semaphore operations may not be easy: –Suppose semaphore variable called.
Quick Review of Apr 29 material
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
Distributed Systems 2006 Styles of Client/Server Computing.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Processing: Concurrency and Serializability 10/4/05.
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Academic Year 2014 Spring Academic Year 2014 Spring.
CIS 720 Concurrency Control. Locking Atomic statement –Can be used to perform two or more updates atomically Th1: …. ;……. Th2:…………. ;…….
1 Transaction Management Overview Chapter Transactions  Concurrent execution of user programs is essential for good DBMS performance.  Because.
08_Transactions_LECTURE2 DBMSs should guarantee ACID properties (Atomicity, Consistency, Isolation, Durability). This is typically done by guaranteeing.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Database Systems/COMP4910/Spring05/Melikyan1 Transaction Management Overview Unit 2 Chapter 16.
Chapter 11 Concurrency Control. Lock-Based Protocols  A lock is a mechanism to control concurrent access to a data item  Data items can be locked in.
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
A Consistency Framework for Iteration Operations in Concurrent Data Structures Yiannis Nikolakopoulos A. Gidenstam M. Papatriantafilou P. Tsigas Distributed.
1 Concurrency Control II: Locking and Isolation Levels.
CORRECTNESS CRITERIA FOR CONCURRENCY & PARALLELISM 6/16/2010 Correctness Criteria for Parallelism & Concurrency 1.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
7c.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Module 7c: Atomicity Atomic Transactions Log-based Recovery Checkpoints Concurrent.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
Concurrency Control Introduction Lock-Based Protocols
1 Concurrency control lock-base protocols timestamp-based protocols validation-based protocols Ioan Despi.
Timestamp-based Concurrency Control
1 Lecture 4: Transaction Serialization and Concurrency Control Advanced Databases CG096 Nick Rossiter [Emma-Jane Phillips-Tait]
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Concurrency Control 2004, Spring Pusan National University Ki-Joune Li.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
Academic Year 2014 Spring Academic Year 2014 Spring.
MULTIUSER DATABASES : Concurrency and Transaction Management.
Transaction Management and Concurrency Control
Transaction Management Overview
Concurrent Objects Companion slides for
Concurrency Control.
Transaction Management
Transaction Management Overview
Transaction Management
Transaction Management Overview
Chapter 10 Transaction Management and Concurrency Control
Chapter 15 : Concurrency Control
Multicore programming
Transaction Management
Transaction Management Overview
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Transaction Management Overview
Parallel Data Structures
Transactions, Properties of Transactions
Presentation transcript:

Parallel Data Structures

Story 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 structures Algorithm (Galois program written by Joe) Data structure (library written by Stephanie) Galois library API Galois programming model

Parallel 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 maintain

Working 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 versa

Pictorially enq(x) deq()/? enq(y) deq()/? enq(z) time Iteration1 Iteration2 Object: queue Methods: enq(x),deq()/y, Thread1 starts executing Stephanie code for m1 Thread1 completes Stephanie code and resumes Joe code enq(x)deq()/x enq(y) deq()/yenq(z) Iteration2 Must be equivalent to Iteration1 enq(x)deq()/z enq(y) deq()/y enq(z) Iteration2 Iteration1 OR

Two 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() time Iteration1 Iteration2 Object: o Methods: m1,m2,m3,m4,m5

Some 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, …) Iteration1Iteration2 Two-phase locking incremental requires rollback –old idea: Eswaran and Gray (1976) –we will call it catch-and-keep lock(o1) o1.m() lock(o2) o2.m() … unlock(o1, o2, …) lock(o2) o2.m() lock(o1) o1.m() … unlock(o1, o2, …) Iteration1Iteration2

Problem: 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 tuples

Discussion 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 Timewarp implementation

Performance 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 graph

Catch-and-release objects 1.Use lock to ensure consistency but release lock on object after method invocation is complete 2.Check commutativity explicitly in gate- keeper object –Maintains serializability 3.Need inverse method to undo the effect of method invocation in case of rollback

Gatekeeping Log T1 T2 m1 m2 m3 Base Object m2 m3 Abort!

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 possible

KD-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 commutativity as forward method

Gatekeeping in Galois Most commutativity conditions are simple –Equalities and disequalities of 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 Herlihy 19 time Linearizability: Intuitively for the single lock queue q.deq(x) q.enq(x) enq deq lock() unlock() lock() unlock() enq deq

Other Correctness Conditions Sequential Consistency Linearizability T1T2 Memory T1 enq(x) T1 ok() T2 enq(y) T2 ok() T2 deq() T2 ok(y) enq(x) enq(y)deq()/x 1.Concurrent operations happen in some sequential order 2.Partial order on non-overlapping operations

Partitioning arrays

Standard array partitions Standard partitions supported in Scalapack (dense numerical linear algebra library), High-performance FORTRAN (HPF), etc. –block –cyclic –block-cyclic Block-cyclic subsumes the other two

Block

Cyclic partitioning

Common use of block-cyclic

Distributions for 2D arrays

Distributing both dimensions