SlideShare a Scribd company logo
CnC-Scala:
A Declarative Approach to
  Multicore Parallelism

       Scala Days
        April 17, 2012

 Shams Imam and Vivek Sarkar
        Rice University


                               1
Acknowledgments
•  Habanero Group
    –  Sagnak Tasirlar
    –  Dragos Sbirlea
    –  Alina Sbirlea

•    “Concurrent Collections” Zoran Budimlic, Michael Burke,
     Vincent Cave, Kathleen Knobe, Geoff Lowney, Ryan
     Newton, Jens Palsberg, David Peixotto, Vivek Sarkar,
     Frank Schlimbach, Sagnak Tasirlar. Scientific
     Programming.
•    “Concurrent Collections: Easy and effective
     distributed computing” Frank Schlimbach, Kath Knobe,
     James Brodman.
                                                            2
Inverted Pyramid of Parallel
      Programming Skills



Parallelism oblivious       Focus of this talk

    developers
                                  Focus of Rice
                                 Habanero Project


       Parallelism
         aware                Habanero-Scala,
          devs             presented earlier today

                            Java threads, locks, etc.
         Concurrency
           Experts
                                                        3
                       http://habanero.rice.edu
The Issue


Parallel programs are notoriously difficult for
 mortals to write, debug, maintain and port.




                                             4
The Big Idea


•  Don’t specify what operations run in parallel
   •  Difficult and depends on target

•  Specify the semantic ordering constraints only
   •  Easier and depends only on application




                                                    5
Exactly Two Sources of Ordering
                 Requirements

•  Producer must execute before consumer

•  Controller must execute before controllee




                                               6
Outline

•  The Concurrent Collections (CnC) Model
     •  Features
     •  Constructs
•  CnC Scala – Example
•  Implementation
•  Results




                                            7
The CnC model

•  Programmer defines semantic dependences
  •    Ordering constraints between computational units
  •    Code in computation unit is standard serial code


•  Runtime takes care of
  •    Executing the computational units
  •    Extracting parallelism in the application




                                                          8
CnC Constructs - Steps


                           (step)	



•  Computational unit of a CnC program
  •    Stateless
  •    Side-effect free
  •    Functional with respect to inputs



                                           9
CnC Constructs – Data Items



       [in_item]
               	               (step)	                  [out_item]
                                                                 	




•  Data units are called Item Collection
  •     Means of communication between steps
  •     Mapping of data tags to items
       •    Items can only be retrieved by their tags
  •     Dynamic single assignment


                                                                     10
CnC Constructs - Control

             <tag>
                 	



       [in_item]
               	          (step)	             [out_item]
                                                       	



•  Tag Collections are control units
  •    Used to execute (prescribe) steps
  •    A CnC step will not launch until its tag has been put




                                                           11
CnC Constructs - Environment
      env
              <tag>
                  	
                                                         env
env
        [in_item]
                	       (step)	        [out_item]
                                                	



      •  A driver which encapsulates the CnC Graph
      •  Provides inputs to and consumes outputs
         from the CnC Graph



                                                    12
Exactly Two Sources of Ordering
                     Requirements

•  Producer must execute before consumer

•  Controller must execute before controllee


     Producer - Consumer          Controller - Controllee

                                           <tag1>	



  (prod)	      [C1]
                  	   (cons)
                           	      (C-er)
                                       	             (C-ee)
                                                          	




                                                              13
Outline

•  The CnC Model
•  CnC-Scala
     •  Build Model
     •  Capitalize-Words Example
     •  Step Code
•  Implementation
•  Results




                                   14
CnC-Scala

•  Written in pure Scala
   •  uses continuations compiler plugin
•  Only dependency – jsr-166y.jar
   •  comes bundled with java 7
•  Distribution with examples available at:
   •  http://cnc-scala.rice.edu/




                                              15
CnC-Scala Build Model

           CnC Graph Spec
              cnc_scala_translate
                                                    - Step code
                                                    - main() method
        Generated Stub code
                                cnc_scala_compile


                            Compiled bytecode

                                    cnc_scala_run
  User Code
                                     Output
