SlideShare a Scribd company logo
1 of 90
Download to read offline
GPars Workshop

                                     Russel Winder
                                   email: russel@winder.org.uk
                                  xmpp: russel@winder.org.uk
                                     twitter: @russel_winder

                                    http://www.russel.org.uk




Copyright © 2013 Russel Winder                                   1
Aims, Goals and Objectives
     ●   Gain practical experience of the various models of
         concurrent and parallel behaviour available in
         GPars; actors, dataflow, data parallelism, etc.
     ●   Have some fun.




Copyright © 2013 Russel Winder                                2
Subsidiary Aims, Goals and Objects
     ●   Show that shared mutable memory multi-threading
         should return to being an operating systems
         development technique and not continue to be
         pushed as an applications programming technique
         – remember…




Copyright © 2013 Russel Winder                             3
…people should tremble

                       in fear at the prospect of using

          Shared mutable memory
               multi-threading.

Copyright © 2013 Russel Winder                            4
Structure


                                  Introduction.
                                      Actors.
                                    Dataflow.
                                 Data Parallelism.
                                     Analysis.
                                     Closing.

Copyright © 2013 Russel Winder                       5
Protocol


                                 Short presentation.
                                                                   3
               (Short presentation → Practical period)
                                    Interaction.
                                 Short presentation.


                                  Questions or comments welcome at any time.

Copyright © 2013 Russel Winder                                                 6
Interstitial Advertisement




Copyright © 2013 Russel Winder                       7
Introduction




Copyright © 2013 Russel Winder                  8
It is no longer contentious that
                         The Multicore Revolution
                             is well underway.




Copyright © 2013 Russel Winder                          9
Quad core laptops and phones.

                    Eight and twelve core workstations.

                         Servers with “zillions” of cores.




Copyright © 2013 Russel Winder                               10
Parallel capable hardware is the norm.




Copyright © 2013 Russel Winder                      11
Software technology in use is now lagging
           hardware technology by decades.




Copyright © 2013 Russel Winder                     12
Operating systems manage cores
                            with kernel threads.

         Operating systems are fundamentally shared
          mutable memory multi-threaded systems.

            Operating systems rightly use all the lock,
             semaphore, monitor, etc. technologies.



Copyright © 2013 Russel Winder                            13
Computationally intensive systems or
             subsystems definitely have to be parallel.

                  Other systems likely use concurrency
                          but not parallelism.




Copyright © 2013 Russel Winder                            14
Concurrency


                                 Execution as co-routines:

            Sequences of code give up the execution
                to pass it to another coroutine.




Copyright © 2013 Russel Winder                               15
More Concurrency


            Concurrency is a technique founded in a
                uniprocessor view of the world.

                            Time-division multiplexing.




Copyright © 2013 Russel Winder                            16
Parallelism



                    Having multiple executions active
                           at the same time.




Copyright © 2013 Russel Winder                          17
Concurrency is a tool for structuring execution where a
      single processor is used by multiple computations.


      Parallelism is about making a computation complete
                faster than using a single processor.




Copyright © 2013 Russel Winder                                18
Copyright © 2013 Russel Winder   19
Copyright © 2013 Russel Winder   20
Copyright © 2013 Russel Winder   21
Copyright © 2013 Russel Winder   22
Copyright © 2013 Russel Winder   23
Copyright © 2013 Russel Winder   24
Copyright © 2013 Russel Winder   25
Squirrel behaviour emulates
                      synchronized software behaviour.




Copyright © 2013 Russel Winder                           26
Locks deny parallelism.




Copyright © 2013 Russel Winder                             27
The whole purpose of a lock is to
                             prevent parallelism.




Copyright © 2013 Russel Winder                             28
Parallelism is performance improvement.


    Performance improvement requires parallelism.




Copyright © 2013 Russel Winder                        29
Locks deny performance improvement.




Copyright © 2013 Russel Winder                       30
Locks are needed only if
                           there is mutable shared state.




Copyright © 2013 Russel Winder                              31
Avoid mutable shared state.




Copyright © 2013 Russel Winder                         32
…but how…




Copyright © 2013 Russel Winder               33
Use appropriate architectural models.




Copyright © 2013 Russel Winder                           34
It's all about controlling
                            concurrency and parallelism
                             with tools that applications
                             programmers find usable.




