SlideShare ist ein Scribd-Unternehmen logo
1 von 12
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
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

Weitere ähnliche Inhalte

Was ist angesagt?

Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11
koolkampus
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
Ravi_Kant_Sahu
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
Laura Popovici
 

Was ist angesagt? (20)

Basics of Java Concurrency
Basics of Java ConcurrencyBasics of Java Concurrency
Basics of Java Concurrency
 
Decision Structures and Boolean Logic
Decision Structures and Boolean LogicDecision Structures and Boolean Logic
Decision Structures and Boolean Logic
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UML
 
Database connectivity to sql server asp.net
Database connectivity to sql server asp.netDatabase connectivity to sql server asp.net
Database connectivity to sql server asp.net
 
Java ppt
Java pptJava ppt
Java ppt
 
Map Reduce
Map ReduceMap Reduce
Map Reduce
 
Event Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdfEvent Driven programming(ch1 and ch2).pdf
Event Driven programming(ch1 and ch2).pdf
 
Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11
 
4+1 view model
4+1 view model4+1 view model
4+1 view model
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
Diagramas De Despligue Uml
Diagramas De Despligue UmlDiagramas De Despligue Uml
Diagramas De Despligue Uml
 
Exception handling
Exception handlingException handling
Exception handling
 
C# Generics
C# GenericsC# Generics
C# Generics
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-java
 
Assemblies
AssembliesAssemblies
Assemblies
 
Distributed architecture (SAD)
Distributed architecture (SAD)Distributed architecture (SAD)
Distributed architecture (SAD)
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 

Andere mochten auch

TASK SCHEDULING ON ADAPTIVE MULTI-CORE
TASK SCHEDULING ON ADAPTIVE MULTI-CORETASK SCHEDULING ON ADAPTIVE MULTI-CORE
TASK SCHEDULING ON ADAPTIVE MULTI-CORE
Haris Muhammed
 
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
Naoki Shibata
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
knowdiff
 
Multicore scheduling in automotive ECUs
Multicore scheduling in automotive ECUsMulticore scheduling in automotive ECUs
Multicore scheduling in automotive ECUs
RealTime-at-Work (RTaW)
 

Andere mochten auch (8)

Partitioning CCGrid 2012
Partitioning CCGrid 2012Partitioning CCGrid 2012
Partitioning CCGrid 2012
 
TASK SCHEDULING ON ADAPTIVE MULTI-CORE
TASK SCHEDULING ON ADAPTIVE MULTI-CORETASK SCHEDULING ON ADAPTIVE MULTI-CORE
TASK SCHEDULING ON ADAPTIVE MULTI-CORE
 
Wait-free data structures on embedded multi-core systems
Wait-free data structures on embedded multi-core systemsWait-free data structures on embedded multi-core systems
Wait-free data structures on embedded multi-core systems
 
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
 
Real time system in Multicore/Multiprocessor system
Real time system in Multicore/Multiprocessor systemReal time system in Multicore/Multiprocessor system
Real time system in Multicore/Multiprocessor system
 
Critical Chain Project Management
Critical Chain Project ManagementCritical Chain Project Management
Critical Chain Project Management
 
Multicore scheduling in automotive ECUs
Multicore scheduling in automotive ECUsMulticore scheduling in automotive ECUs
Multicore scheduling in automotive ECUs
 

Ähnlich wie C# Parallel programming

Dot net parallelism and multicore computing
Dot net parallelism and multicore computingDot net parallelism and multicore computing
Dot net parallelism and multicore computing
Aravindhan Gnanam
 
Parallel programming in modern world .net technics shared
Parallel programming in modern world .net technics   sharedParallel programming in modern world .net technics   shared
Parallel programming in modern world .net technics shared
IT Weekend
 

Ähnlich wie C# Parallel programming (20)

Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
 
Coding For Cores - C# Way
Coding For Cores - C# WayCoding For Cores - C# Way
Coding For Cores - C# Way
 
Migration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming ModelsMigration To Multi Core - Parallel Programming Models
Migration To Multi Core - Parallel Programming Models
 
Multi core programming 1
Multi core programming 1Multi core programming 1
Multi core programming 1
 
Parallel Computing-Part-1.pptx
Parallel Computing-Part-1.pptxParallel Computing-Part-1.pptx
Parallel Computing-Part-1.pptx
 
Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data Structures
 
Dot net parallelism and multicore computing
Dot net parallelism and multicore computingDot net parallelism and multicore computing
Dot net parallelism and multicore computing
 
Towards high performance computing(hpc) through parallel programming paradigm...
Towards high performance computing(hpc) through parallel programming paradigm...Towards high performance computing(hpc) through parallel programming paradigm...
Towards high performance computing(hpc) through parallel programming paradigm...
 
Parallel programming in modern world .net technics shared
Parallel programming in modern world .net technics   sharedParallel programming in modern world .net technics   shared
Parallel programming in modern world .net technics shared
 
Parallel Programming In Modern World .NET Technics
Parallel Programming In Modern World .NET TechnicsParallel Programming In Modern World .NET Technics
Parallel Programming In Modern World .NET Technics
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented Model
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Concurrency and Parallelism, Asynchronous Programming, Network Programming
Concurrency and Parallelism, Asynchronous Programming, Network ProgrammingConcurrency and Parallelism, Asynchronous Programming, Network Programming
Concurrency and Parallelism, Asynchronous Programming, Network Programming
 
MERIMeeting du 27 mai 2014 - Parallel Programming
MERIMeeting du 27 mai 2014 - Parallel ProgrammingMERIMeeting du 27 mai 2014 - Parallel Programming
MERIMeeting du 27 mai 2014 - Parallel Programming
 
Threads
ThreadsThreads
Threads
 
Concurrency and parallel in .net
Concurrency and parallel in .netConcurrency and parallel in .net
Concurrency and parallel in .net
 
Evolution of JDK Tools for Multithreaded Programming
Evolution of JDK Tools for Multithreaded ProgrammingEvolution of JDK Tools for Multithreaded Programming
Evolution of JDK Tools for Multithreaded Programming
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

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.
  • 5.
  • 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