2.4.8. Compiling and Running Programs

Up: Contents Next: Writing Application Codes with PETSc Previous: Parallel Programming

Figure 6 illustrates compiling and running a PETSc program using MPICH. Note that different sites may have slightly different library and compiler names. See Chapter Makefiles for a discussion about compiling PETSc programs. Users who are experiencing difficulties linking PETSc programs should refer to the troubleshooting guide via the PETSc WWW home page http://www.mcs.anl.gov/petsc or given in the file ${}PETSC_DIR/docs/troubleshooting.html.


   eagle> make BOPT=g ex2 
   gcc -DPETSC_ARCH_sun4 -pipe -c  -I../../../  -I../../..//include    
       -I/usr/local/mpi/include  -I../../..//src -g  
       -DUSE_PETSC_DEBUG -DPETSC_MALLOC -DUSE_PETSC_LOG ex1.c 
   gcc -g -DUSE_PETSC_DEBUG -DPETSC_MALLOC -DUSE_PETSC_LOG -o ex1 ex1.o  
      /home/bsmith/petsc/lib/libg/sun4/libpetscsles.a  
      -L/home/bsmith/petsc/lib/libg/sun4 -lpetscstencil -lpetscgrid  -lpetscsles  
      -lpetscmat  -lpetscvec -lpetscsys -lpetscdraw   
      /usr/local/lapack/lib/lapack.a /usr/local/lapack/lib/blas.a  
      /usr/lang/SC1.0.1/libF77.a -lm /usr/lang/SC1.0.1/libm.a -lX11  
      /usr/local/mpi/lib/sun4/ch_p4/libmpi.a 
      /usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o   
      /usr/lang/SC1.0.1/libF77.a -lm /usr/lang/SC1.0.1/libm.a -lm 
   rm -f ex1.o 
   eagle> mpirun -np 1 ex2 
   Norm of error 3.6618e-05 iterations 7 
   eagle> 
   eagle> mpirun -np 2 ex2 
   Norm of error 5.34462e-05 iterations 9 

Figure 6: Running a PETSc Program

As shown in Figure 7 , the option -log_summary activates printing of a performance summary, including times, floating point operation (flop) rates, and message-passing activity. Chapter Profiling provides details about profiling, including interpretation of the output data within Figure 7 . This particular example involves the solution of a linear system on one processor using GMRES and ILU. The low floating point operation (flop) rates in this example are due to the fact that the code solved a tiny system. We include this example merely to demonstrate the ease of extracting performance information.


eagle> mpirun -np 1 ex1 -n 1000 -pc_type ilu -ksp_type gmres -ksp_rtol 1.e-7 -log_summary 
-------------------------------- PETSc Performance Summary: -------------------------------------- 

ex1 on a sun4 named merlin.mcs.anl.gov with 1 processor, by curfman Wed Aug 7 17:24:27 1996

Max Min Avg Total Time (sec): 1.150e-01 1.0 1.150e-01 Objects: 1.900e+01 1.0 1.900e+01 Flops: 3.998e+04 1.0 3.998e+04 3.998e+04 Flops/sec: 3.475e+05 1.0 3.475e+05 MPI Messages: 0.000e+00 0.0 0.000e+00 0.000e+00 MPI Messages: 0.000e+00 0.0 0.000e+00 0.000e+00 (lengths) MPI Reductions: 0.000e+00 0.0

-------------------------------------------------------------------------------------------------- Phase Count Time (sec) Flops/sec -- Global -- Max Ratio Max Ratio Mess Avg len Reduct %T %F %M %L %R -------------------------------------------------------------------------------------------------- MatMult 2 2.553e-03 1.0 3.9e+06 1.0 0.0e+00 0.0e+00 0.0e+00 2 25 0 0 0 MatAssemblyBegin 1 2.193e-05 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 MatAssemblyEnd 1 5.004e-03 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 4 0 0 0 0 MatGetReordering 1 3.004e-03 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 3 0 0 0 0 MatILUFctrSymbol 1 5.719e-03 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 5 0 0 0 0 MatLUFactorNumer 1 1.092e-02 1.0 2.7e+05 1.0 0.0e+00 0.0e+00 0.0e+00 9 7 0 0 0 MatSolve 2 4.193e-03 1.0 2.4e+06 1.0 0.0e+00 0.0e+00 0.0e+00 4 25 0 0 0 MatSetValues 1000 2.461e-02 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 21 0 0 0 0 VecDot 1 2.060e-04 1.0 9.7e+06 1.0 0.0e+00 0.0e+00 0.0e+00 0 5 0 0 0 VecNorm 3 5.870e-04 1.0 1.0e+07 1.0 0.0e+00 0.0e+00 0.0e+00 1 15 0 0 0 VecScale 1 1.640e-04 1.0 6.1e+06 1.0 0.0e+00 0.0e+00 0.0e+00 0 3 0 0 0 VecCopy 1 3.101e-04 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 VecSet 3 5.029e-04 1.0 0.0e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 VecAXPY 3 8.690e-04 1.0 6.9e+06 1.0 0.0e+00 0.0e+00 0.0e+00 1 15 0 0 0 VecMAXPY 1 2.550e-04 1.0 7.8e+06 1.0 0.0e+00 0.0e+00 0.0e+00 0 5 0 0 0 SLESSolve 1 1.288e-02 1.0 2.2e+06 1.0 0.0e+00 0.0e+00 0.0e+00 11 70 0 0 0 SLESSetUp 1 2.669e-02 1.0 1.1e+05 1.0 0.0e+00 0.0e+00 0.0e+00 23 7 0 0 0 KSPGMRESOrthog 1 1.151e-03 1.0 3.5e+06 1.0 0.0e+00 0.0e+00 0.0e+00 1 10 0 0 0 PCSetUp 1 2.024e-02 1.0 1.5e+05 1.0 0.0e+00 0.0e+00 0.0e+00 18 7 0 0 0 PCApply 2 4.474e-03 1.0 2.2e+06 1.0 0.0e+00 0.0e+00 0.0e+00 4 25 0 0 0 -------------------------------------------------------------------------------------------------

Memory usage is given in bytes:

Object Type Creations Destructions Memory Descendants' Mem. Index set 3 3 12420 0 Vector 8 8 65728 0 Matrix 2 2 184924 4140 Krylov Solver 1 1 16892 41080 Preconditioner 1 1 0 64872 SLES 1 1 0 122844


Figure 7: Running a PETSc Program with Profiling


Up: Contents Next: Writing Application Codes with PETSc Previous: Parallel Programming