Copyright © 2013 Russel Winder                              35
Shared mutable memory multi-threading
                is an operating system technique.




Copyright © 2013 Russel Winder                       36
Applications and tools programmers
                    need computational models with
                       integrated synchronization.




Copyright © 2013 Russel Winder                          37
Use processes and message passing.




Copyright © 2013 Russel Winder                          38
It's all easier if processes
                                    are single threaded.




Copyright © 2013 Russel Winder                                  39
Dataflow
                                      Operators connected by
    Actors                            channels with activity
    Independent processes             triggered by arrival of
    communicating via                 data on the channels.
    asynchronous exchange
    of messages.



                                 Data Parallelism
                                 Transform a sequence to
                                 another sequence where all
                                 individual actions happen
                                 at the same time.
Copyright © 2013 Russel Winder                                  40
Agents
                                         A wrapper for some
    Active Objects                       shared mutable state.
    An object that is actually
    an actor but looks like a
    full service object.
                                 Fork/Join
                                 An toolkit for tree structured
                                 concurrency and parallelism.


        Software Transactional Memory
        Wrappers for mutable values that uses transactions
        rather than locks.
Copyright © 2013 Russel Winder                                    41
Actors




Copyright © 2013 Russel Winder            42
Actors
    Independent processes
    communicating via
    asynchronous exchange
    of messages




Copyright © 2013 Russel Winder   43
Need an example.




Copyright © 2013 Russel Winder                      44
The Sleeping Barber Problem




Copyright © 2013 Russel Winder             45
The Sleeping Barber Problem
     ●   The barber's shop has a          ●   If the barber is cutting, a new
         single cutting chair and a row       customer checks to see if
         of waiting seats.                    there is a free waiting seat.
     ●   The barber sleeps in the             ●   If there is join the queue
         cutting chair unless trimming            to be trimmed.
         a customer.                          ●   If there isn't leave
     ●   Customers arrive at the shop             disgruntled.
         at intervals.
     ●   If the barber is asleep, the
         customer wakes the barber                 Problem originally due
         takes the cutting chair and               to Edsgar Dijkstra.
         gets a trim.
Copyright © 2013 Russel Winder                                                  46
The cutting chair.

      The waiting chairs




                                          The barber's shop.

  A new customer enters the shop,
  check to see if they can go straight
  to the cutting chair, if not can they
  take a waiting chair, if not leave.

Copyright © 2013 Russel Winder                                      47
Wikipedia article presents the classic operating
      systems approach using locks and semaphores.

           http://en.wikipedia.org/wiki/Sleeping_barber_problem




Copyright © 2013 Russel Winder                                    48
Code!



Copyright © 2013 Russel Winder           49
Dataflow




Copyright © 2013 Russel Winder              50
Dataflow
                                 Operators connected by
                                 channels with activity
                                 triggered by arrival of
                                 data on the channels.




Copyright © 2013 Russel Winder                             51
Code!



Copyright © 2013 Russel Winder           52
If you want the code, clone the Git repository:

      http://www.russel.org.uk/Git/SleepingBarber.git




Copyright © 2013 Russel Winder                           53
Or if you just want to browse:

                        http://www.russel.org.uk/gitweb




Copyright © 2013 Russel Winder                              54
Data Parallelism




Copyright © 2013 Russel Winder                      55
Data Parallelism
                                 Transform a sequence to
                                 another sequence where all
                                 individual actions happen
                                 at the same time.
Copyright © 2013 Russel Winder                                56
Need an example.




Copyright © 2013 Russel Winder                      57

Copyright © 2013 Russel Winder       58
What is the Value of           ?

                                 Easy, it's known exactly.

                                          It's .

                                        Obviously.



Copyright © 2013 Russel Winder                                59
It's simples
                                          Александр Орлов   2009




Copyright © 2013 Russel Winder                                     60
Approximating 
     ●   What is it's value represented as a floating point
         number?
          ●    We can only obtain an approximation.
          ●    A plethora of possible algorithms to choose from, a
               popular one is to employ the following integral
               equation.


                                              1  1
                                             =∫0       dx
                                           4     1x 2




