SlideShare a Scribd company logo
2
Most read
7
Most read
8
Most read
by Umesh
Parallel Programming
 Most of computers manufacture with multi cores
 Server application will handle each request in separate
threads.
 Parallel programming basically for Desktop applications.
 Desktop implementation
 Partitioning codes into small chunks
 Execute those chunks in multi threads
 Collate all the results from the threads, in a thread-safe and
perform ant manner.
 Its awkward to handle with threads particularly
partitioning and collating.
 Parallel programming is designed with set of API’s
specifically handle these scenario.
Parallel Programming
 Programming to leverage multicores or multiple processors is
called parallel programming. This is a subset of the broader
concept of multithreading.
 Parallel programming is the general discipline of doing multiple
computations in parallel, using multiple cores, each of which is
doing some sub computation of a larger single problem.
 Where as Multithreading is the approach of using multiple
threads of execution to process different operations, e.g. if you
have two things to do, use one thread to do one and another
thread to do the other.
 An operating system is able to take handle thread execution in
available cores.
 New .net parallel API’s take maximum advantage of available
CPU resources.
Parallel Programming
C# Parallel programming
Parallel Programming
 Task Parallel Library (TPL)
 PLINQ
 Data Parallelism
 Parallel.For
 Parallel.ForEach
 Parallel.Invoke
 Task Parallelism
 Task
Task Parallel Library (TPL)
 TPL provides set of API to implement parallel
processing.
 TPL is to make developers more productive by
simplifying the process of adding parallelism and
concurrency to applications.
 The TPL scales the degree of concurrency dynamically
to most efficiently use all the processors that are
available.
 the TPL handles the partitioning of the work, the
scheduling of threads on the ThreadPool, cancellation
support and state management.
PLINQ (Parallel LINQ)
 PLINQ offers the richest functionality: it automates all the
steps of parallelization—including partitioning the work
into tasks, executing those tasks on threads, and collating
the results into a single output sequence
 PLINQ is to speed up the execution of LINQ to Objects
queries by executing the query delegates in parallel on
multi-core computers.
 PLINQ queries scale in the degree of concurrency based on
the capabilities of the host computer. Syntax-
from num in source.AsParallel()
where num % 10 == 0
select num;
Data Parallelism
 The same operation is performed concurrently on
elements in a source collection or array.
 The source collection is partitioned so that multiple
threads can operate on different segments concurrently.
 Parallel – class available in System.Thread.Tasks namespace
 For() - Performs the parallel equivalent of a C# for loop
 ForEach() - Performs the parallel equivalent of a C# foreach loop
 Invoke () - method provides a convenient way to run any number
of arbitrary statements concurrently. That mean, executes an array
of Action delegates in parallel, and then waits for them to complete
TaskParallelism
 It refers to one or more independent tasks running concurrently.
 A task represents an asynchronous operation, and in some ways it resembles the creation
of a new thread or ThreadPool work item,.
 Benefits of taks.
 Tune a task’s scheduling
 Establish a parent/child relationship when one task is started from another
 Implement cooperative cancellation
 Wait on a set of tasks—without a signaling construct
 Attach “continuation” task(s)
 Schedule a continuation based on multiple antecedent tasks
 Propagate exceptions to parents, continuations, and task consumers
 Dispose the task, it will dispose associated object in the task.
 The Parallel class and PLINQ are internally built on the task parallelism constructs. Task
parallelism is the lowest-level approach to parallelization.
 The following way to create Task, class available in System.Threading.Tasks namespace
 Task - For managing a unit for work
 Task<Tresult> - For managing a unit for work with a return value
 TaskFactory - For creating tasks
 TaskFactory<Tresult> - For creating tasks and continuations with the same return type
References
http://msdn.microsoft.com/en-
us/library/dd460693.aspx
http://www.albahari.com/threading/part5.aspx
C# Parallel programming
Ad

Recommended

PPTX
Introduction à Angular
Jean-Baptiste Vigneron
 
