memory consistency models
play

Memory Consistency Models Adam Wierman Daniel Neill Adve, Pai, and - PowerPoint PPT Presentation

Memory Consistency Models Adam Wierman Daniel Neill Adve, Pai, and Ranganathan. Recent advances in memory consistency models for hardware shared-memory systems, 1999. Gniady, Falsafi, and Vijaykumar . Is SC+ILP=RC? , 1999. Hill. Multiprocessors


  1. Memory Consistency Models Adam Wierman Daniel Neill Adve, Pai, and Ranganathan. Recent advances in memory consistency models for hardware shared-memory systems, 1999. Gniady, Falsafi, and Vijaykumar . Is SC+ILP=RC? , 1999. Hill. Multiprocessors should support simple memory consistency models , 1998. Architecture Carnegie Mellon 1 School of Computer Science

  2. Memory consistency models • The memory consistency model of a shared-memory system determines the order in which memory operations will appear to execute to the programmer. – Processor 1 writes to some memory location… – Processor 2 reads from that location… – Do I get the result I expect? • Different models make different guarantees; the processor can reorder/overlap memory operations as long as the guarantees are upheld. Tradeoff between programmability and performance! Architecture Carnegie Mellon 2 School of Computer Science

  3. Code example 1 initially Data1 = Data2 = Flag = 0 P1 P2 Data1 = 64 while (Flag != 1) {;} Data2 = 55 register1 = Data1 Flag = 1 register2 = Data2 What should happen? Architecture Carnegie Mellon 3 School of Computer Science

  4. Code example 1 initially Data1 = Data2 = Flag = 0 P1 P2 Data1 = 64 while (Flag != 1) {;} Data2 = 55 register1 = Data1 Flag = 1 register2 = Data2 What could go wrong? Architecture Carnegie Mellon 4 School of Computer Science

  5. Three models of memory consistency • Sequential Consistency (SC): – Memory operations appear to execute one at a time, in some sequential order. – The operations of each individual processor appear to execute in program order. • Processor Consistency (PC): – Allows reads following a write to execute out of program order (if they’re not reading/writing the same address!) – Writes may not be immediately visible to other processors, but become visible in program order. • Release Consistency (RC): – All reads and writes (to different addresses!) are allowed to operate out of program order. Architecture Carnegie Mellon 5 School of Computer Science

  6. Code example 1 initially Data1 = Data2 = Flag = 0 P1 P2 Data1 = 64 while (Flag != 1) {;} Data2 = 55 register1 = Data1 Flag = 1 register2 = Data2 Does it work under: • SC (no relaxation)? • PC (Write → Read relaxation)? • RC (all relaxations)? Architecture Carnegie Mellon 6 School of Computer Science

  7. Code example 2 initially Flag1 = Flag2 = 0 P1 P2 Flag1 = 1 Flag2 = 1 register1 = Flag2 register2 = Flag1 if (register1 == 0) if (register2 == 0) critical section critical section What should happen? Architecture Carnegie Mellon 7 School of Computer Science

  8. Code example 2 initially Flag1 = Flag2 = 0 P1 P2 Flag1 = 1 Flag2 = 1 register1 = Flag2 register2 = Flag1 if (register1 == 0) if (register2 == 0) critical section critical section What could go wrong? Architecture Carnegie Mellon 8 School of Computer Science

  9. Code example 2 initially Flag1 = Flag2 = 0 P1 P2 Flag1 = 1 Flag2 = 1 register1 = Flag2 register2 = Flag1 if (register1 == 0) if (register2 == 0) critical section critical section Does it work under: • SC (no relaxation)? • PC (Write → Read relaxation)? • RC (all relaxations)? Architecture Carnegie Mellon 9 School of Computer Science

  10. The performance/programmability tradeoff Increasing performance Increasing programmability Architecture Carnegie Mellon 10 School of Computer Science

  11. Programming difficulty • PC/RC include special synchronization operations to allow specific instructions to execute atomically and in program order. • The programmer must identify conflicting memory operations, and ensure that they are properly synchronized. • Missing or incorrect synchronization → program gives unexpected/incorrect results. • Too many unnecessary synchronizations → performance reduced (no better than SC?) Idea: normally ensure sequential consistency; allow programmer to specify when relaxation possible? Architecture Carnegie Mellon 11 School of Computer Science

  12. Code example 1, revisited initially Data1 = Data2 = Flag = 0 P1 P2 Data1 = 64 while (Flag != 1) {;} Data2 = 55 MEMBAR (LD-LD) MEMBAR (ST-ST) register1 = Data1 Flag = 1 register2 = Data2 Programmer adds synchronization commands… … and now it works as expected! Architecture Carnegie Mellon 12 School of Computer Science

  13. Performance of memory consistency models • Relaxed memory models (PC/RC) hide much of memory operations’ long latencies by reordering and overlapping some or all memory operations. – PC/RC can use write buffering. – RC can be aggressively out of order. • This is particularly important: – When cache performance poor, resulting in many memory operations. – In distributed shared memory systems, when remote memory accesses may take much longer than local memory accesses. • Performance results for straightforward implementations: as compared to SC, PC and RC reduce execution time by 23% and 46% respectively (Adve et al). Architecture Carnegie Mellon 13 School of Computer Science

  14. The big question How can SC approach the performance of RC? Architecture Carnegie Mellon 14 School of Computer Science

  15. How can SC approach RC? 2 Techniques Hardware Compiler Optimizations Optimizations Architecture Carnegie Mellon 15 School of Computer Science

  16. What can SC do? Can SC have Can SC have YES YES YES Can SC have non-binding per-processor multithreading? prefetching? caches? Hardware Optimizations NO Can SC use a write buffer? SC cannot reorder memory operations because it might cause inconsistency. Architecture Carnegie Mellon 16 School of Computer Science

  17. Speculation with SC SC only needs to appear to do memory operations in order 1. Speculatively perform all memory operations 2. Roll back to “sequentially consistent” Hardware state if constraints are violated Optimizations This emulates RC as long as rollbacks are infrequent. Architecture Carnegie Mellon 17 School of Computer Science

  18. Speculation with SC SC only needs to appear to do memory operations in order 1. Speculatively perform all memory operations 2. Roll back to “sequentially consistent” Hardware state if constraints are violated Optimizations • Must allow both loads and stores to bypass each other • Needs a very large speculative state • Don’t introduce overhead to the pipeline Architecture Carnegie Mellon 18 School of Computer Science

  19. Speculation with SC SC only needs to appear to do memory operations in order 1. Speculatively perform all memory operations 2. Roll back to “sequentially consistent” Hardware state if constraints are violated Optimizations • Must detect violations quickly • Must be able to roll back quickly • Rollbacks can’t happen often Architecture Carnegie Mellon 19 School of Computer Science

  20. Results SC only needs to appear to do memory operations in order These changes were implemented Hardware in SC++ and results showed a Optimizations narrowing gap as compared to PC and RC The gap is Unlimited SHiQ, negligible! BLT … but SC++ used significantly more hardware. Architecture Carnegie Mellon 20 School of Computer Science

  21. How can SC approach RC? 2 Techniques Hardware Compiler Optimizations Optimizations Architecture Carnegie Mellon 21 School of Computer Science

  22. Compiler optimizations? P1 P2 • Data1 = 64 while (Flag != 1) {;} • Data2 = 55 register1 = Data1 • Flag = 1 register2 = Data2 Compiler Optimizations If we could figure out ahead of time which operations need to be run in order we wouldn’t need speculation Architecture Carnegie Mellon 22 School of Computer Science

  23. Where are the conflicts? P1 P2 • Data1 = 64 while (Flag != 1) {;} • Data2 = 55 register1 = Data1 • Flag = 1 register2 = Data2 Guaranteeing no operations on an edge in a cycle are reordered Write Data1 guarantees consistency! Compiler Optimizations Write Data2 Read Flag Write Flag Read Data1 If there are no cycles then there Read Data2 are no conflicts Architecture Carnegie Mellon 23 School of Computer Science

  24. Conclusion SC approaches RC Speculation and compiler optimizations allow SC to achieve nearly the same performance as RC RC approaches SC Programming constructs allow user to distinguish possible conflicts as synchronization operations and atill obtain the simplicity of SC Architecture Carnegie Mellon 24 School of Computer Science

  25. Memory Consistency Models Adam Wierman Daniel Neill Adve, Pai, and Ranganathan. Recent advances in memory consistency models for hardware shared-memory systems, 1999. Gniady, Falsafi, and Vijaykumar . Is SC+ILP=RC? , 1999. Hill. Multiprocessors should support simple memory consistency models , 1998. Architecture Carnegie Mellon 25 School of Computer Science

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend