1 / 8

Understanding Parallel Programming

`Parallel programming’ efficiently use all the cores and execute faster.Understanding Parallel Programming<br>

Download Presentation

Understanding Parallel Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction 1.Hardware industry rapidly shifting towards multiple-processor core technology. 2.Having multiple core in machine cannot expect  sequential program to run faster in machine. 3.For that purpose `Parallel programming’ is required which can efficiently use all the cores and execute faster.

  2. Feature Areas 1.Task Parallel Library(TPL) 2.Parallel LINQ

  3. Task Parallel Library - The easiest way to use parallel library is to use the same in parallel loops. - If you have a loop where every iteration is doing something expensive and loop iterations are independent. - Then Launch different iterations in parallel. The below block shows the sequential - It can be paralleled by using TPL by following code.

  4. Parallel LINQ - Parallel LINQ(PLINQ) is a query execution engine. - It accepts only LINQ-to-Objects or LINQ-to-XML query. - It automatically utilizes multiple processor or cores for execution when they are available. - With PLINQ you can transform your LINQ queries to parallel version by using the As Parallel extension method as shown below.

  5. -Take ray-tracer algorithm sample to render image with both sequential and parallel programming.- Compare the execution time in both scenarios.- Img1 shows image rendering through sequential program and the bottom right of img1 shows the time taken to execute. Img1: Rendering Image through Sequential Program Img2: Rendering Image through Parallel Program

  6. - It is clear from the above sample images that parallel execution is 1.5 seconds faster than the sequential rendering.- Lets see how the processor core has been consumed in both scenarios using performance monitor tool. In the above  Parallel programming Graph we can see all the core of the processor are equally utilized. In the sequential programming graph we can observe only processor core one, highlighted with red mark, has been utilizing more and rest are least utilized.

  7. Conclusion There are many ways to create a parallel executing program in C#. With multi-core processor there’s no excuse for creating a single threaded programs and penalize your users with unneeded delays.

More Related