PDF
Sync, async and multithreading
Tuan Chau
 
PDF
Understanding the Single Thread Event Loop
TorontoNodeJS
 
PDF
Paving the road with Jakarta EE and Apache TomEE - JCON 2021
César Hernández
 
PPTX
Angular overview
Thanvilahari
 
PPTX
Ionic, AngularJS,Cordova,NodeJS,Sass
marwa baich
 
PDF
Support cours angular
Nizar MAATOUG -ISET Sidi Bouzid
 
PDF
Angular
Lilia Sfaxi
 
PPTX
Angular interview questions
Goa App
 
PPT
Java servlet life cycle - methods ppt
kamal kotecha
 
PPTX
Concurrency in Java
Allan Huang
 
PPT
Boolean Retrieval
mghgk
 
PDF
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
PPTX
Angular 5 presentation for beginners
Imran Qasim
 
PDF
Angular Framework présentation PPT LIGHT
tayebbousfiha1
 
PDF
Introduction To Single Page Application
KMS Technology
 
PPT
Angular 8
Sunil OS
 
PPTX
What Is Express JS?
Simplilearn
 
PPT
MULTIPROCESSOR AND REAL TIME SCHEDULING.ppt
CUO VEERANAN VEERANAN
 
PDF
Chapter 2 Text Operation and Term Weighting.pdf
JemalNesre1
 
PPTX
Introduction to apache nutch
Sigmoid
 
PPTX
Angular
Mouad EL Fakir
 
PPTX
Node js introduction
Joseph de Castelnau
 
PPTX
Spring framework
Rajkumar Singh
 
PDF
Automation of IT Ticket Automation using NLP and Deep Learning
Pranov Mishra
 
PDF
Sync async-blocking-nonblocking-io
Cheoloh Bae
 
ODP
Angular 6 - The Complete Guide
Sam Dias
 
PDF
A first look into the Project Loom in Java
Lukas Steinbrecher
 
PDF
Partitioning CCGrid 2012
Weiwei Chen
 
PPT
TASK SCHEDULING ON ADAPTIVE MULTI-CORE
Haris Muhammed
 

More Related Content

What's hot (20)

PPTX
Angular interview questions
Goa App
 
PPT
Java servlet life cycle - methods ppt
kamal kotecha
 
PPTX
Concurrency in Java
Allan Huang
 
PPT
Boolean Retrieval
mghgk
 
PDF
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
PPTX
Angular 5 presentation for beginners
Imran Qasim
 
PDF
Angular Framework présentation PPT LIGHT
tayebbousfiha1
 
PDF
Introduction To Single Page Application
KMS Technology
 
PPT
Angular 8
Sunil OS
 
PPTX
What Is Express JS?
Simplilearn
 
PPT
MULTIPROCESSOR AND REAL TIME SCHEDULING.ppt
CUO VEERANAN VEERANAN
 
PDF
Chapter 2 Text Operation and Term Weighting.pdf
JemalNesre1
 
PPTX
Introduction to apache nutch
Sigmoid
 
PPTX
Angular
Mouad EL Fakir
 
PPTX
Node js introduction
Joseph de Castelnau
 
PPTX
Spring framework
Rajkumar Singh
 
PDF
Automation of IT Ticket Automation using NLP and Deep Learning
Pranov Mishra
 
PDF
Sync async-blocking-nonblocking-io
Cheoloh Bae
 
ODP
Angular 6 - The Complete Guide
Sam Dias
 
PDF
A first look into the Project Loom in Java
Lukas Steinbrecher
 
Angular interview questions
Goa App
 
Java servlet life cycle - methods ppt
kamal kotecha
 
Concurrency in Java
Allan Huang
 
Boolean Retrieval
mghgk
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
Angular 5 presentation for beginners
Imran Qasim
 
Angular Framework présentation PPT LIGHT
tayebbousfiha1
 
Introduction To Single Page Application
KMS Technology
 
Angular 8
Sunil OS
 
What Is Express JS?
Simplilearn
 
