SlideShare a Scribd company logo
DOT NET PARALLELISM & MULTICORE COMPUTING
BY
ARAVINDHAN G
OMNIEXTRACT TEAM
GENESIS GROUP
Why parallelism?
What is parallelism?
Types of parallelism in C#
Data Parallelism
Parallel Loops
Task Parallelism
2
AGENDA
3
Why Parallelism?
 Don’t expect your sequential program to run faster on new
processors.
 Still, processor technology advances
 BUT the focus now is on multiple cores per chip
 Today’s desktops typically have 4 cores
 The multi-core revolution puts pressure on software developers
to use parallelism if they want to benefit from future hardware
improvements
4
The Free Lunch is over
 Parallelism means that a programming task can be split into
parts that can be run on several networked processors or
computers.
 Parallel computing is a form of computation in which many
calculations are carried out simultaneously, operating on the
principle that large problems can often be divided into smaller
ones, which are then solved concurrently ("in parallel").
5
What is parallelism?
C# supports two main models of parallelism:
• Data parallelism: where an operation is applied to each
element in a collection.
• Task parallelism: where independent computations are
executed in parallel.
6
Types of Parallelism in C#
A sequential for loop in C#:
int n = ...
for (int i = 0; i<=n; i++)
{
// ...
}
A parallel for loop in C#:
int n = ...
Parallel.For(0, n, i =>
{
// ...
});
7
Parallel Loops in C#
 The language construct for is translated into a
(higher-order) function Parallel.For.
 The argument to Parallel.For is an anonymous method,
specifying the code to be performed in each loop
iteration.
 The arguments to this anonymous method are the start
value, the end value and the iteration variable.
8
Parallel Loops in C#
We can limit the degree of parallelism like this:
var options = new ParallelOptions() {
MaxDegreeOfParallelism = 2 };
Parallel.For(0, n, options, i =>
{
fibs[i] = Fib(i);
});
9
A Simple Example
 Parallel loops have two ways to break or stop a loop
instead of just one.
 Parallel break, loopState.Break(), allows all steps with
indices lower than the break index to run before
terminating the loop.
 Parallel stop, loopState.Stop(), terminates the loop
without allowing any new steps to begin.
10
Terminating a Parallel Loop
 The parallel aggregate pattern combines data
parallelism over a collection, with the aggregation of the
result values to an overall result.
 It is parameterized both over the operation on each
element as well as the combination (aggregation) of the
partial results to an overall results.
An Example of Parallel Aggregates:
var options = new ParallelOptions() {
MaxDegreeOfParallelism = k};
Parallel.ForEach(seq /* sequence */, options,
() => 0, // The local initial partial result
// The loop body
});
11
Parallel Aggregates
 When independent computations are started in different
tasks, we use a model of task parallelism.
 This model is more general than data parallelism, but
requires more detailed control of synchronization and
communication.
 The most basic construct for task parallelism is:
Parallel.Invoke(DoLeft, DoRight);
 It executes the methods DoLeft and DoRight in parallel,
and waits for both of them to finish.
12
Task Parallelism in C#
The following code sorts 2 lists in parallel, providing a
comparison operation as an argument:
Parallel.Invoke( // generate two parallel threads
() => ic1.Sort(cmp_int_lt),
() => ic2.Sort(cmp_int_gt));
13
Example of Task Parallelism
 The implementation of Invoke uses the more basic
constructs
StartNew, for starting a computation;
Wait, WaitAll, WaitAny, for synchronising several
computations.
 Any shared data structure needs to be protected with
locks, semaphores or such.
 Programming on this level is similar to explicitly
managing threads:
it can be more efficient
it is error-prone.
14
Implementation of Task Parallelism
static void SequentialQuickSort(int[] array, int from, int to)
{
if (to - from <= Threshold)
{
InsertionSort(array, from, to);
}
else
{
int pivot = from + (to - from) / 2;
pivot = Partition(array, from, to, pivot);
SequentialQuickSort(array, from, pivot - 1);
SequentialQuickSort(array, pivot + 1, to);
}
}
15
Example: Sequential Code
static void ParallelQuickSort(int[] array, int from, int to, int depthRemaining)
{
if (to - from <= Threshold)
{
InsertionSort(array, from, to);
}
else
{
int pivot = from + (to - from) / 2;
pivot = Partition(array, from, to, pivot);
if (depthRemaining > 0)
{
Parallel.Invoke(
() => ParallelQuickSort(array, from, pivot - 1,
depthRemaining - 1),
() => ParallelQuickSort(array, pivot + 1, to,
depthRemaining - 1));
}
else
{
ParallelQuickSort(array, from, pivot - 1, 0);
ParallelQuickSort(array, pivot + 1, to, 0);
}
}
}
16
Example: Parallel Code
 The preferred, high-level way of coding parallel
