dev con kolkata 2011 tpl dataflows

15
Developer Conference 2011 MICROSOFT USER GROUP KOLKATA

Upload: abhishek-sur

Post on 16-Apr-2017

652 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Dev con kolkata 2011   tpl dataflows

Developer Conference 2011

MICROSOFT USER GROUP KOLKATA

Page 2: Dev con kolkata 2011   tpl dataflows

TPLTask Parallel Library

^ – Data

Flow Tasks Sankarsan Bose12th November , 2011

Page 3: Dev con kolkata 2011   tpl dataflows

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

Page 4: Dev con kolkata 2011   tpl dataflows

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

Page 5: Dev con kolkata 2011   tpl dataflows

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???

Page 6: Dev con kolkata 2011   tpl dataflows

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

Page 7: Dev con kolkata 2011   tpl dataflows

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

Page 8: Dev con kolkata 2011   tpl dataflows

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

Page 9: Dev con kolkata 2011   tpl dataflows

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….

Page 10: Dev con kolkata 2011   tpl dataflows

Built In Data Flow Blocks

ActionBlockTask

Input

BufferBlockTask

Input Original

BroadcastBlockTask

Input

Copy

CopyCopy

TransformBlock

TaskInput

Output

JoinBlock

Task

Input1Input2

Output

Page 11: Dev con kolkata 2011   tpl dataflows

Image Processing Program

Image Processing Program…Let’s Build a Skeletal Code

Page 12: Dev con kolkata 2011   tpl dataflows

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/

Page 13: Dev con kolkata 2011   tpl dataflows

Thanks Everybody, For Your Time.Happy Coding…..Enjoy Learning..

Page 14: Dev con kolkata 2011   tpl dataflows

Speaker Details/Contact

- http://twitter.com/sankarsan- http://sankarsan.wordpress.com- http://codingndesign.com- http://sankarsanbose.com