MULTIPROCESSOR AND REAL TIME SCHEDULING.ppt
CUO VEERANAN VEERANAN
 
Chapter 2 Text Operation and Term Weighting.pdf
JemalNesre1
 
Introduction to apache nutch
Sigmoid
 
Node js introduction
Joseph de Castelnau
 
Spring framework
Rajkumar Singh
 
Automation of IT Ticket Automation using NLP and Deep Learning
Pranov Mishra
 
Sync async-blocking-nonblocking-io
Cheoloh Bae
 
Angular 6 - The Complete Guide
Sam Dias
 
A first look into the Project Loom in Java
Lukas Steinbrecher
 

Viewers also liked (8)

PDF
Partitioning CCGrid 2012
Weiwei Chen
 
PPT
TASK SCHEDULING ON ADAPTIVE MULTI-CORE
Haris Muhammed
 
PPTX
Wait-free data structures on embedded multi-core systems
Menlo Systems GmbH
 
PPTX
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
Naoki Shibata
 
PDF
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
knowdiff
 
PPTX
Real time system in Multicore/Multiprocessor system
Mayank Garg
 
PPS
Critical Chain Project Management
Fred Wiersma
 
PDF
Multicore scheduling in automotive ECUs
RealTime-at-Work (RTaW)
 
Partitioning CCGrid 2012
Weiwei Chen
 
TASK SCHEDULING ON ADAPTIVE MULTI-CORE
Haris Muhammed
 
Wait-free data structures on embedded multi-core systems
Menlo Systems GmbH
 
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
Naoki Shibata
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
knowdiff
 
Real time system in Multicore/Multiprocessor system
Mayank Garg
 
Critical Chain Project Management
Fred Wiersma
 
Multicore scheduling in automotive ECUs
RealTime-at-Work (RTaW)
 
Ad

Similar to C# Parallel programming (20)

PPTX
Parallel Programming
Mindfire Solutions
 
PPTX
Coding For Cores - C# Way
Bishnu Rawal
 
PPTX
Multi core programming 1
Robin Aggarwal
 
PPTX
Parallel extensions in .Net 4.0
Dima Maleev
 
PDF
.Net Multithreading and Parallelization
Dmitri Nesteruk
 
PPT
MTaulty_DevWeek_Parallel
ukdpe
 
PPT
Parallel Extentions to the .NET Framework
ukdpe
 
PPTX
.NET Multithreading/Multitasking
Sasha Kravchuk
 
ZIP
.Net 4.0 Threading and Parallel Programming
Alex Moore
 
PPTX
Parallel Processing
RTigger
 
PPTX
Parallel Computing in .NET
meghantaylor
 
PPTX
C# 5 deep drive into asynchronous programming
Praveen Prajapati
 
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
PPTX
Training – Going Async
Betclic Everest Group Tech Team
 
PPTX
MERIMeeting du 27 mai 2014 - Parallel Programming
Olivier NAVARRE
 
PDF
Parallel Programming With Microsoft Net Design Patterns For Decomposition And...
foegeartemfz
 
PPTX
End to-end async and await
vfabro
 
PPT
Parallel Programming and F#
llangit
 
PPT
Overview Of Parallel Development - Ericnel
ukdpe
 
Parallel Programming
Mindfire Solutions
 
Coding For Cores - C# Way
Bishnu Rawal
 
Multi core programming 1
Robin Aggarwal
 
Parallel extensions in .Net 4.0
Dima Maleev
 
.Net Multithreading and Parallelization
Dmitri Nesteruk
 
MTaulty_DevWeek_Parallel
ukdpe
 
Parallel Extentions to the .NET Framework
ukdpe
 
.NET Multithreading/Multitasking
Sasha Kravchuk
 
.Net 4.0 Threading and Parallel Programming
Alex Moore
 
Parallel Processing
RTigger
 
Parallel Computing in .NET
meghantaylor
 
C# 5 deep drive into asynchronous programming
Praveen Prajapati
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
Training – Going Async
Betclic Everest Group Tech Team
 