Copyright © 2013 Russel Winder                                       61
One Possible Algorithm
     ●   Use quadrature to estimate the value of the integral
         – which is the area under the curve.
                                   4 n          1
                                 = ∑i=1
                                   n           i−0.5 2
   Embarrassingly                          1      
   parallel.                                      n


                                                With n = 3 not much to do,
                                                but potentially lots of error.
                                                Use n = 107 or n = 109?



Copyright © 2013 Russel Winder                                                   62
Because addition is commutative and
                   associative, expression can be
               decomposed into sums of partial sums.




Copyright © 2013 Russel Winder                         63
a+b+c+d+e+f

                                      =

                         (a+b)+(c+d)+(e+f)




Copyright © 2013 Russel Winder                 64
Scatter – Gather




                                 map         reduce
Copyright © 2013 Russel Winder                        65
Code!



Copyright © 2013 Russel Winder           66
If you want the code, clone the Git repository:

      http://www.russel.org.uk/Git/Pi_Quadrature.git




Copyright © 2013 Russel Winder                           67
Or if you just want to browse:

                        http://www.russel.org.uk/gitweb




Copyright © 2013 Russel Winder                              68
An End




Copyright © 2013 Russel Winder            69
Multicore and multiprocessor are now
                the norm, not the exception.




Copyright © 2013 Russel Winder                     70
Parallelism only matters if
             computational performance matters.




Copyright © 2013 Russel Winder                    71
Unstructured synchronization
                           of concurrent systems
                        is not a feasible approach.




Copyright © 2013 Russel Winder                        72
Actors, dataflow, and data parallelism
               (and CSP, agents, fork/join,…)
          are the future of applications structure.




Copyright © 2013 Russel Winder                        73
Passing messages between
                        processes is the way forward.




Copyright © 2013 Russel Winder                          74
Shared memory concurrency
                      is a dead end for applications.




Copyright © 2013 Russel Winder                          75
Copyright © 2013 Russel Winder   76
Copyright © 2013 Russel Winder   77
Copyright © 2013 Russel Winder   78
Copyright © 2013 Russel Winder   79
Copyright © 2013 Russel Winder   80
Copyright © 2013 Russel Winder   81
Squirrels deny parallelism.




Copyright © 2013 Russel Winder                           82
Squirrels deny performance enhancement.




Copyright © 2013 Russel Winder                 83
Don't be a squirrel.




Copyright © 2013 Russel Winder                          84
Do not use explicit locking algorithms.




Copyright © 2013 Russel Winder                            85
Use computational architectures that promote
            parallelism and hence performance
                       improvement:

                                      Actors
                                    Dataflow
                                 Data Parallelism




Copyright © 2013 Russel Winder                        86
Use



                                  Go on, you know you want to…
Copyright © 2013 Russel Winder                                   87
Interstitial Advertisement




Copyright © 2013 Russel Winder                       88
The End




Copyright © 2013 Russel Winder             89
GPars Workshop

                                      Russel Winder
                                   email: russel@winder.org.uk
                                  xmpp: russel@winder.org.uk
                                     twitter: @russel_winder
                                 website: http://www.russel.org.uk




Copyright © 2013 Russel Winder                                       90

More Related Content

Similar to GPars Workshop

ACCU 2012: Go, D, C++ and The Multicore Revolution
ACCU 2012:  Go, D, C++ and The Multicore RevolutionACCU 2012:  Go, D, C++ and The Multicore Revolution
ACCU 2012: Go, D, C++ and The Multicore RevolutionRussel Winder
 
On Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseOn Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseRussel Winder
 
Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Russel Winder
 
Switch to Python 3…now…immediately
Switch to Python 3…now…immediatelySwitch to Python 3…now…immediately
Switch to Python 3…now…immediatelyRussel Winder
 
GPars: Parallelism the Right Way
GPars: Parallelism the Right WayGPars: Parallelism the Right Way
GPars: Parallelism the Right WayRussel Winder
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needRussel Winder
 
Java 8: a New Beginning
Java 8: a New BeginningJava 8: a New Beginning
Java 8: a New BeginningRussel Winder
 
Gant, the lightweight and Groovy targeted scripting framework
Gant, the lightweight and Groovy targeted scripting frameworkGant, the lightweight and Groovy targeted scripting framework
Gant, the lightweight and Groovy targeted scripting frameworkSkills Matter
 