Generated Code                                                        16
Capitalize-Words example




1.     import edu.rice.cnc.translator.GraphDescription._	
2.     object SplitCapitalizeCncDefinition extends App {	
3.         // Item Collections	
4.         ItemCollection[String, String]("input")	
5.         ItemCollection[String, String]("words")	
6.         ItemCollection[String, String]("result")	
7.         // Tag Collections	
8.         TagCollection[String]("data")	
9.         TagCollection[String]("token")	
10.        // Step Prescriptions	
11.        Presription("data", List("split"))	
12.        Presription("token", List("capitalize"))	
13.        // Step Dependences	
14.        StepDependence("split", List ("input"), List("token", "words"))	
15.        StepDependence("capitalize", List("words"), List("result"))	
16.        // Environment Collections	
17.        EnvironmentDependence(List("input", "data"), List("result"))	
18.    }	
                                                                              17
Generated Code Example




1.     trait SplitStep extends Step {	
2.        	
3.        // Optional to provide an implementation	
4.        def createDependences(	
5.          tag: java.lang.String, 	
6.          inInput: InputCollection[java.lang.String, java.lang.String],	
7.          dependenceManager: DependenceManager	
8.        ): Unit = {}	
9.        	
10.       // User must provide an implementation for this method	
11.       def compute(	
12.         tag: java.lang.String, 	
13.         inInput: InputCollection[java.lang.String, java.lang.String], 	
14.         outToken: TagCollection[java.lang.String], 	
15.         outWords: OutputCollection[java.lang.String, java.lang.String]	
16.       ): Unit@cpsParam[Any, Any]	
17.    }	

                                                                              18
User Step Code




1.     class UserSplitStep extends SplitStep {	
2.       	
3.       // User must provide an implementation for this method	
4.       def compute(	
5.         tag: java.lang.String, 	
6.         inInput: InputCollection[java.lang.String, java.lang.String], 	
7.         outToken: TagCollection[java.lang.String], 	
8.         outWords: OutputCollection[java.lang.String, java.lang.String]	
9.       ): Unit@cpsParam[Any, Any] = {	

10.        val inString = inInput.get(tag)	
11.        for ((token, index) <- inString.split(" +").view.zipWithIndex) {	
12.           val newTag = tag + ":" + index	
13.           outWords.put(newTag, token)	
14.           outToken.put(newTag)	
15.    } } }	
                                                                               19
User Main




1.     object SplitCapitalizeMain extends CncScalaApp {	

2.          // Instantiate Steps	
3.          val splitStep = new UserSplitStep()	
4.          val capitalizeStep = new UserCapitalizeStep()	
5.          val graph = new SplitCapitalizeGraph(splitStep, capitalizeStep)	
6.          	
7.          graph.run(new Runnable() {	
8.            def run(): Unit = {	
9.               // populate data from environment to collections	
10.              val tag = "1"	
11.              graph.input.put(tag, "hello world")	
12.              graph.data.put(tag)	
13.           }	
14.         })	
15.         // read results	
16.         graph.result.dump(System.out)	
17.    }	
                                                                               20
Outline

•  The CnC Model
•  CnC-Scala
•  Implementation
     •  Data-driven futures
     •  Continuations
•  Results




                                21
Implementation

•  Tag Collections
   •  Spawn new tasks run step code
•  Item Collections
   •  Use concurrent maps with user defined tag types as keys
      and data-driven futures (DDF) as values
   •  What to do when get() has unavailable items?
      •  Create continuations
   •  When value becomes available…
      •  DDFs resume continuations



                                                         22
Data-driven futures

•  Separation of classical “futures” into data and
   control parts
•  Consumers can eagerly register on the DDF even
   before we know about the producer
  •  i.e., lazily attaches a producer to an item
•  When item is produced, all previously registered
   consumers are notified
    •  Subsequent consumers always get the value
       immediately

                                                      23
Continuations

•  Represents rest of the computation from a given
   point in the program