computation in C# is through parallel patterns, an
instance of design patterns.
 Parallel patterns capture common patterns of parallel
computation.
 Two main classes of parallelism exist:
Data parallelism, which is implemented through parallel
For/Foreach loops.
Task parallelism, which is implemented through parallel
method invocation.
 Tuning the parallel performance often requires code
restructuring.
17
Summary
Any queries?
Thank You

More Related Content

What's hot

Lesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentLesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignment
PVS-Studio
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
kiran Patel
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
Ravikiran A
 
Dynamic Memory Allocation
Dynamic Memory AllocationDynamic Memory Allocation
Dynamic Memory Allocation
vaani pathak
 
16 dynamic-memory-allocation
16 dynamic-memory-allocation16 dynamic-memory-allocation
16 dynamic-memory-allocation
Rohit Shrivastava
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
Manish Joshi
 
C dynamic ppt
C dynamic pptC dynamic ppt
C dynamic ppt
RJ Mehul Gadhiya
 
Parallel programming Comparisions
Parallel programming ComparisionsParallel programming Comparisions
Parallel programming Comparisions
Muhammad Bilal Khan
 
MATLAB/SIMULINK for engineering applications: day 3
MATLAB/SIMULINK for engineering applications: day 3MATLAB/SIMULINK for engineering applications: day 3
MATLAB/SIMULINK for engineering applications: day 3
reddyprasad reddyvari
 
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
Srinivasan Raghvan
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
Buxoo Abdullah
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)
Kamal Acharya
 
Data structure stack&queue basics
Data structure stack&queue   basicsData structure stack&queue   basics
Data structure stack&queue basics
Selvin Josy Bai Somu
 
Java.util.concurrent.concurrent hashmap
Java.util.concurrent.concurrent hashmapJava.util.concurrent.concurrent hashmap
Java.util.concurrent.concurrent hashmap
Srinivasan Raghvan
 
Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3
Mohamed Awni
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
Ameen San
 
Stack & heap
Stack & heap Stack & heap
Stack & heap
Shajahan T S Shah
 
ACM init()- Day 4
ACM init()- Day 4ACM init()- Day 4
PRAM algorithms from deepika
PRAM algorithms from deepikaPRAM algorithms from deepika
PRAM algorithms from deepika
guest1f4fb3
 

What's hot (20)

Lesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentLesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignment
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Dynamic Memory Allocation
Dynamic Memory AllocationDynamic Memory Allocation
Dynamic Memory Allocation
 
16 dynamic-memory-allocation
16 dynamic-memory-allocation16 dynamic-memory-allocation
16 dynamic-memory-allocation
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
 
C dynamic ppt
C dynamic pptC dynamic ppt
C dynamic ppt
 
Parallel programming Comparisions
Parallel programming ComparisionsParallel programming Comparisions
Parallel programming Comparisions
 
MATLAB/SIMULINK for engineering applications: day 3
MATLAB/SIMULINK for engineering applications: day 3MATLAB/SIMULINK for engineering applications: day 3
MATLAB/SIMULINK for engineering applications: day 3
 
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Introduction to c part -3
 
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)
 
Data structure stack&queue basics
Data structure stack&queue   basicsData structure stack&queue   basics
Data structure stack&queue basics
 
Java.util.concurrent.concurrent hashmap
Java.util.concurrent.concurrent hashmapJava.util.concurrent.concurrent hashmap
Java.util.concurrent.concurrent hashmap
 
Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3Matlab HTI summer training course Lecture3
Matlab HTI summer training course Lecture3
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Stack & heap
Stack & heap Stack & heap
Stack & heap
 
ACM init()- Day 4
ACM init()- Day 4ACM init()- Day 4
ACM init()- Day 4
 
PRAM algorithms from deepika
PRAM algorithms from deepikaPRAM algorithms from deepika
PRAM algorithms from deepika
 

Viewers also liked

My englishfriends cas
My englishfriends casMy englishfriends cas
My englishfriends cas
rafaeljoseaguayo
 
Start-up Battlefield in the Middle East
Start-up Battlefield in the Middle EastStart-up Battlefield in the Middle East
Start-up Battlefield in the Middle East
Youngberry, Youth Marketing Agency
 
