1.4. Automatic instrumentation using TAU Compiler

For this section of the tutorial we will be using the files found in the examples/taututorial directory of the tau distribution. To start, there are two files of note: computePi.cpp and Makefile. computePi.cpp is a C++ program that uses an MPI client-server model to estimate the value of Pi. The server accepts requests for random numbers from the clients, and returns an array of random numbers to the clients. The clients use these values to estimate Pi using a dart-throwing method. When the clients have converged to a satisfactory tolerance, they signal their completion to the server and the program exits.

Build computePi.cpp as you would any c++ mpi application.

%> mpicxx -c computePi.cpp -o computePi.o
%> mpicxx computePi.o -o computePi
    

Test the program in your MPI environment. For mpich, the command might be

%> mpirun -np 5 ./computePi
Pi is 3.14226

to run the program on 5 nodes. Note that this program requires at least two nodes to be running! Once you've confirmed that the program ran successfully, try timing it to get a sense of how long it takes to run.

%> time mpirun -np 5 ./computePi
Pi is 3.14226

real    0m2.012s
user    0m1.570s
sys     0m0.330s

Now let us rebuild computePi to be instrumented with tau. First we need to tell TAU which instrumentation library to use by setting the environment variable TAU_MAKEFILE to the location of the tau makefile, for example:

%> export TAU_MAKEFILE=/home/users/hoge/tau2/ia64/lib/Makefile.tau-mpi-pdt
%> tau_cxx.sh -c computePi.cpp -o computePi.o
%> tau_cxx.sh computePi.o -o computePi

Assuming that all goes well, the computePi program will have been automatically built with TAU instrumentation. Run the program as you would any MPI program, i.e.

%> time mpirun -np 5 ./computePi
Pi is 3.14226

real    0m2.123s
user    0m1.760s
sys     0m0.270s

TAU generates a profile file for every node the program is run on. You can see these files by doing a directory listing.

%> ls profile*
profile.0.0.0  profile.1.0.0  profile.2.0.0  
profile.3.0.0  profile.4.0.0

Now you're ready to view the output of TAU. If you've added the TAU binary directory to your path you can launch the TAU profile viewer, Paraprof.

%> paraprof

Enjoy exploring the performance data displayed by Paraprof. A complete description of how to use Paraprof is outside the scope of this document. Please see the Paraprof Manual for more information.