•  Allows
    •  suspending current execution state
    •  resume from that point later
•  We need only delimited one-shot continuations
   •  Scala has shift-reset!



                                                     24
Benefits of using continuations

•  No re-execution of code
•  Allow arbitrary (data-dependent) gets
•  Threads never block
    •  No extra threads created




                                           25
Scala Continuation example
	
1.  object Main {	
2.    def main(args: Array[String]) {	
3.               println("A. Main starts")	
4.               var continuation: (Unit) => Any = null	
                                                           Output:	
5.               reset { // delimit boundary start	
6.                 println("B. Entered reset")	            	
7.                 shift[Unit, Any, Unit] {	               A.   Main starts	
8.                   delimCont =>	                         B.   Entered reset	
9.                       println("C. Entered shift")	      C.   Entered shift	
10.                      continuation = delimCont	         D.   Inside shift	
                                                           F.   Outside reset	
11.                      println("D. Inside shift")	
                                                           G.   Calling cont.	
12.                } 	
                                                           E. After shift	
13.                println("E. After shift")	
                                                           H. Main ends	
14.              } // delimit boundary end	
15.              println("F. Outside reset")	
16.              println("G. Calling cont.")	
17.              continuation()	
18.              println("H. Main ends")	
19.         }	
20.    }	                                                                        26
CnC-Scala Runtime - step

•  Tag Collection step prescription
    •  Wrap each step.compute() in a reset

  // some preparation

  reset {

     step.compute(tag, inputs, outputs)

  }

  // book-keeping logic based on 

  // whether continuation was stored

  // or execution completed normally


                                             27
CnC-Scala Runtime - get

•  If item is available return it
•  Else store continuation

  get(tag: TagType): ItemType = {

     if (itemAvailable)

       return item

     else

       shift { continuation =>

           // store continuation

       }

       // when cont resumes, item is available

       return item

  }	
                                                  28
CnC-Scala Runtime - put

•  Store item
•  Resume waiting continuations

  put(tag: TagType, item: ItemType) {

     // store item into DDF

     // resume ALL waiting continuations

  }	




                                            29
Outline
•    The CnC Model
•    CnC-Scala
•    Implementation
•    Results




                                30
CnC-Scala Results

•  12-core (two hex-cores) 2.8 GHz Intel Westmere
   SMP
•  48 GB memory, running Red Hat Linux (RHEL 6.0)
•  Hotspot JDK 1.7
•  Scala version 2.9.1-1
•  CnC-Scala 0.1.2
•  Arithmetic mean of last thirty iterations from
   hundred iterations on ten separate JVM invocations


                                                  31
Successive Over-Relaxation




•  1 Item Collection, 1 Tag Collection, and 1 Step.
                                                      32
NQueens




•  3 Item Collections, 1 Tag Collection, and 1 Step.
                                                       33
LU Decomposition




•  3 Item Collections, 5 Tag Collections, and 8 Steps.
                                                         34
CnC Features

•    Coordination language
•    Dynamic light-weight task based
•    Single assignment
•    Deterministic
•    Race free




                                       35
Summary

•  CnC exposes more potential parallelism
•  Development is productive
   •  User declaratively defines dependences and
      writes only serial code
   •  runtime hides all the difficulties with using low-
      level techniques
   •  result is deterministic and independent of number
      of threads


                                                    36
Thank you!




