Understanding the benefits (and pitfalls) of parallel programming C#. NET

Parallel computing is, at heart, a performance play. The work that a program performs is broken up into pieces, which are performed by multiple cores, processors, or computers. Some of those pieces of work will be performed at the same time, that is, in parallel, or concurrently, which is where the two key terms for this kind of programming arise. Writing the code that breaks up and arranges for parallel computing is called parallel programming.

If you have a multicore or multi-processor machine, spreading the pieces of work across them can reduce the amount of time to complete the work overall. The key phrase here is can reduce; there are some caveats that you should be aware.

  • ConsideringOverhead
  • Coordinating Data
  • Scaling Applications

Considering Overhead
Parallel execution doesn’t come for free. There are overhead costs associated with setting up and managing parallel programming features. If you have only a small amount of work to perform, the overhead can outweigh the performance benefit.

Coordinating Data
Applying coordination is not hard, but applying just the right amount is a trick that comes with forethought and experience. Too much coordination compromises the performance of your parallel program; too little gets you unexpected results.

Scaling Applications
Adding a second core or CPU might increase the performance of your parallel program, but it is unlikely to double it. Likewise, a four-core machine is not going to execute your parallel program four times as quickly — in part because of the overhead and coordination described in the previous sections. However, the design of the computer hardware also limits its ability to scale. You can expect a significant improvement in performance, but it won’t be 100 percent per additional core, and there will almost certainly be a point at which adding additional cores or CPUs doesn’t improve the performance at all.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C#. NET Topics