Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel...
-
Upload
sheryl-harrell -
Category
Documents
-
view
219 -
download
0
Transcript of Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel...
![Page 1: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/1.jpg)
Better concurrency with a .NET language for isolation and asynchrony
Niklas GustafssonParallel Computing PlatformMicrosoft Corporation
[email protected]© 2009 Microsoft Corporation 1
![Page 2: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/2.jpg)
Take-aways
• Concepts– Domains and agents– Channels and protocols– Schema– Dataflow networks
• Examples
© 2009 Microsoft Corporation
![Page 3: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/3.jpg)
Layers of a Concurrent Program
• Asynchronous Agents– Isolation,
asynchrony• Concurrent
Collections– Parallelism,
decomposition• Interacting
Infrastructure– Consistency
Interacting Infrastructure
Asynchronous Agents
Concurrent Collections
© 2009 Microsoft Corporation
![Page 4: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/4.jpg)
Maestro Value Propositions
• Reduce complexity
• Provide a declarative model for serializing access to state
• Leverage latency
• Components default to concurrency
• Provide an application model that is inherently concurrent and responsive
© 2009 Microsoft Corporation
![Page 5: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/5.jpg)
Incubation Objectives
• Is language the better way to go?• Does our model reduce complexity?• Is it feasible and productive to incrementally adopt
Maestro for legacy apps?• Are we building it right?• Syntax and semantics• Missing concepts• Conceptual consistency and composition• Productivity• Platform fit
© 2009 Microsoft Corporation
![Page 6: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/6.jpg)
Maestro from 50,000 Feet
• Imperative• Actor-oriented• Special-purpose• Object-aware• Concurrent by default
© 2009 Microsoft Corporation
![Page 7: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/7.jpg)
• Ada
• Erlang
• SR (U of Arizona)
• Web-based Application Patterns
© 2009 Microsoft Corporation
Maestro Inspiration
![Page 8: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/8.jpg)
Is a parallel system that:Runs on hundreds of millions of coresIs known to scaleIs built by tens of thousands of programmers of
average skill working in thousands of organizationsIs remarkably robust
Maybe there are some things we could learn from how it's programmed?
© 2009 Microsoft Corporation
The Web
![Page 9: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/9.jpg)
Programming model aspects of relevance to manycore:
Loosely coupled
Strictly isolated components
Globally concurrent, locally sequential
Message-passing with simple protocols
Partial failure is expected and common
© 2009 Microsoft Corporation
Web Programming
![Page 10: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/10.jpg)
Sources Of Concurrency
• Asynchronous Agents– An agent has a separate “thread” of control
• Dataflow networks– Multiple nodes “light up” concurrently
© 2009 Microsoft Corporation
![Page 11: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/11.jpg)
Maestro: Core ConceptsDomain Agent
Channel
SchemaPattern
© 2009 Microsoft Corporation
![Page 12: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/12.jpg)
Maestro: Application Structure
Agent:ReaderAgent:Reader
Shared StateShared State
Agent:ReaderAgent:ReaderReader
AgentsReader Agents
WriterAgentWriterAgent
WriterAgentWriterAgent
Domain Domain
Shared StateShared State
Reader Agent
Reader Agent
WriterAgentWriterAgent
WriterAgentWriterAgent
WriterAgentWriterAgent
SchemaSchema
SchemaSchema
Channel w/ protocolChannel w/ protocol
© 2009 Microsoft Corporation
![Page 13: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/13.jpg)
Domain
• Passive construct• Scope of global state• Isolation boundary
domain A{ int j; int func( int k ) { } agent X : Channel1 { } agent Y : Channel2 { }}
domain B{ double m; string func( ) { } agent Z : Channel1 { }}
© 2009 Microsoft Corporation
![Page 14: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/14.jpg)
Agent
• Thread of control• Communicates with
other agents:– Intra-domain– Inter-domain
• Inheritance model• Reader/Writer
declaration
domain A{ int j; int func( int k ) { } writer agent X : Channel1 { } reader agent Y : Channel2 { }}
domain B{ double m; string func( ) { } agent Z : Channel1 { }}
© 2009 Microsoft Corporation
![Page 15: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/15.jpg)
Channel
• Agent proxy• Duplex message-
passing via ports• Enforces value passing
semantics• Bi-lateral channels only,
not a general "open mailbox" concept
channel ChAddition{ input int Add; output int Sum;}
© 2009 Microsoft Corporation
![Page 16: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/16.jpg)
Duality Of Ports
© 2009 Microsoft Corporation
Num1
Channel
Num2
Sum
Num1
Num2
Sum
Agent Implside
Usingside
Each port is both a source and a target, depending on which side of the channel you are using it from, the channel perspective.
![Page 17: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/17.jpg)
Pattern
• Enforces protocol rules• Special states: start
and end• For channels and
networks
channel ChAddition{ input int Add; output int Sum;
Start: { Add -> S1; } S1: { Sum -> End; }}
© 2009 Microsoft Corporation
![Page 18: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/18.jpg)
Schema
• Fields• Functions• Constants• Rules• Serializable• Strong name identity
schema A { required String Name; optional Int32 Age = 0;
rules { require String.IsNullOrEmpty(Name); require Age >= 0; } }
schema B { optional String Name; } B b = ...;A a = b; A a = {Name = “John”, Age = 39};
© 2009 Microsoft Corporation
![Page 19: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/19.jpg)
Dataflow Networks
• Think of data flowing through network– Not objects performing actions!
• Get data, do something with it, pass on to next stage(s)
© 2009 Microsoft Corporation
![Page 20: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/20.jpg)
Network Declarations
• Encapsulates DF layout• Exposes ports• Implementation details
hidden in private methods and fields
network N1{
input string RequestByKey; input int RequestBySize; output ResultRecord Result;
public N1() { … }
layout { RequestByKey ==> Search ==> Result; RequestBySize ==> szTbl.Find ==> Result; }
private Map<int,ResultRecord> szTbl;}
© 2009 Microsoft Corporation
![Page 21: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/21.jpg)
Dataflow Examples
• Compiler:– Characters flow through lexer turning into tokens;– Tokens go through grammar turning into AST;– AST goes through several passes
• Spreadsheet:– Change in a cell triggers reevaluation of
dependent cells;– Independent cells can change concurrently
© 2009 Microsoft Corporation
![Page 22: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/22.jpg)
Example: Image Processor
© 2009 Microsoft Corporation
• Read JPG, Sharpen, Reduce “red eye” effect, Shrink, Save as 85% quality JPG
• Simple pipeline
Network n1 = Read ==> Sharpen ==> RedEye ==> Shrink ==> Save;
![Page 23: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/23.jpg)
Example: Image Processor (2)
© 2009 Microsoft Corporation
• Simple branching
Save
Network n1 = (Read ==> Sharpen ==> RedEye);n1 -<< { Save, Shrink ==> Save};
![Page 24: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/24.jpg)
Example: Image Processor (3)
© 2009 Microsoft Corporation
• Simple branching
Network n1 = (Sharpen ==> RedEye ==> Shrink);Network n2 = (Sharpen ==> RedEye ==> Shrink); // or: n1.Clone();Network n3 = (Sharpen ==> RedEye ==> Shrink); // or: n1.Clone();
Read -<: { n1, n2, n3 } >>- Save;
Sharpen Red Eye Shrink
Sharpen Red Eye Shrink
![Page 25: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/25.jpg)
Concurrency in Network
• Same model: one writer or multiple readers– Reader/writer of what?– Notation: methods write, true functions read
© 2009 Microsoft Corporation
Domain
ReaderAgent1
method1
method2
function1
function2
m1m2f1f2
WriterAgent2
m1m2f1f2
No AccessAgent3
m1m2f1f2
![Page 26: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/26.jpg)
© 2009 Microsoft Corporation
Example: Backup Utility
![Page 27: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/27.jpg)
Example: Backup Utility
GUIController
Profiles
Backup
FolderMonitor
ConfigurationLog
Backup Sched
© 2009 Microsoft Corporation
![Page 28: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/28.jpg)
We're planning a early-access public release through Microsoft DevLabs in the spring.
Download itPlay with itBuild something with itTry to break itTell us what you thinkSpread the word
© 2009 Microsoft Corporation
How to join the band…
![Page 29: Better concurrency with a.NET language for isolation and asynchrony Niklas Gustafsson Parallel Computing Platform Microsoft Corporation Niklas.Gustafsson@microsoft.com.](https://reader035.fdocuments.in/reader035/viewer/2022062717/56649e2a5503460f94b180c9/html5/thumbnails/29.jpg)
© 2009 Microsoft Corporation
Thank You
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.