[image source: http://www.jerryzeinfeld.com/tag/question-of-the-day/]   37
Ad

More Related Content

What's hot (20)

2 P Seminar
2 P Seminar2 P Seminar
2 P Seminar
Linkiby Belarus
 
Metamodeling of custom Pharo images
 Metamodeling of custom Pharo images Metamodeling of custom Pharo images
Metamodeling of custom Pharo images
ESUG
 
JDK1.6
JDK1.6JDK1.6
JDK1.6
india_mani
 
iOS overview
iOS overviewiOS overview
iOS overview
gupta25
 
Groovy, Transforming Language
Groovy, Transforming LanguageGroovy, Transforming Language
Groovy, Transforming Language
Uehara Junji
 
Clojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVMClojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVM
elliando dias
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
DevelopIntelligence
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
Renzo Borgatti
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
Matthew Gaudet
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
Doug Hawkins
 
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
Vladimir Ivanov
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述
fangjiafu
 
Java Course 13: JDBC & Logging
Java Course 13: JDBC & LoggingJava Course 13: JDBC & Logging
Java Course 13: JDBC & Logging
Anton Keks
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
Vskills
 
Running Pharo on the GemStone VM
Running Pharo on the GemStone VMRunning Pharo on the GemStone VM
Running Pharo on the GemStone VM
ESUG
 
JShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java Platform
JavaDayUA
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
JavaDayUA
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
Anton Keks
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
Stephen Colebourne
 
Metamodeling of custom Pharo images
 Metamodeling of custom Pharo images Metamodeling of custom Pharo images
Metamodeling of custom Pharo images
ESUG
 
iOS overview
iOS overviewiOS overview
iOS overview
gupta25
 
Groovy, Transforming Language
Groovy, Transforming LanguageGroovy, Transforming Language
Groovy, Transforming Language
Uehara Junji
 
Clojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVMClojure A Dynamic Programming Language for the JVM
Clojure A Dynamic Programming Language for the JVM
elliando dias
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
DevelopIntelligence
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
Renzo Borgatti
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
Matthew Gaudet
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
Doug Hawkins
 
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
Vladimir Ivanov
 
Web注入+http漏洞等描述
Web注入+http漏洞等描述Web注入+http漏洞等描述
Web注入+http漏洞等描述
fangjiafu
 
Java Course 13: JDBC & Logging
Java Course 13: JDBC & LoggingJava Course 13: JDBC & Logging
Java Course 13: JDBC & Logging
Anton Keks
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
Vskills
 
Running Pharo on the GemStone VM
Running Pharo on the GemStone VMRunning Pharo on the GemStone VM
Running Pharo on the GemStone VM
ESUG
 
JShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java Platform
JavaDayUA
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
JavaDayUA
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
Anton Keks
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
Stephen Colebourne
 

Viewers also liked (12)

Scala days mizushima
Scala days mizushimaScala days mizushima
Scala days mizushima
Skills Matter Talks
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
Skills Matter Talks
 
Project kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaProject kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scala
Skills Matter Talks
 
Prediction suretogowrong
Prediction suretogowrongPrediction suretogowrong
Prediction suretogowrong
Skills Matter Talks
 
Man made marvels
Man made marvelsMan made marvels
Man made marvels
Sanjeev Raju
 
Nps
NpsNps
Nps
Ahmed Elewa
 
Arvindsujeeth scaladays12
Arvindsujeeth scaladays12Arvindsujeeth scaladays12
Arvindsujeeth scaladays12
Skills Matter Talks
 
Proposal parade seni
Proposal parade seniProposal parade seni
Proposal parade seni
khrisna lukmansyah
 
Frase dan klausa
Frase dan klausaFrase dan klausa
Frase dan klausa
khrisna lukmansyah
 
Zaharia spark-scala-days-2012
Zaharia spark-scala-days-2012Zaharia spark-scala-days-2012
Zaharia spark-scala-days-2012
Skills Matter Talks
 
Review of "The anatomy of a large scale hyper textual web search engine"
Review of  "The anatomy of a large scale hyper textual web search engine" Review of  "The anatomy of a large scale hyper textual web search engine"
Review of "The anatomy of a large scale hyper textual web search engine"
Sai Malleswar
 
EDS selection & implementation @ CCC
EDS selection & implementation @ CCCEDS selection & implementation @ CCC
EDS selection & implementation @ CCC
Molly Beestrum
 
Project kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaProject kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scala
Skills Matter Talks
 
Review of "The anatomy of a large scale hyper textual web search engine"
Review of  "The anatomy of a large scale hyper textual web search engine" Review of  "The anatomy of a large scale hyper textual web search engine"
Review of "The anatomy of a large scale hyper textual web search engine"
Sai Malleswar
 
EDS selection & implementation @ CCC
EDS selection & implementation @ CCCEDS selection & implementation @ CCC
EDS selection & implementation @ CCC
Molly Beestrum
 
Ad

Similar to Cnc scala-presentation (20)

Jazoon12 355 aleksandra_gavrilovska-1
Jazoon12 355 aleksandra_gavrilovska-1Jazoon12 355 aleksandra_gavrilovska-1
Jazoon12 355 aleksandra_gavrilovska-1
Netcetera
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
Uday Sharma
 
Continuos integration for iOS projects
Continuos integration for iOS projectsContinuos integration for iOS projects
Continuos integration for iOS projects
Aleksandra Gavrilovska
 
Постоянное тестирование интеграции
Постоянное тестирование интеграцииПостоянное тестирование интеграции
Постоянное тестирование интеграции
SQALab
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
catherinewall
 
Surge2012
Surge2012Surge2012
Surge2012
davidapacheco
 
Rakuten openstack
Rakuten openstackRakuten openstack
Rakuten openstack
Rakuten Group, Inc.
 
MEAN Inside out (with AngularX)
MEAN Inside out (with AngularX)MEAN Inside out (with AngularX)
MEAN Inside out (with AngularX)
paolokersey
 
Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution Toolkit
Dimitry Snezhkov
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
Ivan Krylov
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
CocoaHeads France
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
7mind
 
Java 9 sneak peek
Java 9 sneak peekJava 9 sneak peek
Java 9 sneak peek
Martin Toshev
 
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Uri Cohen
 
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
Orchestration tool roundup   kubernetes vs. docker vs. heat vs. terra form vs...Orchestration tool roundup   kubernetes vs. docker vs. heat vs. terra form vs...
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
Nati Shalom
 
Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...
Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...
Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...
Cloud Native Day Tel Aviv
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
e-Legion
 
Auto cad 2006_api_overview
Auto cad 2006_api_overviewAuto cad 2006_api_overview
Auto cad 2006_api_overview
scdhruv5
 
CMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessCMake: Improving Software Quality and Process
CMake: Improving Software Quality and Process
Marcus Hanwell
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
Eugene Yokota
 
Jazoon12 355 aleksandra_gavrilovska-1
Jazoon12 355 aleksandra_gavrilovska-1Jazoon12 355 aleksandra_gavrilovska-1
Jazoon12 355 aleksandra_gavrilovska-1
Netcetera
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
Uday Sharma
 
Continuos integration for iOS projects
Continuos integration for iOS projectsContinuos integration for iOS projects
Continuos integration for iOS projects
Aleksandra Gavrilovska
 
Постоянное тестирование интеграции
Постоянное тестирование интеграцииПостоянное тестирование интеграции
Постоянное тестирование интеграции
SQALab
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
catherinewall
 
MEAN Inside out (with AngularX)
MEAN Inside out (with AngularX)MEAN Inside out (with AngularX)
MEAN Inside out (with AngularX)
paolokersey
 
Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution Toolkit
Dimitry Snezhkov
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
Ivan Krylov
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
CocoaHeads France
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
7mind
 
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...Orchestration tool roundup  - OpenStack Israel summit - kubernetes vs. docker...
Orchestration tool roundup - OpenStack Israel summit - kubernetes vs. docker...
Uri Cohen
 
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
Orchestration tool roundup   kubernetes vs. docker vs. heat vs. terra form vs...Orchestration tool roundup   kubernetes vs. docker vs. heat vs. terra form vs...
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
Nati Shalom
 
Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...
Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...
Uri Cohen & Dan Kilman, GigaSpaces - Orchestration Tool Roundup - OpenStack l...
Cloud Native Day Tel Aviv
 
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
«ReactiveCocoa и MVVM» — Николай Касьянов, SoftWear
e-Legion
 
Auto cad 2006_api_overview
Auto cad 2006_api_overviewAuto cad 2006_api_overview
Auto cad 2006_api_overview
scdhruv5
 
CMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessCMake: Improving Software Quality and Process
CMake: Improving Software Quality and Process
Marcus Hanwell
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
Eugene Yokota
 
Ad

More from Skills Matter Talks (9)

Couch db skillsmatter-prognosql
Couch db skillsmatter-prognosqlCouch db skillsmatter-prognosql
Couch db skillsmatter-prognosql
Skills Matter Talks
 
Jordan west real workscalazfinal2
Jordan west   real workscalazfinal2Jordan west   real workscalazfinal2
Jordan west real workscalazfinal2
Skills Matter Talks
 
(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro
Skills Matter Talks
 
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in AngerSCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
Skills Matter Talks
 
Real World Scalaz
Real World ScalazReal World Scalaz
Real World Scalaz
Skills Matter Talks
 
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
Skills Matter Talks
 
Tmt predictions 2011
Tmt predictions 2011Tmt predictions 2011
Tmt predictions 2011
Skills Matter Talks
 
Martin sustrik future_of_messaging
Martin sustrik future_of_messagingMartin sustrik future_of_messaging
Martin sustrik future_of_messaging
Skills Matter Talks
 
Marek pubsubhuddle realtime_web
Marek pubsubhuddle realtime_webMarek pubsubhuddle realtime_web
Marek pubsubhuddle realtime_web
Skills Matter Talks
 
Jordan west real workscalazfinal2
Jordan west   real workscalazfinal2Jordan west   real workscalazfinal2
Jordan west real workscalazfinal2
Skills Matter Talks
 
(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro
Skills Matter Talks
 
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in AngerSCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
Skills Matter Talks
 
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
Skills Matter Talks
 
Martin sustrik future_of_messaging
Martin sustrik future_of_messagingMartin sustrik future_of_messaging
Martin sustrik future_of_messaging
Skills Matter Talks
 

Recently uploaded (20)

tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 

Cnc scala-presentation

  • 1. CnC-Scala: A Declarative Approach to Multicore Parallelism Scala Days April 17, 2012 Shams Imam and Vivek Sarkar Rice University 1
  • 2. Acknowledgments •  Habanero Group –  Sagnak Tasirlar –  Dragos Sbirlea –  Alina Sbirlea •  “Concurrent Collections” Zoran Budimlic, Michael Burke, Vincent Cave, Kathleen Knobe, Geoff Lowney, Ryan Newton, Jens Palsberg, David Peixotto, Vivek Sarkar, Frank Schlimbach, Sagnak Tasirlar. Scientific Programming. •  “Concurrent Collections: Easy and effective distributed computing” Frank Schlimbach, Kath Knobe, James Brodman. 2
  • 3. Inverted Pyramid of Parallel Programming Skills Parallelism oblivious Focus of this talk developers Focus of Rice Habanero Project Parallelism aware Habanero-Scala, devs presented earlier today Java threads, locks, etc. Concurrency Experts 3 http://habanero.rice.edu
  • 4. The Issue Parallel programs are notoriously difficult for mortals to write, debug, maintain and port. 4
  • 5. The Big Idea •  Don’t specify what operations run in parallel •  Difficult and depends on target •  Specify the semantic ordering constraints only •  Easier and depends only on application 5
  • 6. Exactly Two Sources of Ordering Requirements •  Producer must execute before consumer •  Controller must execute before controllee 6
  • 7. Outline •  The Concurrent Collections (CnC) Model •  Features •  Constructs •  CnC Scala – Example •  Implementation •  Results 7
  • 8. The CnC model •  Programmer defines semantic dependences •  Ordering constraints between computational units •  Code in computation unit is standard serial code •  Runtime takes care of •  Executing the computational units •  Extracting parallelism in the application 8
  • 9. CnC Constructs - Steps (step) •  Computational unit of a CnC program •  Stateless •  Side-effect free •  Functional with respect to inputs 9
  • 10. CnC Constructs – Data Items [in_item] (step) [out_item] •  Data units are called Item Collection •  Means of communication between steps •  Mapping of data tags to items •  Items can only be retrieved by their tags •  Dynamic single assignment 10
  • 11. CnC Constructs - Control <tag> [in_item] (step) [out_item] •  Tag Collections are control units •  Used to execute (prescribe) steps •  A CnC step will not launch until its tag has been put 11
  • 12. CnC Constructs - Environment env <tag> env env [in_item] (step) [out_item] •  A driver which encapsulates the CnC Graph •  Provides inputs to and consumes outputs from the CnC Graph 12
  • 13. Exactly Two Sources of Ordering Requirements •  Producer must execute before consumer •  Controller must execute before controllee Producer - Consumer Controller - Controllee <tag1> (prod) [C1] (cons) (C-er) (C-ee) 13
  • 14. Outline •  The CnC Model •  CnC-Scala •  Build Model •  Capitalize-Words Example •  Step Code •  Implementation •  Results 14
  • 15. CnC-Scala •  Written in pure Scala •  uses continuations compiler plugin •  Only dependency – jsr-166y.jar •  comes bundled with java 7 •  Distribution with examples available at: •  http://cnc-scala.rice.edu/ 15
  • 16. CnC-Scala Build Model CnC Graph Spec cnc_scala_translate - Step code - main() method Generated Stub code cnc_scala_compile Compiled bytecode cnc_scala_run User Code Output Generated Code 16
  • 17. Capitalize-Words example 1.  import edu.rice.cnc.translator.GraphDescription._ 2.  object SplitCapitalizeCncDefinition extends App { 3.  // Item Collections 4.  ItemCollection[String, String]("input") 5.  ItemCollection[String, String]("words") 6.  ItemCollection[String, String]("result") 7.  // Tag Collections 8.  TagCollection[String]("data") 9.  TagCollection[String]("token") 10.  // Step Prescriptions 11.  Presription("data", List("split")) 12.  Presription("token", List("capitalize")) 13.  // Step Dependences 14.  StepDependence("split", List ("input"), List("token", "words")) 15.  StepDependence("capitalize", List("words"), List("result")) 16.  // Environment Collections 17.  EnvironmentDependence(List("input", "data"), List("result")) 18.  } 17
  • 18. Generated Code Example 1.  trait SplitStep extends Step { 2.  3.  // Optional to provide an implementation 4.  def createDependences( 5.  tag: java.lang.String, 6.  inInput: InputCollection[java.lang.String, java.lang.String], 7.  dependenceManager: DependenceManager 8.  ): Unit = {} 9.  10.  // User must provide an implementation for this method 11.  def compute( 12.  tag: java.lang.String, 13.  inInput: InputCollection[java.lang.String, java.lang.String], 14.  outToken: TagCollection[java.lang.String], 15.  outWords: OutputCollection[java.lang.String, java.lang.String] 16.  ): Unit@cpsParam[Any, Any] 17.  } 18
  • 19. User Step Code 1.  class UserSplitStep extends SplitStep { 2.  3.  // User must provide an implementation for this method 4.  def compute( 5.  tag: java.lang.String, 6.  inInput: InputCollection[java.lang.String, java.lang.String], 7.  outToken: TagCollection[java.lang.String], 8.  outWords: OutputCollection[java.lang.String, java.lang.String] 9.  ): Unit@cpsParam[Any, Any] = { 10.  val inString = inInput.get(tag) 11.  for ((token, index) <- inString.split(" +").view.zipWithIndex) { 12.  val newTag = tag + ":" + index 13.  outWords.put(newTag, token) 14.  outToken.put(newTag) 15.  } } } 19
  • 20. User Main 1.  object SplitCapitalizeMain extends CncScalaApp { 2.  // Instantiate Steps 3.  val splitStep = new UserSplitStep() 4.  val capitalizeStep = new UserCapitalizeStep() 5.  val graph = new SplitCapitalizeGraph(splitStep, capitalizeStep) 6.  7.  graph.run(new Runnable() { 8.  def run(): Unit = { 9.  // populate data from environment to collections 10.  val tag = "1" 11.  graph.input.put(tag, "hello world") 12.  graph.data.put(tag) 13.  } 14.  }) 15.  // read results 16.  graph.result.dump(System.out) 17.  } 20
  • 21. Outline •  The CnC Model •  CnC-Scala •  Implementation •  Data-driven futures •  Continuations •  Results 21
  • 22. Implementation •  Tag Collections •  Spawn new tasks run step code •  Item Collections •  Use concurrent maps with user defined tag types as keys and data-driven futures (DDF) as values •  What to do when get() has unavailable items? •  Create continuations •  When value becomes available… •  DDFs resume continuations 22
  • 23. Data-driven futures •  Separation of classical “futures” into data and control parts •  Consumers can eagerly register on the DDF even before we know about the producer •  i.e., lazily attaches a producer to an item •  When item is produced, all previously registered consumers are notified •  Subsequent consumers always get the value immediately 23
  • 24. Continuations •  Represents rest of the computation from a given point in the program •  Allows •  suspending current execution state •  resume from that point later •  We need only delimited one-shot continuations •  Scala has shift-reset! 24
  • 25. Benefits of using continuations •  No re-execution of code •  Allow arbitrary (data-dependent) gets •  Threads never block •  No extra threads created 25
  • 26. Scala Continuation example 1.  object Main { 2.  def main(args: Array[String]) { 3.  println("A. Main starts") 4.  var continuation: (Unit) => Any = null Output: 5.  reset { // delimit boundary start 6.  println("B. Entered reset") 7.  shift[Unit, Any, Unit] { A. Main starts 8.  delimCont => B. Entered reset 9.  println("C. Entered shift") C. Entered shift 10.  continuation = delimCont D. Inside shift F. Outside reset 11.  println("D. Inside shift") G. Calling cont. 12.  } E. After shift 13.  println("E. After shift") H. Main ends 14.  } // delimit boundary end 15.  println("F. Outside reset") 16.  println("G. Calling cont.") 17.  continuation() 18.  println("H. Main ends") 19.  } 20.  } 26
  • 27. CnC-Scala Runtime - step •  Tag Collection step prescription •  Wrap each step.compute() in a reset // some preparation
 reset {
 step.compute(tag, inputs, outputs)
 }
 // book-keeping logic based on 
 // whether continuation was stored
 // or execution completed normally 27
  • 28. CnC-Scala Runtime - get •  If item is available return it •  Else store continuation get(tag: TagType): ItemType = {
 if (itemAvailable)
 return item
 else
 shift { continuation =>
 // store continuation
 }
 // when cont resumes, item is available
 return item
 } 28
  • 29. CnC-Scala Runtime - put •  Store item •  Resume waiting continuations put(tag: TagType, item: ItemType) {
 // store item into DDF
 // resume ALL waiting continuations
 } 29
  • 30. Outline •  The CnC Model •  CnC-Scala •  Implementation •  Results 30
  • 31. CnC-Scala Results •  12-core (two hex-cores) 2.8 GHz Intel Westmere SMP •  48 GB memory, running Red Hat Linux (RHEL 6.0) •  Hotspot JDK 1.7 •  Scala version 2.9.1-1 •  CnC-Scala 0.1.2 •  Arithmetic mean of last thirty iterations from hundred iterations on ten separate JVM invocations 31
  • 32. Successive Over-Relaxation •  1 Item Collection, 1 Tag Collection, and 1 Step. 32
  • 33. NQueens •  3 Item Collections, 1 Tag Collection, and 1 Step. 33
  • 34. LU Decomposition •  3 Item Collections, 5 Tag Collections, and 8 Steps. 34
  • 35. CnC Features •  Coordination language •  Dynamic light-weight task based •  Single assignment •  Deterministic •  Race free 35
  • 36. Summary •  CnC exposes more potential parallelism •  Development is productive •  User declaratively defines dependences and writes only serial code •  runtime hides all the difficulties with using low- level techniques •  result is deterministic and independent of number of threads 36
  • 37. Thank you! [image source: http://www.jerryzeinfeld.com/tag/question-of-the-day/] 37