dev con kolkata 2011 tpl dataflows
TRANSCRIPT
Developer Conference 2011
MICROSOFT USER GROUP KOLKATA
TPLTask Parallel Library
^ – Data
Flow Tasks Sankarsan Bose12th November , 2011
Parallel Programming in .NET 4.0
Threads
Data Flow Tasks
Coordination Data Structure
Task Parallel Library
Till .NET 3.5 to takeCare of concurrencyrequirements
.NET 4.5 Preview 1
Parallel Programming As It Evolves
- Earlier DevLabs
- CTP
- Higher level constructs to handle pipeline scenarios
Pipelines And Data Flow Networks
- A linear series of producer/consumer stages- Output of one stage -> Input of another
- Stages of pipeline are supposed to process
input in specified order- Data Flow networks are more general form of
pipelinesStage1 Stage 2 Stage NInput Output
Image Pipeline – An Example
Load Image
Scale Image
Filter Image
Display Image
Input Image
Original Image s
Filtered ImagesThumbnails
This is sequential… How it makes sense in Parallel World???
Image Pipeline – An Example (Contd..)
Load
Scale
Filter
Image1
Display
Image1
Image1
Image1
Image2
Image2
Image2
Image2
Image3
Image4
t0 t1 t2 t3 t4 t5 t6 t7
Image3
Image3
Image3
Image4
Image4
Image4
Image5
Image5
Image5
Image5
What type of tasks Stages Can Do?
- Receive an input and process it.- Receive an input, buffer it and send it to
another stage- Receive an input, transform the input and
send the output to another stage- Receive input from multiple stages and
join/combine the inputs to produce the output
TPL DataFlow Blocks
- Stages should be able- Handle input- Produce output- Buffer data- Perform Processing
- Stages are modeled as Data Flow Blocks- Data Flow Blocks can be
- Source Block – Generate data- Target Block - Accept data
IDataFlowBlock
ISourceBlock ITargetBlock
TPL DataFlow Blocks(Contd..)
- Built-In Data Flow Blocks- Buffering Blocks
- BufferedBlock- BroadCastBlock
- Executor Blocks- ActionBlock- TransformBlock- TransformManyBlock
- Join Blocks- JoinBlock- BatchBlock
Let’s Go To The Code….
Built In Data Flow Blocks
ActionBlockTask
Input
BufferBlockTask
Input Original
BroadcastBlockTask
Input
Copy
CopyCopy
TransformBlock
TaskInput
Output
JoinBlock
Task
Input1Input2
Output
Image Processing Program
Image Processing Program…Let’s Build a Skeletal Code
References
- Parallel Programming with Microsoft Visual C++ by Colin Campbell and Ade Miller
- Patterns Of Parallel Programming by Stephen Toub
- Introduction To TPL DataFlow by Stepehen Toub
- Samples in http://parallelpatterns.codeplex.com/
Thanks Everybody, For Your Time.Happy Coding…..Enjoy Learning..
Speaker Details/Contact
- http://twitter.com/sankarsan- http://sankarsan.wordpress.com- http://codingndesign.com- http://sankarsanbose.com