Developer Conference 2011 MICROSOFT USER GROUP KOLKATA
TPL Task Parallel Library^ – Data Flow Tasks Sankarsan Bose 12th November , 2011
Parallel Programming As It Evolves - Higher level constructs to handle pipeline scenarios - Earlier DevLabs - CTP Data Flow Tasks .NET 4.5 Preview 1 Coordination Data Task Parallel Parallel Structure Library Programming in .NET 4.0 Threads Till .NET 3.5 to ta Care of concurrency requirements
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 pipelines Input Stage1 Stage 2 Stage N Output
Image Pipeline – An Example Input Image Load Image Original Image s Scale Image Filter Image Thumbnails Filtered Images Display Image This is sequential… How it makes sense in Parallel World???
Image Pipeline – An Example (Contd..) Image1 Image2 Image3 Image4 Image5 Load Image1 Image2 Image3 Image4 Image5 Scale Filter Image1 Image2 Image3 Image4 Image5 Image1 Image2 Image3 Image4 Image5 Display t0 t1 t2 t3 t4 t5 t6 t7
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 IDataFlowBloc - Stages should be able k - Handle input ISourceBlock ITargetBlock - 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
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 Input ActionBlock Task Input BufferBlock Original Task Input BroadcastBlock Copy Task Copy Copy TransformBlock Input Tas Output k Input JoinBlock 1 Tas Output k Input 2
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. Coding…..Enjoy Learning.. Happy
Speaker Details/Contact - http://twitter.com/sankarsan - http://sankarsan.wordpress.com - http://codingndesign.com - http://sankarsanbose.com
Task Parallel Library Data Flows

Task Parallel Library Data Flows

  • 1.
    Developer Conference 2011 MICROSOFT USER GROUP KOLKATA
  • 2.
    TPL Task Parallel Library^– Data Flow Tasks Sankarsan Bose 12th November , 2011
  • 3.
    Parallel Programming AsIt Evolves - Higher level constructs to handle pipeline scenarios - Earlier DevLabs - CTP Data Flow Tasks .NET 4.5 Preview 1 Coordination Data Task Parallel Parallel Structure Library Programming in .NET 4.0 Threads Till .NET 3.5 to ta Care of concurrency requirements
  • 4.
    Pipelines And DataFlow 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 pipelines Input Stage1 Stage 2 Stage N Output
  • 5.
    Image Pipeline –An Example Input Image Load Image Original Image s Scale Image Filter Image Thumbnails Filtered Images Display Image This is sequential… How it makes sense in Parallel World???
  • 6.
    Image Pipeline –An Example (Contd..) Image1 Image2 Image3 Image4 Image5 Load Image1 Image2 Image3 Image4 Image5 Scale Filter Image1 Image2 Image3 Image4 Image5 Image1 Image2 Image3 Image4 Image5 Display t0 t1 t2 t3 t4 t5 t6 t7
  • 7.
    What type oftasks 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
  • 8.
    TPL DataFlow Blocks IDataFlowBloc - Stages should be able k - Handle input ISourceBlock ITargetBlock - 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
  • 9.
    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….
  • 10.
    Built In DataFlow Blocks Input ActionBlock Task Input BufferBlock Original Task Input BroadcastBlock Copy Task Copy Copy TransformBlock Input Tas Output k Input JoinBlock 1 Tas Output k Input 2
  • 11.
    Image Processing Program ImageProcessing Program…Let’s Build a Skeletal Code
  • 12.
    References - Parallel Programmingwith 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/
  • 13.
    Thanks Everybody, ForYour Time. Coding…..Enjoy Learning.. Happy
  • 14.
    Speaker Details/Contact - http://twitter.com/sankarsan -http://sankarsan.wordpress.com - http://codingndesign.com - http://sankarsanbose.com