Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simplify Parallel Programming with Patterns Primož Gabrijelčič R&D Manager, FAB.

Similar presentations


Presentation on theme: "Simplify Parallel Programming with Patterns Primož Gabrijelčič R&D Manager, FAB."— Presentation transcript:

1 Simplify Parallel Programming with Patterns Primož Gabrijelčič R&D Manager, FAB

2 Multithreading is Hard 2 “New programmers are drawn to multithreading like moths to flame, with similar results.” - Danny Thorpe

3 Solution Extract all hard parts into a boilerplate code. Test it. Test again. Test repeatedly. Reuse as much as possible. Test again. Don’t stop testing. – or – Use existing library. 3

4 Bugs Away! 4 “The code that you don’t write, contains no bugs.” - Primož Gabrijelčič

5 Adapt the Algorithm to the Pattern don‘t write the code for your algorithm decompose the algorithm into the patterns when everything fails, go low-level tasks first [CodeRage 9: Parallel Programming Library] threads last 5

6 Frameworks PPL Parallel Programming Library XE7+, all platforms, RTL license patterns: For, Future, Join OTL OmniThreadLibrary 2009+ (patterns), 2007+ (tasks), Windows (VCL/console/service) only (but working on that), OpenBSD license patterns: Async[/Await], Background worker, For, Fork/Join, Future, Join, Map, Parallel task, Pipeline 6

7 Patterns Async/Await Fire asynchronous tasks Future Execute long calculation in background https://en.wikipedia.org/wiki/Futures_and_promises For Use all of available CPUs when processing large data https://en.wikipedia.org/wiki/Embarrassingly_parallel Map Converting data in parallel 7

8 Async/Await 8

9 Future 9

10 For 10

11 Map 11

12 Important Facts We Learned Today Don’t write boilerplate code – use patterns Be careful when accessing shared data Never access the GUI from a background thread! 12

13 Q&A Primož Gabrijelčič blogwww.thedelphigeek infoprimoz.gabrijelcic.org emailprimoz@gabrijelcic.org twitter@thedelphigeek skypegabr42 13


Download ppt "Simplify Parallel Programming with Patterns Primož Gabrijelčič R&D Manager, FAB."

Similar presentations


Ads by Google