Technology[1]
Technology[1]Technology[1]
Technology[1]
rloudermilk3
 
Arany kezek(36) ani (nx power lite)
Arany kezek(36) ani (nx power lite)Arany kezek(36) ani (nx power lite)
Arany kezek(36) ani (nx power lite)
VarganeAnny
 
心肌梗塞急救法
心肌梗塞急救法心肌梗塞急救法
心肌梗塞急救法chengchunhao
 
EME2040 Project VI, Part III
EME2040 Project VI, Part IIIEME2040 Project VI, Part III
EME2040 Project VI, Part III
John Hayes
 
List Growth In the Shadow of CASL (Canada Anti-Spam Law)
List Growth In the Shadow of CASL (Canada Anti-Spam Law)List Growth In the Shadow of CASL (Canada Anti-Spam Law)
List Growth In the Shadow of CASL (Canada Anti-Spam Law)
Care2Team
 
Parenting U: Toddler Behavior
Parenting U: Toddler BehaviorParenting U: Toddler Behavior
Ipad Usability 2nd Edition
Ipad Usability 2nd EditionIpad Usability 2nd Edition
Ipad Usability 2nd Edition
jamiewaltz
 
Tour Ancient Mexico!
Tour Ancient Mexico!Tour Ancient Mexico!
Tour Ancient Mexico!
LibraryLeroy
 
ICE President Apprentices 2006-07
ICE President Apprentices 2006-07ICE President Apprentices 2006-07
ICE President Apprentices 2006-07
katfyt
 
Conductedwork
ConductedworkConductedwork
Conductedwork
Prashant Sharma
 
Minden, ami szép(5) (nx power lite)+ani
Minden, ami szép(5) (nx power lite)+aniMinden, ami szép(5) (nx power lite)+ani
Minden, ami szép(5) (nx power lite)+aniVarganeAnny
 
How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...
How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...
How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...
ReachOut Pro
 
Protests past and present
Protests past and presentProtests past and present
Protests past and present
vanessaftok
 
Catalog dental-general
Catalog dental-generalCatalog dental-general
Catalog dental-general
MIGUEL CHAVEZ
 
Parenting U: Child Nutrition - Recipes
Parenting U: Child Nutrition - RecipesParenting U: Child Nutrition - Recipes
Parenting U: Child Nutrition - Recipes
Providence Health & Services Southwest Washington
 

Viewers also liked (20)

My englishfriends cas
My englishfriends casMy englishfriends cas
My englishfriends cas
 
Sant jordi
Sant jordiSant jordi
Sant jordi
 
Start-up Battlefield in the Middle East
Start-up Battlefield in the Middle EastStart-up Battlefield in the Middle East
Start-up Battlefield in the Middle East
 
Technology[1]
Technology[1]Technology[1]
Technology[1]
 
Arany kezek(36) ani (nx power lite)
Arany kezek(36) ani (nx power lite)Arany kezek(36) ani (nx power lite)
Arany kezek(36) ani (nx power lite)
 
心肌梗塞急救法
心肌梗塞急救法心肌梗塞急救法
心肌梗塞急救法
 
EME2040 Project VI, Part III
EME2040 Project VI, Part IIIEME2040 Project VI, Part III
EME2040 Project VI, Part III
 
List Growth In the Shadow of CASL (Canada Anti-Spam Law)
List Growth In the Shadow of CASL (Canada Anti-Spam Law)List Growth In the Shadow of CASL (Canada Anti-Spam Law)
List Growth In the Shadow of CASL (Canada Anti-Spam Law)
 
Parenting U: Toddler Behavior
Parenting U: Toddler BehaviorParenting U: Toddler Behavior
Parenting U: Toddler Behavior
 
Ipad Usability 2nd Edition
Ipad Usability 2nd EditionIpad Usability 2nd Edition
Ipad Usability 2nd Edition
 
Tour Ancient Mexico!
Tour Ancient Mexico!Tour Ancient Mexico!
Tour Ancient Mexico!
 
ICE President Apprentices 2006-07
ICE President Apprentices 2006-07ICE President Apprentices 2006-07
ICE President Apprentices 2006-07
 
Conductedwork
ConductedworkConductedwork
Conductedwork
 
Minden, ami szép(5) (nx power lite)+ani
Minden, ami szép(5) (nx power lite)+aniMinden, ami szép(5) (nx power lite)+ani
Minden, ami szép(5) (nx power lite)+ani
 
