Transcript ppt
Explicitly Parallel Programming with Shared-Memory is Insane: At Least Make it Deterministic! Joe Devietti, Brandon Lucia, Luis Ceze and Mark Oskin University of Washington Parallel Programming is Hard Race conditions make life difficult barrier_wait(); x = 1; barrier_wait(); x = 2; return x; 17% 100% 0% 83% 100% 0% Deterministic parallel execution would be nice! Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 2 Wouldn't it be nice if... ...execution were reproducible on a machine? No more heisenbugs! Run parallel programs forwards and backwards ...execution were reproducible across machines? Reduces the parallel testing coverage problem to the single-threaded testing coverage problem Can reproduce bugs found in the field Increases robustness of deployed parallel code Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 3 Related Work Deterministic, implicitly-parallel languages StreamIt [ASPLOS 2002], Jade [TOPLAS 1998] Typically domain-specific Record+replay RecPlay [TOCS 1999], FDR [ISCA 2003], Rerun [ISCA 2008], DeLorean [ISCA 2008] Log ordering of memory operations Serialize execution (Simics [Computer 2002]) Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 4 DMP: A Deterministic Multiprocessor Determinism: same input yields same output What is “input”? Input is value and timing of I/O and OS events DMP provides deterministic interleaving of memory operations Serialize execution in a consistent, but arbitrary way Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 5 Valid Non-deterministic Executions = lock, scheduling decision, race condition, ... DMP picks the Each root-leaf path same valid execution is a valid execution every time DMP serializes execution in a consistent way Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 6 Serialized Execution DT store A store P store B load A store A store B store P' store B “Deterministic Token” gets passed after every insn store P' store P load A 6 steps store B Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 7 Serialized Execution DT store A store P store B load A store P' store B Passing token after every insn is expensive store A One of Pass token after each n-insn quantum instead many possible store P store B serializations load A 6 steps store P' store B Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 8 Serialized Execution: Flow of Data A particular serialization enforces a particular flow of data store A store P store B load A store P' DMP enforces the same serialization across program runs store B Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 9 DMP Interface and Implementation Interface: deterministically serialized execution Preserves program behavior across runs Naïve implementation: Execute insns in round-robin order nx slowdown on n threads :-( Better implementation: “OoO superscalar” Serialize only when necessary Serialize only for as long as necessary Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 10 Recovering Parallelism Parallelize thread-private accesses Speculatively parallelize execution Transactional Memory (TM) TM + Speculative Value Forwarding Sharing Table TM-Forward Smarter Quantum Building Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 11 DMP-Sharing Table: Exploiting Thread-private Data store A store P store P' store B Thread-private accesses can't affect other threads store B load A Okay to execute private accesses in parallel Sharing Table: locations are Shared or Private Shared = S state, Private = M/E state Need to hold DT to update sharing table Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 12 DMP-TM: Leveraging Speculation store A store P store B load A store P' store B Execute quanta as implicit transactions Quanta execute speculatively in parallel Abort+retry if serialization was violated Commit quanta in order (need DT to commit) Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 13 DMP-TM Execution DT store A store B store P' store P load A store B store B load A store P' 6 6 steps store B Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 14 DMP-TM Execution store A store B store P' store P load A store B DT store B load A Ordering+isolation = “memory renaming” WAW/WAR are “false” conflicts 4 6 steps Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 15 DMP-TM-Forward: Speculative Value Forwarding store A store P store B load A store P' store B Speculatively forward values to “future” quanta Can potentially avoid squashes even with true (RAW) data dependences Must squash yourself if data you were forwarded is overwritten by “past” quantum When you squash, must squash all your consumers Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 16 TM-Forward Execution DT store A store B store P' store P load A store B 2 4 6 steps Same serial flow of data, but highly parallel execution! Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 17 Recovering Parallelism Sharing Table Parallelizes accesses to thread-private data Non-speculative TM and TM-Forward Speculation allows for more parallelism “memory renaming” means fewer squashes Smarter Quantum Building Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 18 Quantum Building Building quanta by just counting dynamic insns is simple, but can be slow lock L store A unlock L ... lock L store A unlock L ... Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 19 Naïve Quantum Building: Convoying lock L DT store A lock L lock L unlock L ... lock L store A Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 20 Smarter Quantum Building Enclose critical sections in a single quantum! Start new quantum after an “unlock” Other quantum building strategies in paper lock L store A unlock L ... lock L store A unlock L ... Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 21 Experimental Methodology Simulator using PIN Functionally models effects of serialization Models address conflicts, limited TM buffering Assume 1 IPC, free commits SPLASH2 benchmark suite Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 22 8.0 7.5 7.0 TM-Forward 6.5 6.0 TM 5.5 5.0 4.5 Serial SharingTable 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 23 8 benchmark 4 water-ns 2 8 4 volrend 2 8 4 radix 2 8 4 ocean-nc 2 8 4 ocean-c 2 8 4 lu-nc 2 8 4 lu-c 2 8 4 fft 2 runtime normalized to non-deterministic parallel execution Runtime Overhead 8.0 7.5 7.0 TM-Forward 6.5 6.0 TM 5.5 5.0 4.5 Serial SharingTable 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 24 8 benchmark 4 water-ns 2 8 4 volrend 2 8 4 radix 2 8 4 ocean-nc 2 8 4 ocean-c 2 8 4 lu-nc 2 8 4 lu-c 2 8 4 fft 2 runtime normalized to non-deterministic parallel execution Runtime Overhead 8.0 7.5 7.0 TM-Forward 6.5 6.0 TM 5.5 5.0 4.5 Serial SharingTable 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 25 8 benchmark 4 water-ns 2 8 4 volrend 2 8 4 radix 2 8 4 ocean-nc 2 8 4 ocean-c 2 8 4 lu-nc 2 8 4 lu-c 2 8 4 fft 2 runtime normalized to non-deterministic parallel execution Runtime Overhead 8.0 7.5 7.0 6.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 TM-Forward TM SharingTable Serial Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 26 8 benchmark 4 water-ns 2 8 4 volrend 2 8 4 radix 2 8 4 ocean-nc 2 8 4 ocean-c 2 8 4 lu-nc 2 8 4 lu-c 2 8 4 fft 2 runtime normalized to non-deterministic parallel execution Runtime Overhead Non-deterministic events environmental factors Network I/O I/O DMP memory interleavings File I/O OS events Thread Scheduling IPC Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 27 Conclusions Determinism is a Good Thing Simplifies debugging, testing and (potentially) deployment of parallel programs We want sequential behavior with parallel performance We show several ways to build efficient DMPs No memory log Competitive performance Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 28 Questions? Deterministic Multiprocessors – Joe Devietti – SHCMP 2008 29