HIGHLEVEL MULTITHREADED PROGRAMMINGPrimo PART II Gabrijeli BACKGROUND INFORMATION
HIGH-LEVEL MULTITHREADED PROGRAMMINGPrimož [PART II] Gabrijelčič
BACKGROUND INFORMATION
About Me • Primož Gabrijelčič • Programmer, consultant, writer, speaker – thedelphigeek. com – www. glagolite. si/delphi • Hacking multithreaded code since 1999
About Omni. Thread. Library • „VCL for multithreading“ • Delphi 2007 – XE 3[4] • Open source – Open. BSD license – www. omnithreadlibrary. com – omnithreadlibrary. googlecode. com • Win 32/Win 64
About the Webinars • Code and video: www. omnithreadlibrary. com/webinars • Code = free, video = $10 • 20 free books, courtesy of the De Novo Software, www. denovosoftware. com
High-Level Abstractions • • Async [/Await] Future Join For. Each • • Parallel. Task Background. Worker Fork. Join Pipeline
High-Level Abstractions • Parallel. Task • Async [/Await] • Background. Worker • Future • Fork. Join • Join Start multiple background tasks [and wait] • For. Each • Pipeline
Join
High-Level Abstractions • Parallel. Task • Async [/Await] Start multiple copies of a single task • Future • Join • For. Each • Background. Worker • Fork. Join • Pipeline
Parallel. Task
High-Level Abstractions • Parallel. Task • Async [/Await] • Background. Worker • Future Background request-processing service • Join • For. Each • Fork. Join • Pipeline
Background Worker
Background. Worker Usage • service : = Paralell. Background. Worker. On. Request. Done(code 1). Execute(code 2); • work. Item : = service. Create. Work. Item(data); • service. Schedule(work. Item) • service. Terminate; service : = nil;
High-Level Abstractions • Async [/Await] • Future • Join • Parallel. Task • Background. Worker • Fork. Join Divide and conquer • For. Each • Pipeline
Fork/Join
Fork/Join Usage • computation : = Parallel. Fork. Join; • compute 1 : = computation. Compute(action); – Inside action: computation. Compute(new. Action) • compute 2 : = computation. Compute(action); • compute 1. Value / compute 1. Await • compute 2. Value / compute 2. Await
PARTING NOTES
Keep in Mind • • • Don’t parallelize everything Rethink the algorithm Data flow dictates the abstraction Measure the improvements Test, test and test
Code & Video • Will be available shortly at www. omnithreadlibrary. com/webinars
- Slides: 19