How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...
How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...
How to provide 24/7 support in a 9-5 work day: the benefit of e-mental health...
 
Protests past and present
Protests past and presentProtests past and present
Protests past and present
 
17 dsp dunia muzik tahun 3 5 feb 2013
17 dsp dunia muzik tahun 3   5 feb 201317 dsp dunia muzik tahun 3   5 feb 2013
17 dsp dunia muzik tahun 3 5 feb 2013
 
Catalog dental-general
Catalog dental-generalCatalog dental-general
Catalog dental-general
 
Parenting U: Child Nutrition - Recipes
Parenting U: Child Nutrition - RecipesParenting U: Child Nutrition - Recipes
Parenting U: Child Nutrition - Recipes
 
差異是祝福
差異是祝福差異是祝福
差異是祝福
 

Similar to Dot net parallelism and multicore computing

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
Zvi Avraham
 
C# Parallel programming
C# Parallel programmingC# Parallel programming
C# Parallel programming
Umeshwaran V
 
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CLIRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET Journal
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
Neeraj Kaushik
 
Code Tuning
Code TuningCode Tuning
Code Tuning
guest4df97e3d
 
Parallel computing and its applications
Parallel computing and its applicationsParallel computing and its applications
Parallel computing and its applications
Burhan Ahmed
 
Modern processors
Modern processorsModern processors
Modern processors
gowrivageesan87
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
Roman Okolovich
 
Parallel Computing
Parallel ComputingParallel Computing
Parallel Computing
Ameya Waghmare
 
Complier design
Complier design Complier design
Complier design
shreeuva
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
Dhammpal Ramtake
 
Lecture18-19 (1).ppt
Lecture18-19 (1).pptLecture18-19 (1).ppt
Lecture18-19 (1).ppt
ssuserf67e3a
 
Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP
Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP
Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP
IJCSEIT Journal
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
Information Technology Center
 
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
Prabu U
 
Unit2-Part2-MultithreadAlgos.pptx.pdf
Unit2-Part2-MultithreadAlgos.pptx.pdfUnit2-Part2-MultithreadAlgos.pptx.pdf
Unit2-Part2-MultithreadAlgos.pptx.pdf
Vinayak247538
 
parellel computing
parellel computingparellel computing
parellel computing
katakdound
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
kshanth2101
 
Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62
Max Kleiner
 
Distributed Radar Tracking Simulation Project
Distributed Radar Tracking Simulation ProjectDistributed Radar Tracking Simulation Project
Distributed Radar Tracking Simulation Project
Assignmentpedia
 

Similar to Dot net parallelism and multicore computing (20)

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
 
C# Parallel programming
C# Parallel programmingC# Parallel programming
C# Parallel programming
 
IRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CLIRJET- Latin Square Computation of Order-3 using Open CL
IRJET- Latin Square Computation of Order-3 using Open CL
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
Code Tuning
Code TuningCode Tuning
Code Tuning
 
Parallel computing and its applications
Parallel computing and its applicationsParallel computing and its applications
Parallel computing and its applications
 
Modern processors
Modern processorsModern processors
Modern processors
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
 
Parallel Computing
Parallel ComputingParallel Computing
Parallel Computing
 
Complier design
Complier design Complier design
Complier design
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
Lecture18-19 (1).ppt
Lecture18-19 (1).pptLecture18-19 (1).ppt
Lecture18-19 (1).ppt
 
Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP
Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP
Performance Analysis of Parallel Algorithms on Multi-core System using OpenMP
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
 
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
 
Unit2-Part2-MultithreadAlgos.pptx.pdf
Unit2-Part2-MultithreadAlgos.pptx.pdfUnit2-Part2-MultithreadAlgos.pptx.pdf
Unit2-Part2-MultithreadAlgos.pptx.pdf
 
parellel computing
parellel computingparellel computing
parellel computing
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
 
Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62
 
Distributed Radar Tracking Simulation Project
Distributed Radar Tracking Simulation ProjectDistributed Radar Tracking Simulation Project
Distributed Radar Tracking Simulation Project
 

Recently uploaded

Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 

Recently uploaded (20)

Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 