CAP and the Architectural Consequences by martin Schönert
CAP and the Architectural Consequences by martin SchönertCAP and the Architectural Consequences by martin Schönert
CAP and the Architectural Consequences by martin SchönertArangoDB Database
 
Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...
Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...
Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...Jarrett Neil Ridlinghafer
 
Dataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderDataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel Winderploibl
 
Dataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderDataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderJAXLondon2014
 
SOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARE
SOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARESOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARE
SOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARESimware
 
Cloud expo 10 myths rex wang oracle ss
Cloud expo 10 myths rex wang oracle ssCloud expo 10 myths rex wang oracle ss
Cloud expo 10 myths rex wang oracle ssRex Wang
 

Similar to GPars Workshop (20)

ACCU 2012: Go, D, C++ and The Multicore Revolution
ACCU 2012:  Go, D, C++ and The Multicore RevolutionACCU 2012:  Go, D, C++ and The Multicore Revolution
ACCU 2012: Go, D, C++ and The Multicore Revolution
 
On Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseOn Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverse
 
Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.
 
Switch to Python 3…now…immediately
Switch to Python 3…now…immediatelySwitch to Python 3…now…immediately
Switch to Python 3…now…immediately
 
GPars: Parallelism the Right Way
GPars: Parallelism the Right WayGPars: Parallelism the Right Way
GPars: Parallelism the Right Way
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you need
 
GPars 2014
GPars 2014GPars 2014
GPars 2014
 
Java 8: a New Beginning
Java 8: a New BeginningJava 8: a New Beginning
Java 8: a New Beginning
 
Gant, the lightweight and Groovy targeted scripting framework
Gant, the lightweight and Groovy targeted scripting frameworkGant, the lightweight and Groovy targeted scripting framework
Gant, the lightweight and Groovy targeted scripting framework
 
CAP and the Architectural Consequences by martin Schönert
CAP and the Architectural Consequences by martin SchönertCAP and the Architectural Consequences by martin Schönert
CAP and the Architectural Consequences by martin Schönert
 
Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...
Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...
Security & Compliance in the Cloud - Hadoop Magazine Column Version 1.2 by Ja...
 
Federated Learning
Federated LearningFederated Learning
Federated Learning
 
Scaling Small App
Scaling Small AppScaling Small App
Scaling Small App
 
Omg dds berlin 2013
Omg dds berlin 2013Omg dds berlin 2013
Omg dds berlin 2013
 
GPars Remoting
GPars RemotingGPars Remoting
GPars Remoting
 
Dataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderDataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel Winder
 
Dataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel WinderDataflow, the Forgotten Way - Russel Winder
Dataflow, the Forgotten Way - Russel Winder
 
SOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARE
SOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARESOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARE
SOLVING LVC INTEROPERABILITY PROBLEMS WITH SIMWARE
 
Cloud expo 10 myths rex wang oracle ss
Cloud expo 10 myths rex wang oracle ssCloud expo 10 myths rex wang oracle ss
Cloud expo 10 myths rex wang oracle ss
 
DDS Made Simple
DDS Made SimpleDDS Made Simple
DDS Made Simple
 

More from Russel Winder

The Case for Kotlin and Ceylon
The Case for Kotlin and CeylonThe Case for Kotlin and Ceylon
The Case for Kotlin and CeylonRussel Winder
 
On the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layerOn the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layerRussel Winder
 
Fast Python? Don't Bother
Fast Python? Don't BotherFast Python? Don't Bother
Fast Python? Don't BotherRussel Winder
 
Making Python computations fast
Making Python computations fastMaking Python computations fast
Making Python computations fastRussel Winder
 
Tales from the Workshops
Tales from the WorkshopsTales from the Workshops
Tales from the WorkshopsRussel Winder
 
Making Computations Execute Very Quickly
Making Computations Execute Very QuicklyMaking Computations Execute Very Quickly
Making Computations Execute Very QuicklyRussel Winder
 
Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etcRussel Winder
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Russel Winder
 
Spocktacular testing
Spocktacular testingSpocktacular testing
Spocktacular testingRussel Winder
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular TestingRussel Winder
 
Is Groovy static or dynamic
Is Groovy static or dynamicIs Groovy static or dynamic
Is Groovy static or dynamicRussel Winder
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Russel Winder
 
Are Go and D threats to Python
Are Go and D threats to PythonAre Go and D threats to Python
Are Go and D threats to PythonRussel Winder
 
