270 likes | 460 Views
Serialization Sets A Dynamic Dependence-Based Parallel Execution Model. Matthew D. Allen Srinath Sridharan Gurindar S. Sohi University of Wisconsin-Madison. Motivation. Multicore processors ubiquitous Performance via parallel execution Multithreaded programming is problematic
E N D
Serialization SetsA Dynamic Dependence-Based Parallel Execution Model Matthew D. Allen SrinathSridharan Gurindar S. Sohi University of Wisconsin-Madison
Motivation • Multicore processors ubiquitous • Performance via parallel execution • Multithreaded programming is problematic • Dependences encoded statically • Difficult to reason about locks, synchronization • Many errors not found in sequential programs • Execution is nondeterministic • Need better parallel execution models! PPoPP 2009
Serialization Sets Overview • Sequential program with annotations • Identify potentially independent methods • Associate a serializer with these methods • Serializer groups dependent method invocations into serialization sets • Runtime executes in order to honor dependences • Serializer attempts to map independent methods invocations into different sets • Runtime opportunistically parallelizes execution PPoPP 2009
Serialization Sets Overview • Sequential program with no locks and no explicit synchronization • Deterministic, race-free execution • Comparable performance to multithreading • Sometimes better! PPoPP 2009
Outline • Overview • Serialization Sets Execution Model • Prometheus: C++ Library for SS • Experimental Evaluation • Related Work & Conclusions PPoPP 2009
Running Example # of transactions? trans_t* trans; while ((trans = get_trans ()) != NULL) { account_t* account = trans->account; if (trans->type == DEPOSIT) account->deposit (trans->amount); if (trans->type == WITHDRAW) account->withdraw (trans->amount); } Points to? Loop-carried dependence? Several static unknowns! PPoPP 2009
Multithreading Strategy Oblivious to what accounts each thread may access! → Methods must lock account to → ensure mutual exclusion trans_t* trans; while ((trans = get_trans ()) != NULL) { account_t* account = trans[i]->account; if (trans->type == DEPOSIT) account->deposit (trans->amount); if (trans->type == WITHDRAW) account->withdraw (trans->amount); } • Read all transactions into an array • Divide chunks of array among multiple threads PPoPP 2009
Serialization Sets • Potentially independent methods • Modify only data owned by object • Fields / Data members • Pointers to non-shared data • Consistent with OO practices (modularity, encapsulation, information hiding) • Modifying methods for independence • Store return value in object, retrieve with accessor • Copy pointer data PPoPP 2009
Serialization Sets • Divide program into isolation epochs • Data partitioned into domains • Privately writable: data that may be read or written by a single serialization set • Object or set of objects • Serializer dynamically identifies serialization set for each method invocation • Shared read-only: data that may be read (but not written) by any method PPoPP 2009
Example with Serialization Sets writable <account_t, acct_ser_t> pw_account_t; begin_isolation (); trans_t* trans; while ((trans = get_trans ()) != NULL) { pw_account_t* account = trans->account; if (trans->type == DEPOSIT) delegate(account, deposit, trans->amount); if (trans->type == WITHDRAW) delegate(account, withdraw, trans->amount); } end_isolation (); Declare privately-writable account Serializer type: uses account number to compute serialization set Delegate indicates potentially-independent operations • At execution, delegate: • Executes serializer • Identifies serialization set • Inserts invocation in serialization set Begin isolation epoch End isolation epoch PPoPP 2009
Delegate context Program context SS #100 SS #200 SS #300 delegate deposit acct=100 $2000 deposit acct=100 $300 withdraw acct=100 $50 withdraw acct=100 $20 delegate delegate delegate withdraw acct=200 $1000 withdraw acct=200 $1000 delegate delegate delegate delegate withdraw acct=300 $350 deposit acct=300 $5000 Serializer: computes SS with account number ss_t ss = account->get_number(); PPoPP 2009
Delegate threads Delegate context Program thread Program context SS #100 Delegate 0 SS #200 Delegate 1 SS #300 delegate withdraw acct=100 $50 withdraw acct=100 $20 deposit acct=100 $2000 deposit acct=100 $300 withdraw acct=100 $50 withdraw acct=100 $20 deposit acct=100 $300 deposit acct=100 $2000 delegate delegate delegate withdraw acct=200 $1000 withdraw acct=200 $1000 withdraw acct=200 $1000 withdraw acct=200 $1000 delegate delegate delegate delegate withdraw acct=300 $350 withdraw acct=300 $350 deposit acct=300 $5000 deposit acct=300 $5000 Race-free, deterministic execution without synchronization! PPoPP 2009
Parallel Execution w/o Sharing • Vary data in privately-writable/read-only domains in alternating epochs • Outputs of one epoch become inputs of the next • Associative, commutative methods • Operate on local copy of state • Reduction to summarize result • Containers manipulated by program context • Delegate operations on underlying data PPoPP 2009
Outline • Overview • Serialization Sets Execution Model • Prometheus: C++ Library for SS • Experimental Evaluation • Related Work & Conclusions PPoPP 2009
Prometheus: C++ Library for SS • Template library • Compile-time instantiation of SS data structures • Metaprogramming for static type checking • Runtime orchestrates parallel execution • Portable • x86, x86_64, SPARC V9 • Linux, Solaris PPoPP 2009
Prometheus Serializers • Serializers • Subclass serializer base class and override method • Or use built-in serializer supplied by library • Reducibles • Subclass reducible base class and override virtual reduce method • Reduction automatically performed on first use after isolation epoch ends PPoPP 2009
Prometheus Runtime Program Thread Delegate Thread 0 Delegate Thread 2 Delegate Thread 1 Delegate assignment: SS % NUM_THREADS Communication queues: Fast-Forward [PPoPP 2008] + Polymorphic interface PPoPP 2009
Debugging Support • Tag all data accessed by serialization set • Objects • Smart pointers • Any data accessed by multiple serialization sets indicates programmer error • Problem: can’t detect some kinds of missing annotations • Future work: static checking of annotations PPoPP 2009
Debugging Support • Deterministic model means we can simulate SS execution in sequential program • Prometheus support for compiling debug version • Do all debugging on sequential program! • Correct sequential → correct parallel (caveat: for a given input) PPoPP 2009
Outline • Overview • Serialization Sets Execution Model • Prometheus: C++ Library for SS • Experimental Evaluation • Related Work & Conclusions PPoPP 2009
Evaluation Methodology • Benchmarks • Lonestar, NU-MineBench, PARSEC, Phoenix • Conventional Parallelization • pthreads, OpenMP • Prometheus versions • Port program to sequential C++ program • Idiomatic C++: OO, inheritance, STL • Parallelize with serialization sets PPoPP 2009
Results Summary 4 Socket AMD Barcelona (4-way multicore) = 16 total cores PPoPP 2009
Results Summary PPoPP 2009
Outline • Overview • Serialization Sets Execution Model • Prometheus: C++ Library for SS • Experimental Evaluation • Related Work & Conclusions PPoPP 2009
Related Work • Actors / Active Objects • Hewitt [JAI 1977] • MultiLisp • Halstead [ACM TOPLAS 1985] • Inspector-Executor • Wu et al. [ICPP 1991] • Jade • Rinard and Lam [ACM TOPLAS 1998] • Cilk • Frigo et al. [PLDI 1998] • OpenMP PPoPP 2009
Conclusions • Sequential program with annotations • No explicit synchronization, no locks • Programmers focus on keeping computation private to object state • Consistent with OO programming practices • Dependence-based model • Deterministic race-free parallel execution • Performance close to, and sometimes better, than multithreading PPoPP 2009
Questions PPoPP 2009