Optimizing Multi-Threaded Applications on the Itanium 2 (Part 1)

22. January 2007 12:59 by Csaborio in General  //  Tags:   //   Comments (0)

If the tasks that your application carries out are independent of each other, a way to optimize things is to create threads for various tasks.  There are many ways to thread applications including Pthreads, windows threading, and recently OpenMP.  OpenMP excels in the sense that it can make your application multi-threaded by just writing a few pragmas here and there.

Once you multi-thread your application, many things can go astray.  For instance, different threads can access variables at different intervals in a loop, which can only lead to disastrous results in your calculations.  You can break your head and lose some of your sanity by manually debugging what is going wrong with your application or you can use Intel's thread checker to find out what is going on.  For instance, the following sceenshot shows you the output of all the problems (referred to as data races) when various threads were accessing variables and changing them on each loop:

ZZ209DC9B6

 

Furthermore, your application's threads might starve waiting for a particular resource to be freed, which can only make the whole multi-threading effort futile.  Tools like Intel's thread profiler can help you find this info.  For example, after data collection, based on the following screenshot, you can pretty much tell that due to locks in the code, the threads are pretty much stalling the application:

ZZ3BEA36A3

 

Now that you know what these two tools are and what they do, what I wanted to show you was how to get around the fact that none of these tools can be installed on a Itanium box.  That is, now that the Itanium is dual-core, how do you go about optimizing multi-threaded apps using these tools?   The solution to this problem will be included in the second part of this post, stay tuned!