Is Groovy as fast as Java
Is Groovy as fast as JavaIs Groovy as fast as Java
Is Groovy as fast as JavaRussel Winder
 
Who needs C++ when you have D and Go
Who needs C++ when you have D and GoWho needs C++ when you have D and Go
Who needs C++ when you have D and GoRussel Winder
 
GPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for JavaGPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for JavaRussel Winder
 
GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily Russel Winder
 
Given Groovy Who Needs Java
Given Groovy Who Needs JavaGiven Groovy Who Needs Java
Given Groovy Who Needs JavaRussel Winder
 
Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Russel Winder
 
Closures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaClosures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaRussel Winder
 

More from Russel Winder (20)

The Case for Kotlin and Ceylon
The Case for Kotlin and CeylonThe Case for Kotlin and Ceylon
The Case for Kotlin and Ceylon
 
On the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layerOn the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layer
 
Fast Python? Don't Bother
Fast Python? Don't BotherFast Python? Don't Bother
Fast Python? Don't Bother
 
Making Python computations fast
Making Python computations fastMaking Python computations fast
Making Python computations fast
 
Tales from the Workshops
Tales from the WorkshopsTales from the Workshops
Tales from the Workshops
 
Making Computations Execute Very Quickly
Making Computations Execute Very QuicklyMaking Computations Execute Very Quickly
Making Computations Execute Very Quickly
 
Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etc
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.
 
Spocktacular testing
Spocktacular testingSpocktacular testing
Spocktacular testing
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular Testing
 
Is Groovy static or dynamic
Is Groovy static or dynamicIs Groovy static or dynamic
Is Groovy static or dynamic
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.
 
Are Go and D threats to Python
Are Go and D threats to PythonAre Go and D threats to Python
Are Go and D threats to Python
 
Is Groovy as fast as Java
Is Groovy as fast as JavaIs Groovy as fast as Java
Is Groovy as fast as Java
 
Who needs C++ when you have D and Go
Who needs C++ when you have D and GoWho needs C++ when you have D and Go
Who needs C++ when you have D and Go
 
GPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for JavaGPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for Java
 
GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily
 
Given Groovy Who Needs Java
Given Groovy Who Needs JavaGiven Groovy Who Needs Java
Given Groovy Who Needs Java
 
Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…
 
Closures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaClosures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In Java
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

