Multi-core CPUs - Why does not my application use all processor cores?

16

I have a question that I can not find a convincing answer.

There is an application developed in Delphi 7, and in an extremely complex routine (which takes about 2 hours) we noticed that only the first processor core is used, in this case an Intel Core-i7 (8 core) , and the other cores remain idle (at least that's what the Windows feature monitor demonstrates).

Regarding this I have several questions, the main ones being the following:

  • Why does this occur?
  • Is this a problem with Delphi 7, or Delphi?
  • Can this be resolved using Delphi 7?
  • Other technology such as .net and Java, are already prepared to efficiently use Multi-core CPUs?
  • In case of other technology such as .net and Java. Is it necessary to do something in the application or will it already occur automatically and managed by the Framework?
asked by anonymous 23.06.2015 / 21:06

2 answers

10

Serial Algorithm vs. Parallel Algorithm

In order to solve your problem, you will need to change your algorithm.

Today what you have is an application that runs all its logic on a single thread that will be run by a single processor. This is called a serial algorithm or sequential.

What it means to say that all of your logic runs sequentially. You would have to rewrite part of your application by splitting it into subtasks - subtasks, and handing them to threads - this would be the parallel algorithm. An addendum can not parallelize your entire algorithm, you can only divide up to a certain point.

The number of threads must be the number of processors available, and for each thread you submit your tasks. Each thread is executed by a processor. Do not confuse parallel computing with concurrent programming.

  

Other technology such as .net and Java are already ready to use   to efficiently multi-core CPUs?

Java has always provided APIs and frameworks for concurrent programming and parallel computing. From Java 1.5 a framework called Executor Framework has been added. It provides several utilitarian classes, interfaces, methods for manufacturing Thread Pools, and methods of submitting tasks.

In Java 1.7 we have already won the Fork / Join framework . By allowing you to program an algorithm by setting Thresholds , which are boundaries, when this threshold is reached you want the task in two-fork. Once it is executed and the other tasks are completed, you make the joys of them for the end result. Interestingly, this framework implements an algorithm called work-stealing . This is a technique where when a thread finishes executing its task it steals the task from another thread that has not yet finished its execution.

Last but not least

If you take on the project of migrating a new execution template, I recommend that you study the Amdahl's law that predicts the maximum amount of time it is possible to optimize a program using multiple processors.

Sources: Serial Algorithm: link

Parallel algorithm: link

Parallel computing: link

    
24.06.2015 / 19:23
0

Explaining a WELL shape simplified the differences between execution models:

Multitasking:

  • Multiple processes in a kernel.
  • Run concurrently.

Multiprocessing:

  • Multiplemulti-coreprocesses.
  • Runinparallel

Multithreading :

  • A process using multiple threads.
  • Computing is split between cores
  • PS: (Will run in parallel or not, depends on your code and hardware)

    
30.06.2015 / 14:50