Multi-core machines are dominant these days and one could easily find machines with multicore by default. Do we have to change the way we write programs? Wouldn’t running my program on a multi-core machine automatically improve performance? After all aren’t there more threads?
The answer is no! Running a program on a multi-core machine has nearly zero performance enhancements. With the exception of IO operations, your program will still use one thread of a single core at a time. Thread switching occurs – which by the way incurs overheads but at all times, only one thread will be active
What does multithreading have to do with multi-cores? Can’t we write multi-threaded codes if we have a single core? Yes, we can. But again, as long as we have a single core, only one thread at a time will work since all threads belong to that same single core… logical enough. When your multi-threaded program runs on a multi-core machine, threads belonging to different cores will be able to run together and hence your program will take advantage of the hardware power.
It is useful to point out the difference between traditional multithreading and parallel programming. In the past, most computers had a single CPU and multithreading was used to take advantage of idle time, such as when a program blocks for user input. Using this approach, one thread can be executed while another is waiting. On a single-CPU system, multithreading is used to allow two or more tasks to share the CPU. Although this type of multithreading will remain useful, it was not designed for situations in which two or more CPUs are available.
When multiple CPUs are present, a second type of multithreading capability is needed because it is possible to execute portions of a program simultaneously, with each part executing on its own CPU. This can be used to significantly speed up the execution of some types of operations, such as sorting, transforming, or searching a large array.
Microsoft .NET 4 comes with a host of new features that makes enterprise application development more productive and manageable. .NET has had support for parallel programming since version 1.0, now referred to as classic threading, but it was hard to use effectively and made you think too much about managing multiple threads of the parallel aspects of your program, which detracts from focusing on what needs to be done.
While developing and running with custom applications using Microsoft .NET platform, there are many challenges observed across enterprises, however it is not exhaustive. One of them would be
With this article, I intended to bring to your notice that, each one of us needs to understand and start using this knowledge in applications. Going forward all servers will have multicore and we will not use that multicore power unless we consider this while development.
There are some cautions that we should be aware of.
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.
If your pieces of work share common data or need to work in a concerted manner, you will need to provide coordination. As a general rule, the more coordination leads, the poorer the performance of your parallel program.
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. 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.
Rishabh Software, a CMMI Level-3 technology company, focuses on cost-effective, qualitative and timely delivered Software Development, Business Process Outsourcing (BPO) and Engineering Services.
Get a Free ConsultationContact us for cost-effective and qualitative Software Development services.