GPars Workshop

  • 1. GPars Workshop Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winder http://www.russel.org.uk Copyright © 2013 Russel Winder 1
  • 2. Aims, Goals and Objectives ● Gain practical experience of the various models of concurrent and parallel behaviour available in GPars; actors, dataflow, data parallelism, etc. ● Have some fun. Copyright © 2013 Russel Winder 2
  • 3. Subsidiary Aims, Goals and Objects ● Show that shared mutable memory multi-threading should return to being an operating systems development technique and not continue to be pushed as an applications programming technique – remember… Copyright © 2013 Russel Winder 3
  • 4. …people should tremble in fear at the prospect of using Shared mutable memory multi-threading. Copyright © 2013 Russel Winder 4
  • 5. Structure Introduction. Actors. Dataflow. Data Parallelism. Analysis. Closing. Copyright © 2013 Russel Winder 5
  • 6. Protocol Short presentation. 3 (Short presentation → Practical period) Interaction. Short presentation. Questions or comments welcome at any time. Copyright © 2013 Russel Winder 6
  • 9. It is no longer contentious that The Multicore Revolution is well underway. Copyright © 2013 Russel Winder 9
  • 10. Quad core laptops and phones. Eight and twelve core workstations. Servers with “zillions” of cores. Copyright © 2013 Russel Winder 10
  • 11. Parallel capable hardware is the norm. Copyright © 2013 Russel Winder 11
  • 12. Software technology in use is now lagging hardware technology by decades. Copyright © 2013 Russel Winder 12
  • 13. Operating systems manage cores with kernel threads. Operating systems are fundamentally shared mutable memory multi-threaded systems. Operating systems rightly use all the lock, semaphore, monitor, etc. technologies. Copyright © 2013 Russel Winder 13
  • 14. Computationally intensive systems or subsystems definitely have to be parallel. Other systems likely use concurrency but not parallelism. Copyright © 2013 Russel Winder 14
  • 15. Concurrency Execution as co-routines: Sequences of code give up the execution to pass it to another coroutine. Copyright © 2013 Russel Winder 15
  • 16. More Concurrency Concurrency is a technique founded in a uniprocessor view of the world. Time-division multiplexing. Copyright © 2013 Russel Winder 16
  • 17. Parallelism Having multiple executions active at the same time. Copyright © 2013 Russel Winder 17
  • 18. Concurrency is a tool for structuring execution where a single processor is used by multiple computations. Parallelism is about making a computation complete faster than using a single processor. Copyright © 2013 Russel Winder 18
  • 19. Copyright © 2013 Russel Winder 19
  • 20. Copyright © 2013 Russel Winder 20
  • 21. Copyright © 2013 Russel Winder 21
  • 22. Copyright © 2013 Russel Winder 22
  • 23. Copyright © 2013 Russel Winder 23
  • 24. Copyright © 2013 Russel Winder 24
  • 25. Copyright © 2013 Russel Winder 25
  • 26. Squirrel behaviour emulates synchronized software behaviour. Copyright © 2013 Russel Winder 26
  • 27. Locks deny parallelism. Copyright © 2013 Russel Winder 27
  • 28. The whole purpose of a lock is to prevent parallelism. Copyright © 2013 Russel Winder 28
  • 29. Parallelism is performance improvement. Performance improvement requires parallelism. Copyright © 2013 Russel Winder 29
  • 30. Locks deny performance improvement. Copyright © 2013 Russel Winder 30
  • 31. Locks are needed only if there is mutable shared state. Copyright © 2013 Russel Winder 31
  • 32. Avoid mutable shared state. Copyright © 2013 Russel Winder 32
  • 33. …but how… Copyright © 2013 Russel Winder 33
  • 34. Use appropriate architectural models. Copyright © 2013 Russel Winder 34
  • 35. It's all about controlling concurrency and parallelism with tools that applications programmers find usable. Copyright © 2013 Russel Winder 35
  • 36. Shared mutable memory multi-threading is an operating system technique. Copyright © 2013 Russel Winder 36
  • 37. Applications and tools programmers need computational models with integrated synchronization. Copyright © 2013 Russel Winder 37
  • 38. Use processes and message passing. Copyright © 2013 Russel Winder 38
  • 39. It's all easier if processes are single threaded. Copyright © 2013 Russel Winder 39
  • 40. Dataflow Operators connected by Actors channels with activity Independent processes triggered by arrival of communicating via data on the channels. asynchronous exchange of messages. Data Parallelism Transform a sequence to another sequence where all individual actions happen at the same time. Copyright © 2013 Russel Winder 40
  • 41. Agents A wrapper for some Active Objects shared mutable state. An object that is actually an actor but looks like a full service object. Fork/Join An toolkit for tree structured concurrency and parallelism. Software Transactional Memory Wrappers for mutable values that uses transactions rather than locks. Copyright © 2013 Russel Winder 41
  • 42. Actors Copyright © 2013 Russel Winder 42
  • 43. Actors Independent processes communicating via asynchronous exchange of messages Copyright © 2013 Russel Winder 43
  • 44. Need an example. Copyright © 2013 Russel Winder 44
  • 45. The Sleeping Barber Problem Copyright © 2013 Russel Winder 45
  • 46. The Sleeping Barber Problem ● The barber's shop has a ● If the barber is cutting, a new single cutting chair and a row customer checks to see if of waiting seats. there is a free waiting seat. ● The barber sleeps in the ● If there is join the queue cutting chair unless trimming to be trimmed. a customer. ● If there isn't leave ● Customers arrive at the shop disgruntled. at intervals. ● If the barber is asleep, the customer wakes the barber Problem originally due takes the cutting chair and to Edsgar Dijkstra. gets a trim. Copyright © 2013 Russel Winder 46
  • 47. The cutting chair. The waiting chairs The barber's shop. A new customer enters the shop, check to see if they can go straight to the cutting chair, if not can they take a waiting chair, if not leave. Copyright © 2013 Russel Winder 47
  • 48. Wikipedia article presents the classic operating systems approach using locks and semaphores. http://en.wikipedia.org/wiki/Sleeping_barber_problem Copyright © 2013 Russel Winder 48
  • 49. Code! Copyright © 2013 Russel Winder 49
  • 50. Dataflow Copyright © 2013 Russel Winder 50
  • 51. Dataflow Operators connected by channels with activity triggered by arrival of data on the channels. Copyright © 2013 Russel Winder 51
  • 52. Code! Copyright © 2013 Russel Winder 52
  • 53. If you want the code, clone the Git repository: http://www.russel.org.uk/Git/SleepingBarber.git Copyright © 2013 Russel Winder 53
  • 54. Or if you just want to browse: http://www.russel.org.uk/gitweb Copyright © 2013 Russel Winder 54
  • 55. Data Parallelism Copyright © 2013 Russel Winder 55
  • 56. Data Parallelism Transform a sequence to another sequence where all individual actions happen at the same time. Copyright © 2013 Russel Winder 56
  • 57. Need an example. Copyright © 2013 Russel Winder 57
  • 58.  Copyright © 2013 Russel Winder 58
  • 59. What is the Value of ? Easy, it's known exactly. It's . Obviously. Copyright © 2013 Russel Winder 59
  • 60. It's simples Александр Орлов 2009 Copyright © 2013 Russel Winder 60
  • 61. Approximating  ● What is it's value represented as a floating point number? ● We can only obtain an approximation. ● A plethora of possible algorithms to choose from, a popular one is to employ the following integral equation.  1 1 =∫0 dx 4 1x 2 Copyright © 2013 Russel Winder 61
  • 62. One Possible Algorithm ● Use quadrature to estimate the value of the integral – which is the area under the curve. 4 n 1 = ∑i=1 n i−0.5 2 Embarrassingly 1  parallel. n With n = 3 not much to do, but potentially lots of error. Use n = 107 or n = 109? Copyright © 2013 Russel Winder 62
  • 63. Because addition is commutative and associative, expression can be decomposed into sums of partial sums. Copyright © 2013 Russel Winder 63
  • 64. a+b+c+d+e+f = (a+b)+(c+d)+(e+f) Copyright © 2013 Russel Winder 64
  • 65. Scatter – Gather map reduce Copyright © 2013 Russel Winder 65
  • 66. Code! Copyright © 2013 Russel Winder 66
  • 67. If you want the code, clone the Git repository: http://www.russel.org.uk/Git/Pi_Quadrature.git Copyright © 2013 Russel Winder 67
  • 68. Or if you just want to browse: http://www.russel.org.uk/gitweb Copyright © 2013 Russel Winder 68
  • 69. An End Copyright © 2013 Russel Winder 69
  • 70. Multicore and multiprocessor are now the norm, not the exception. Copyright © 2013 Russel Winder 70
  • 71. Parallelism only matters if computational performance matters. Copyright © 2013 Russel Winder 71
  • 72. Unstructured synchronization of concurrent systems is not a feasible approach. Copyright © 2013 Russel Winder 72
  • 73. Actors, dataflow, and data parallelism (and CSP, agents, fork/join,…) are the future of applications structure. Copyright © 2013 Russel Winder 73
  • 74. Passing messages between processes is the way forward. Copyright © 2013 Russel Winder 74
  • 75. Shared memory concurrency is a dead end for applications. Copyright © 2013 Russel Winder 75
  • 76. Copyright © 2013 Russel Winder 76
  • 77. Copyright © 2013 Russel Winder 77
  • 78. Copyright © 2013 Russel Winder 78
  • 79. Copyright © 2013 Russel Winder 79
  • 80. Copyright © 2013 Russel Winder 80
  • 81. Copyright © 2013 Russel Winder 81
  • 82. Squirrels deny parallelism. Copyright © 2013 Russel Winder 82
  • 83. Squirrels deny performance enhancement. Copyright © 2013 Russel Winder 83
  • 84. Don't be a squirrel. Copyright © 2013 Russel Winder 84
  • 85. Do not use explicit locking algorithms. Copyright © 2013 Russel Winder 85
  • 86. Use computational architectures that promote parallelism and hence performance improvement: Actors Dataflow Data Parallelism Copyright © 2013 Russel Winder 86
  • 87. Use Go on, you know you want to… Copyright © 2013 Russel Winder 87
  • 89. The End Copyright © 2013 Russel Winder 89
  • 90. GPars Workshop Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winder website: http://www.russel.org.uk Copyright © 2013 Russel Winder 90