1 / 26

Multithreading Made Simple with OmniThreadLibrary

Multithreading Made Simple with OmniThreadLibrary. Primož Gabrijelčič. Introduction. OmniThreadLibrary is …. … VCL for multithreading Simplifies programming tasks Componentizes solutions Allows access to the bare metal … trying to make multithreading possible for mere mortals

moses
Download Presentation

Multithreading Made Simple with OmniThreadLibrary

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Multithreading Made Simple with OmniThreadLibrary Primož Gabrijelčič

  2. Introduction

  3. OmniThreadLibrary is … • … VCL for multithreading • Simplifies programming tasks • Componentizes solutions • Allows access to the bare metal • … trying to make multithreading possible for mere mortals • … providing well-tested components packed in reusable classes with high-level parallel programming support • … parallel programming today!

  4. Project status • OpenBSD license • Actively developed • 1008 commits • Actively used • 2.0: 2710 downloads [in 7 months] • 2.1: 1187 downloads [in 3 months] • 2.2: current release, XE2 support • Delphi 2007 and above; currently Win32 only

  5. Installation • Download last installation from the Google Code or checkout the SVN repository • code.google.com/p/omnithreadlibrary/ • Add installation folder and its src subfolder to the project search path or Win32 library path • Add the OtlParallel unit to the uses list • That’s all folks!

  6. Future • Win64 • FMX • OS/X • iOS?

  7. OmniThreadLibrary basics

  8. Task vs. thread

  9. Communication

  10. High-level multithreading

  11. Be afraid “New programmers are drawn to multithreading like moths to flame, with similar results.” -Danny Thorpe

  12. Why high-level approach? • Designing parallel solutions is hard • Writing multithreaded code is hard • Testing multicore applications is hard • Debugging multithreadingcode is pure insanity • Debugging multithreading code is hard

  13. High-level multithreading • Async • start background task and continue • Future • start background calculation and retrieve the result • Join • start multiple background tasks and wait • ParallelTask • start multiple copies of one task and wait

  14. High-level multithreading • ForEach • parallel iteration over many different containers • Pipeline • run a multistage process • Fork/Join • divide and conquer, in parallel • Delphi 2009 required

  15. Async • Parallel.Async(code)

  16. Future • Future:=Parallel.Future<type>. (calculation); • Query Future.Value;

  17. Join • Parallel.Join([task1, task2, task3, … taskN]).Execute

  18. ParallelTask • Parallel.ParallelTask.Execute (code)

  19. ParallelFor • Parallel.ForEach(from, to).Execute(procedure (const value: integer);begin//…end) • Parallel.ForEach(source).Execute(procedure (const value: TOmniValue);begin//…end)

  20. ParallelFor

  21. Pipeline example

  22. Pipeline • Parallel.Pipeline([stage1, stage2, stage3]). Run

  23. Fork/Join • Divide and conquer

  24. Multithreading is hard?

  25. Why high-level approach? • Designing parallel solutions is hard • Writing multithreaded code is hard • Testing multicore applications is hard • Debugging multithreadingcode is pure insanity • Debugging multithreading code is hard

  26. Questions?

More Related