Multithreading Made Simple with OmniThreadLibrary

Slides:



Advertisements
Similar presentations
H IGH - LEVEL M ULTITHREADED P ROGRAMMING [P ART I] Primož Gabrijelčič.
Advertisements

H IGH - LEVEL M ULTITHREADED P ROGRAMMING [P ART II] Primož Gabrijelčič.
H IGH - LEVEL M ULTITHREADED P ROGRAMMING [P ART III] Primož Gabrijelčič.
Developing Grid User Interface Components Portlets, gadgets, etc.
Parallel Programming with OmniThreadLibrary
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Fast programs for modern computers
CHAPTER 5 THREADS & MULTITHREADING 1. Single and Multithreaded Processes 2.
Parallel Programming Made Easy Primož Gabrijelčič,
Version Control System Sui Huang, McMaster University Version Control SystemSui Huang, McMaster University Version Control System -- base on Subversion.
Intro to Threading CS221 – 4/20/09. What we’ll cover today Finish the DOTS program Introduction to threads and multi-threading.
Threads Section 2.2. Introduction to threads A thread (of execution) is a light-weight process –Threads reside within processes. –They share one address.
An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 OpenMP -Example ICS 535 Design and Implementation.
Cloud Computing Lecture #1 Parallel and Distributed Computing Jimmy Lin The iSchool University of Maryland Monday, January 28, 2008 This work is licensed.
Eclipse IDE. 2 IDE Overview An IDE is an Interactive Development Environment Different IDEs meet different needs BlueJ and DrJava are designed as teaching.
G ETTING F ULL S PEED WITH D ELPHI Primož Gabrijelčič otl.17slon.com [W HY S INGLE -T HREADING I S N OT E.
By: Taylor Helsper.  Introduction  Bug Tracking  Progress Tracking  Version Control  Conclusion  Questions.
 A FPS (First Person Shooter) game from 1999  The source code was released in 2005  It is entirely written in C and ASM.
Advanced Topics: MapReduce ECE 454 Computer Systems Programming Topics: Reductions Implemented in Distributed Frameworks Distributed Key-Value Stores Hadoop.
How do developers use parallel Libraries? Semih Okur & Danny Dig University of Illinois at Urbana- Champaign.
OpenMP in a Heterogeneous World Ayodunni Aribuki Advisor: Dr. Barbara Chapman HPCTools Group University of Houston.
1 Developing Native Device for MPJ Express Advisor: Dr. Aamir Shafi Co-advisor: Ms Samin Khaliq.
Building Multithreaded Solutions with OmniThreadLibrary
CS Tutorial 1 Getting Started with Visual Studio 2012 (Visual Studio 2010 are no longer available on MSDNAA, please choose Visual Studio 2012 which.
Oct Multi-threaded Active Objects Ludovic Henrio, Fabrice Huet, Zsolt Istvàn June 2013 –
CHAPTER FOUR COMPUTER SOFTWARE.
Threaded Applications Introducing additional threads in a Delphi application is easy.
Subversion (SVN) Tutorial Source:
(1) A Beginner’s Quick Start to SIMICS. (2) Disclaimer This is a quick start document to help users get set up quickly Does not replace the user guide.
Drexel University Software Engineering Research Group Git for SE101 1.
Chapter 2 Parallel Architecture. Moore’s Law The number of transistors on a chip doubles every years. – Has been valid for over 40 years – Can’t.
CIDER - Today’s research, Tomorrow’s treatments Lab-3 September 22, 2010 Bijoy George, Program Manager, CBMI
© 2004 IBM Corporation IBM ^ z/VM Module 2: Conversational Monitor System (CMS)
(Sub)Version Control. 2 Keep large teams working on the same code Back up your work so you don't lose it all Compare changes to previous versions Revert.
SIMPLE PARALLEL PROGRAMMING WITH PATTERNS AND OMNITHREADLIBRARY PRIMOŽ GABRIJELČIČ SKYPE: GABR42
MATRIX MULTIPLY WITH DRYAD B649 Course Project Introduction.
]po[ - „Excellent Developers“ Frank Bergmann,
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Vector/Array ProcessorsCSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Vector/Array Processors Reading: Stallings, Section.
University of Washington What is parallel processing? Spring 2014 Wrap-up When can we execute things in parallel? Parallelism: Use extra resources to solve.
1. 2 Pipelining vs. Parallel processing  In both cases, multiple “things” processed by multiple “functional units” Pipelining: each thing is broken into.
WinCvs. WinCVS WinCvs is a window based version control system. Use WinCvs when  You want to save every version of your file you have ever created. CVS.
CS- 492 : Distributed system & Parallel Processing Lecture 7: Sun: 15/5/1435 Foundations of designing parallel algorithms and shared memory models Lecturer/
Simplify Parallel Programming with Patterns Primož Gabrijelčič R&D Manager, FAB.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Open project in Microsoft Visual Studio → build program in “Release” mode.
Abdul Rahim Ahmad MITM 613 Intelligent System Chapter 10: Tools.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
SMP Basics KeyStone Training Multicore Applications Literature Number: SPRPxxx 1.
Simple Equations Brackets Consider the simple equation 5(2x+3) = 3(x+9) Remove the brackets to obtain 10x + 15 = 3x + 27 Subtract 15 from both sides.
Maven. Introduction Using Maven (I) – Installing the Maven plugin for Eclipse – Creating a Maven Project – Building the Project Understanding the POM.
 Project Team: Suzana Vaserman David Fleish Moran Zafir Tzvika Stein  Academic adviser: Dr. Mayer Goldberg  Technical adviser: Mr. Guy Wiener.
CPIT Program Execution. Today, general-purpose computers use a set of instructions called a program to process data. A computer executes the.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Computer Architecture Organization and Architecture
The Complex Number System. 1. Write each expression as a pure imaginary number. (similar to p.537 #26)
Lecture 5. Example for periority The average waiting time : = 41/5= 8.2.
Introduction to threads
Faster parallel programs with improved FastMM
Chapter 4: Multithreaded Programming
Async or Parallel? No they aren’t the same thing!
Course Name: QTP Trainer: Laxmi Duration: 25 Hrs Session: Daily 1 Hr.
Chapter 4 Multithreading programming
Chapter 4: Threads.
Parallel Programming Done Right with OTL and PPL
Writing High Performance Delphi Application
Multithreaded Programming
Parallel Programming with ForkJoinPool Tasks in Java
Presentation transcript:

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 … providing well-tested components packed in reusable classes with high-level parallel programming support … parallel programming today! “Why multithreading?” is most probably not a question anymore “Why not TThread?” is harder to answer - maybe a good answer would be “Because not CreateWindow”

Delphi 2007 and above; currently Win32 only 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

Add the OtlParallel unit to the uses list That’s all folks! 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!

Future Win64 FMX OS/X iOS?

OmniThreadLibrary basics

Task vs. thread Task is part of code that has to be executed Thread is the execution environment You take care of the task, OTL takes care of the thread

Communication TOmniValue = variant T/IOmniBlockingCollection = threadsafe queue with read-blocking behaviour Message/data passing can solve most synchronisation problems (shared data access, deadlocking)

High-level multithreading

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

Why high-level approach? Designing parallel solutions is hard Writing multithreaded code is hard Testing multicore applications is hard Debugging multithreading code is pure insanity Debugging multithreading code is hard Cross out off of this stuff – high-level primitives help you exactly with that

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

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

Parallel.Async(code) Async Demo (probably HttpGet): async get and ignore result async with communication task.comm.send … async with invoke explain that this is better handled with Future

Future:=Parallel.Future<type>. (calculation); Query Future.Value; future httpget add termination handler show exception handling

Parallel.Join([task1, task2, task3, … taskN]).Execute Use Join to get three different pages with HttpGet explain exception handling

Parallel.ParallelTask.Execute (code) need a better demo

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

ParallelFor Demo simple parallel for; nowait variant; ordered variant; maybe even aggregates Demo enumeration over different sources

Pipeline example Pipeline example: Simple read-compress-encrypt-write process For each doesn’t help here, both in compression and encryption process (may) depend on previously processed data What does R-C-E-W process really do? It consists of four parts, each processing data. Usually we don’t process complete data in each part before continuing into next. We can rewrite this code to use queues instead of fixed buffers. Why? … … Because now we can split those four parts into four threads. Threads execute overlapped. Total execution time (providing multicore machine) if much shorter.

Parallel.Pipeline([stage1, stage2, stage3]). Run “encryption” demo should work fine demo throttling explain exception handling

Fork/Join Divide and conquer QuickSort demo

Multithreading is hard?

Why high-level approach? Designing parallel solutions is hard Writing multithreaded code is hard Testing multicore applications is hard Debugging multithreading code is pure insanity Debugging multithreading code is hard Cross out off of this stuff – high-level primitives help you exactly with that

Questions?