reflective parallel programming
play

Reflective Parallel Programming Nicholas D. Matsakis, Thomas R. - PowerPoint PPT Presentation

Reflective Parallel Programming Nicholas D. Matsakis, Thomas R. Gross ETH Zurich 1 Friday, June 18, 2010 Reflective Parallelism Reflection : Ability for a program to reason about its own structure Reflective Parallelism : Ability for


  1. Querying the Schedule a.end.hb(b.start)? a true (lock) a.locks(lock)? true b.end.hb(a.start)? b b.locks(lock)? 23 Friday, June 18, 2010

  2. Querying the Schedule a.end.hb(b.start)? a true (lock) a.locks(lock)? true ? b.end.hb(a.start)? b b.locks(lock)? 23 Friday, June 18, 2010

  3. Querying the Schedule a.end.hb(b.start)? a true (lock) a.locks(lock)? true ? b.end.hb(a.start)? b false b.locks(lock)? 23 Friday, June 18, 2010

  4. Querying the Schedule a.end.hb(b.start)? a true (lock) a.locks(lock)? true b.end.hb(a.start)? b false b.locks(lock)? 23 Friday, June 18, 2010

  5. Querying the Schedule a.end.hb(b.start)? a true (lock) a.locks(lock)? true b.end.hb(a.start)? b false b.locks(lock)? false 23 Friday, June 18, 2010

  6. Monotonicity • Edges and locks can only be added, not removed • Necessary for static analysis: • Compiler knows that edges and locks it sees cannot be removed at runtime 24 Friday, June 18, 2010

  7. Outline • What is reflective parallel programming? • Why do we need a new model? • Intervals model • Example: Data-race detection 25 Friday, June 18, 2010

  8. Outline • What is reflective parallel programming? • Why do we need a new model? • Intervals model • Example: Data-race detection 25 Friday, June 18, 2010

  9. Data Race Detection • Key Idea: • User defines conditions in which a field can be accessed • Use the reflective API to determine whether conditions are met 26 Friday, June 18, 2010

  10. Locked Fields class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 27 Friday, June 18, 2010

  11. Locked Fields class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 27 Friday, June 18, 2010

  12. Locked Fields class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 27 Friday, June 18, 2010

  13. Locked Fields class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 27 Friday, June 18, 2010

  14. Locked Fields class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 27 Friday, June 18, 2010

  15. Dynamic Checking void setString() { assert current.locks(theLock); theString = "..."; } 28 Friday, June 18, 2010

  16. Dynamic Checking void setString() { assert current.locks(theLock); theString = "..."; } 28 Friday, June 18, 2010

  17. Dynamic Checking void setString() { assert current.locks(theLock); theString = "..."; } 28 Friday, June 18, 2010

  18. Dynamic Checking void setString() { assert current.locks(theLock); theString = "..."; } 28 Friday, June 18, 2010

  19. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x.ready(); } 29 Friday, June 18, 2010

  20. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x.ready(); } 29 Friday, June 18, 2010

  21. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x.ready(); } 29 Friday, June 18, 2010

  22. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x.ready(); } 29 Friday, June 18, 2010

  23. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x x.ready(); } 29 Friday, June 18, 2010

  24. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x x.ready(); } 29 Friday, June 18, 2010

  25. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x x.ready(); (theLock) } 29 Friday, June 18, 2010

  26. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x x.ready(); (theLock) } 29 Friday, June 18, 2010

  27. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x x.ready(); (theLock) } 29 Friday, June 18, 2010

  28. Static Checking void staticCheck() { Interval x = interval { assert current.locks(theLock); theString = "..."; } x.addLock(theLock); x x.ready(); (theLock) } 29 Friday, June 18, 2010

  29. Guard Objects • Our compiler automatically enforces these kind of checks using guard objects • Guard object defines methods that check each read and write for validity • When possible, checks are performed statically 30 Friday, June 18, 2010

  30. Guard Object Annotations class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 31 Friday, June 18, 2010

  31. Guard Object Annotations class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 31 Friday, June 18, 2010

  32. Guard Object Annotations class TheClass { final Lock theLock; @GuardedBy(theLock) String theString; ... } 31 Friday, June 18, 2010

  33. Custom Guards • Example Conditions • Written only by one interval • Dynamic monitoring • Lock only on writes, not reads • Select lock dynamically 32 Friday, June 18, 2010

  34. Summary • User defines conditions to access a field by writing code against the reflective API • Compiler runs checks statically if possible • Runtime can run checks with live schedule 33 Friday, June 18, 2010

  35. Related Work • Smalltalk • Reflective objects for stack frames, etc • Debuggers and other tools require no special support from VM • Traditional threading model • More in the paper 34 Friday, June 18, 2010

  36. Conclusion • Reflective parallelism empowers users: • Custom tools for safety checking and monitoring • Reflective parallelism as foundation for static analysis: • Seamless integration of static and dynamic checks 35 Friday, June 18, 2010

  37. Thank You • Intervals library is available for download: • http://intervals.inf.ethz.ch 36 Friday, June 18, 2010

  38. Spare Slides 37 Friday, June 18, 2010

  39. Schedule Model Hierarchical Structure 38 Friday, June 18, 2010

  40. Illegal Additions • Schedule is being built and executed simultaneously • Certain additions are illegal 39 Friday, June 18, 2010

  41. Adding Edges void method( a Interval a, Interval b) { a.end.addHb(b.start); b } 40 Friday, June 18, 2010

  42. Adding Edges void method( a Interval a, Interval b) { a.end.addHb(b.start); b } What if b had already begun execution? 40 Friday, June 18, 2010

  43. Adding Edges c void method( a Interval a, Interval b) { a.end.addHb(b.start); b } If method is part of c, b cannot have started. 41 Friday, June 18, 2010

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