Kernels (or processors) are the physical elements of your computer that execute code. Usually each core has all the necessary elements for performing calculations, registering files, interrupt lines, etc.
Most operating systems present applications as processes . This means that the application has its own address space (== memory view), where the OS ensures that this view and its contents are isolated from other applications.
A process consists of one or more threads that perform the actual work of the application by executing machine code on the CPU. The operating system determines which thread runs on which CPU (using smart heuristics to improve load balance, power consumption, etc.). If your application consists of only one thread, then your entire multiprocessor system will not help you, since it will use only one processor for your application. (However, overall performance may still improve, since the OS will run other applications on different processors so that they do not mix with the first).
Now to your specific questions:
1) The OS usually allows you to at least give hints about which kernel you want to execute certain threads on. What OpenMP does is generate code that generates a certain number of threads to distribute the total computing work from your program's loops into multiple threads. He can use the OS prompt tool (see: Thread Affinity) for this. However, OpenMP applications will still run simultaneously with others, and therefore, the OS may interrupt one of the threads and schedule other (potentially unrelated) work with the CPU. In fact, there are many different planning schemes that you might want to apply depending on your situation, but this is very specific, and most of the time you need to be sure that your operating system will do the right thing for you.
2) Even if you use a single-threaded application on a multi-core processor, you will notice that other processors also work. This happens: a) from the OS that does its work, and b) due to the fact that your application never starts alone - each working system consists of a whole group of simultaneously performing tasks. Check Windows Task Manager (or ps / top on Linux) to see if it works.
BjoernD Jun 07 '10 at 6:23 2010-06-07 06:23
source share