Profiling templates

Discussion of chess software programming and technical issues.

Moderator: Ras

Carbec
Posts: 162
Joined: Thu Jan 20, 2022 9:42 am
Location: France
Full name: Philippe Chevalier

Profiling templates

Post by Carbec »

Hi,

Im trying to profile Zangdar with gprof; the problem is that several routines don't show.
The code have several templates, its perhaps the cause ?

For example :

Code: Select all

  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 23.84     16.70    16.70 261650443     0.00     0.00  int Board::evaluate<true>()
 20.38     30.98    14.28 81277114     0.00     0.00  int Search::alpha_beta<(Color)0>(Board&, int, int, int, int, bool, PVariation&, ThreadData*)
 17.74     43.41    12.43 101595721     0.00     0.00  int Search::alpha_beta<(Color)1>(Board&, int, int, int, int, bool, PVariation&, ThreadData*)
  7.35     48.56     5.15 103318438     0.00     0.00  int Search::quiescence<(Color)1>(Board&, int, int, int, ThreadData*)
  7.11     53.54     4.98 93077658     0.00     0.00  int Search::quiescence<(Color)0>(Board&, int, int, int, ThreadData*)
  6.37     58.00     4.46 105754180     0.00     0.00  MovePicker::scoreMoves(int, unsigned int)
  4.51     61.16     3.16 17901986     0.00     0.00  void Board::legal_moves<(Color)1>(MoveList&)
  4.22     64.12     2.96 16279857     0.00     0.00  void Board::legal_moves<(Color)0>(MoveList&)
  2.68     66.00     1.88 145887917     0.00     0.00  void Board::make_move<(Color)0>(unsigned int)
  2.63     67.84     1.84 109783210     0.00     0.00  Board::fast_see(unsigned int, int) const [clone .constprop.0]
  2.01     69.25     1.41 125861582     0.00     0.00  void Board::make_move<(Color)1>(unsigned int)
Here "evaluate" don't do really anything, its just calls another routine (which is not a template); the latter calls others routines (theses ones are templates). But these routines don't show in the output.
Is there a limitation of gprof ? Or do I have to use another tool ? I am under Linux (Ubuntu).
Thanks for info
Philippe
abulmo2
Posts: 465
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Profiling templates

Post by abulmo2 »

Inlined functions, which include templates, do not appear when you profile a program. The body of these functions are inserted inside the calling function and they are no more called from there. Only functions that are called appear in the profile output, not the inlined ones. To see them you can disable inlining; for example with the -fno-inline option if you are using gcc or by disabling any optimizations.
Richard Delorme