Dot net parallelism and multicore computing

  • 1. DOT NET PARALLELISM & MULTICORE COMPUTING BY ARAVINDHAN G OMNIEXTRACT TEAM GENESIS GROUP
  • 2. Why parallelism? What is parallelism? Types of parallelism in C# Data Parallelism Parallel Loops Task Parallelism 2 AGENDA
  • 4.  Don’t expect your sequential program to run faster on new processors.  Still, processor technology advances  BUT the focus now is on multiple cores per chip  Today’s desktops typically have 4 cores  The multi-core revolution puts pressure on software developers to use parallelism if they want to benefit from future hardware improvements 4 The Free Lunch is over
  • 5.  Parallelism means that a programming task can be split into parts that can be run on several networked processors or computers.  Parallel computing is a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently ("in parallel"). 5 What is parallelism?
  • 6. C# supports two main models of parallelism: • Data parallelism: where an operation is applied to each element in a collection. • Task parallelism: where independent computations are executed in parallel. 6 Types of Parallelism in C#
  • 7. A sequential for loop in C#: int n = ... for (int i = 0; i<=n; i++) { // ... } A parallel for loop in C#: int n = ... Parallel.For(0, n, i => { // ... }); 7 Parallel Loops in C#
  • 8.  The language construct for is translated into a (higher-order) function Parallel.For.  The argument to Parallel.For is an anonymous method, specifying the code to be performed in each loop iteration.  The arguments to this anonymous method are the start value, the end value and the iteration variable. 8 Parallel Loops in C#
  • 9. We can limit the degree of parallelism like this: var options = new ParallelOptions() { MaxDegreeOfParallelism = 2 }; Parallel.For(0, n, options, i => { fibs[i] = Fib(i); }); 9 A Simple Example
  • 10.  Parallel loops have two ways to break or stop a loop instead of just one.  Parallel break, loopState.Break(), allows all steps with indices lower than the break index to run before terminating the loop.  Parallel stop, loopState.Stop(), terminates the loop without allowing any new steps to begin. 10 Terminating a Parallel Loop
  • 11.  The parallel aggregate pattern combines data parallelism over a collection, with the aggregation of the result values to an overall result.  It is parameterized both over the operation on each element as well as the combination (aggregation) of the partial results to an overall results. An Example of Parallel Aggregates: var options = new ParallelOptions() { MaxDegreeOfParallelism = k}; Parallel.ForEach(seq /* sequence */, options, () => 0, // The local initial partial result // The loop body }); 11 Parallel Aggregates
  • 12.  When independent computations are started in different tasks, we use a model of task parallelism.  This model is more general than data parallelism, but requires more detailed control of synchronization and communication.  The most basic construct for task parallelism is: Parallel.Invoke(DoLeft, DoRight);  It executes the methods DoLeft and DoRight in parallel, and waits for both of them to finish. 12 Task Parallelism in C#
  • 13. The following code sorts 2 lists in parallel, providing a comparison operation as an argument: Parallel.Invoke( // generate two parallel threads () => ic1.Sort(cmp_int_lt), () => ic2.Sort(cmp_int_gt)); 13 Example of Task Parallelism
  • 14.  The implementation of Invoke uses the more basic constructs StartNew, for starting a computation; Wait, WaitAll, WaitAny, for synchronising several computations.  Any shared data structure needs to be protected with locks, semaphores or such.  Programming on this level is similar to explicitly managing threads: it can be more efficient it is error-prone. 14 Implementation of Task Parallelism
  • 15. static void SequentialQuickSort(int[] array, int from, int to) { if (to - from <= Threshold) { InsertionSort(array, from, to); } else { int pivot = from + (to - from) / 2; pivot = Partition(array, from, to, pivot); SequentialQuickSort(array, from, pivot - 1); SequentialQuickSort(array, pivot + 1, to); } } 15 Example: Sequential Code
  • 16. static void ParallelQuickSort(int[] array, int from, int to, int depthRemaining) { if (to - from <= Threshold) { InsertionSort(array, from, to); } else { int pivot = from + (to - from) / 2; pivot = Partition(array, from, to, pivot); if (depthRemaining > 0) { Parallel.Invoke( () => ParallelQuickSort(array, from, pivot - 1, depthRemaining - 1), () => ParallelQuickSort(array, pivot + 1, to, depthRemaining - 1)); } else { ParallelQuickSort(array, from, pivot - 1, 0); ParallelQuickSort(array, pivot + 1, to, 0); } } } 16 Example: Parallel Code
  • 17.  The preferred, high-level way of coding parallel computation in C# is through parallel patterns, an instance of design patterns.  Parallel patterns capture common patterns of parallel computation.  Two main classes of parallelism exist: Data parallelism, which is implemented through parallel For/Foreach loops. Task parallelism, which is implemented through parallel method invocation.  Tuning the parallel performance often requires code restructuring. 17 Summary