MERIMeeting du 27 mai 2014 - Parallel Programming
Olivier NAVARRE
 
Parallel Programming With Microsoft Net Design Patterns For Decomposition And...
foegeartemfz
 
End to-end async and await
vfabro
 
Parallel Programming and F#
llangit
 
Overview Of Parallel Development - Ericnel
ukdpe
 
Ad

Recently uploaded (20)

PDF
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
PDF
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
PDF
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
PDF
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
PDF
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
PDF
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
PDF
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
PDF
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
PDF
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
PDF
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
The Growing Value and Application of FME & GenAI
Safe Software
 

C# Parallel programming

  • 2. Parallel Programming  Most of computers manufacture with multi cores  Server application will handle each request in separate threads.  Parallel programming basically for Desktop applications.  Desktop implementation  Partitioning codes into small chunks  Execute those chunks in multi threads  Collate all the results from the threads, in a thread-safe and perform ant manner.  Its awkward to handle with threads particularly partitioning and collating.  Parallel programming is designed with set of API’s specifically handle these scenario.
  • 3. Parallel Programming  Programming to leverage multicores or multiple processors is called parallel programming. This is a subset of the broader concept of multithreading.  Parallel programming is the general discipline of doing multiple computations in parallel, using multiple cores, each of which is doing some sub computation of a larger single problem.  Where as Multithreading is the approach of using multiple threads of execution to process different operations, e.g. if you have two things to do, use one thread to do one and another thread to do the other.  An operating system is able to take handle thread execution in available cores.  New .net parallel API’s take maximum advantage of available CPU resources.
  • 6. Parallel Programming  Task Parallel Library (TPL)  PLINQ  Data Parallelism  Parallel.For  Parallel.ForEach  Parallel.Invoke  Task Parallelism  Task
  • 7. Task Parallel Library (TPL)  TPL provides set of API to implement parallel processing.  TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications.  The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available.  the TPL handles the partitioning of the work, the scheduling of threads on the ThreadPool, cancellation support and state management.
  • 8. PLINQ (Parallel LINQ)  PLINQ offers the richest functionality: it automates all the steps of parallelization—including partitioning the work into tasks, executing those tasks on threads, and collating the results into a single output sequence  PLINQ is to speed up the execution of LINQ to Objects queries by executing the query delegates in parallel on multi-core computers.  PLINQ queries scale in the degree of concurrency based on the capabilities of the host computer. Syntax- from num in source.AsParallel() where num % 10 == 0 select num;
  • 9. Data Parallelism  The same operation is performed concurrently on elements in a source collection or array.  The source collection is partitioned so that multiple threads can operate on different segments concurrently.  Parallel – class available in System.Thread.Tasks namespace  For() - Performs the parallel equivalent of a C# for loop  ForEach() - Performs the parallel equivalent of a C# foreach loop  Invoke () - method provides a convenient way to run any number of arbitrary statements concurrently. That mean, executes an array of Action delegates in parallel, and then waits for them to complete
  • 10. TaskParallelism  It refers to one or more independent tasks running concurrently.  A task represents an asynchronous operation, and in some ways it resembles the creation of a new thread or ThreadPool work item,.  Benefits of taks.  Tune a task’s scheduling  Establish a parent/child relationship when one task is started from another  Implement cooperative cancellation  Wait on a set of tasks—without a signaling construct  Attach “continuation” task(s)  Schedule a continuation based on multiple antecedent tasks  Propagate exceptions to parents, continuations, and task consumers  Dispose the task, it will dispose associated object in the task.  The Parallel class and PLINQ are internally built on the task parallelism constructs. Task parallelism is the lowest-level approach to parallelization.  The following way to create Task, class available in System.Threading.Tasks namespace  Task - For managing a unit for work  Task<Tresult> - For managing a unit for work with a return value  TaskFactory - For creating tasks  TaskFactory<Tresult> - For creating tasks and continuations with the same return type