|
Nickname: n_raj
Articles(8)
Visits(14152)
Comments(1)
Votes(1)
|
|
| I have over two decades of experience in the software industry. I have worked extensively in product engineering focusing on system software, embedded and networking technologies. I am currently working as product management consultant in a startup. I was till recently VP in the R&D Services business unit of MindTree. Prior to MindTree, I was with Wipro’s R&D. My other interests include photography and traveling. | ||
| Blog Archive: 2011 - Dec., Apr. 2010 - Jul., May., Mar., Feb., Jan. |
View All | |
Posted: 03:58:40 PM, 12/03/2010
OpenMP and multicore |
|---|
Dear Readers, In the last article, we saw about the so called “embrassingly parallel operations” which can easily take advantage of multicore systems. In this article, let us see one more way of getting performance improvements on multicore systems. OpenMP is one of them.
OpenMP specifications was originally defined by industry vendors like Sun, Intel in 1997. It was popular in Symmetric Multiprocessing (SMP) systems. A typical SMP system is a multiprocessor computer hardware where two or more identical processors are connected to a single shared memory and are all processors run same OS instance.
Surprisingly, today's multicore systems are similar to the SMP architecture. Instead of multiple processors, we have multiple cores. All cores access the common shared memory and run same OS instance. That is why, a solution like OpenMP which is from SMP era is suddenly finding a renewed interest in the multicore systems of today.
The OpenMP specification is defined for C/C++/Fortran languages. It consists of three parts: compiler directives, runtime library and environment variables. The code is instrumented with directives and it gets compiled with the openMP supported compiler. The code is linked with the runtime library for generating the executable. There are some runtime environment variables that control the code execution.
An OpenMP program works like this:
Since the process of creation, starting and joining of threads is done automatically, programmers are relieved of the complexities. The model also allows variables to be locked and shared between the threads and supports fairly advanced features. Here is an example code from Wikipedia:
int main(int argc, char **argv) {
As first step, the code is compiled with OpenMP enabled compiler. An environment variable, something like OMP_NUM_THREADS is set to the number of threads and the program is executed. Suppose, OMP_NUM_THREADS is set to 4. Code starts normally, but when it reaches the for loop, it creates 4 threads, and each thread does the matrix multiplication for 100000/4=25000 different entries. This speeds up the processing as four threads work in parallel, on different cores. As we keep increasing the the value of OMP_NUM_THREADS, one could see a decrease in time and improvement in performance, till system bus bottlenecks start showing up. The advantages of the openMP include:
Main disadvantage of OpenMP is that it needs specific tool chains (compilers, runtime). Not all compiler tool chains support OpenMP. Popular ones include Sun Studio tool chain and GNU 4.3.1.
OpenMP can get a big performance improvement on a multicore systems as each thread can run on each core separately and hence translates to better performance.
Then why OpenMP is not so well known in mainstream? It is because OpenMP gives big performance gains to mainly mathematical and scientific computing needs like large matrix multiplications. For a desktop application or server application, OpenMP may not be of great help unless the application logic has such code.
|
Have Your Say!
Got something to say? Why not share itwith other engineers?

Looking for parts to specify for your design project? Browse our library of datasheets NOW!
Posted:15/05/12 05:07 PM
• Do you have a hobby?
Posted:03/05/12 07:22 PM
Posted:15/05/12 05:58 PM
• Clipix: The tool we've all been waiting for?
Posted:11/05/12 03:27 PM
Posted:30/12/11 08:25 PM
• SmartGrids - what do they have to offer?
Posted:27/12/11 06:07 PM
Posted:09/05/12 12:49 PM
• Do new technologies simplify small-scale prod...
Posted:23/04/12 08:44 PM
















