Behavior with debug flags

Documentation, Web site and code modifications

Moderators: baguetl, routerov

Locked
User avatar
jzwanzig
Posts: 504
Joined: Mon Aug 17, 2009 9:25 am

Behavior with debug flags

Post by jzwanzig » Mon Mar 17, 2014 2:01 pm

Hi,

when I build abinit with enable_debug=yes, the current behavior is to print to the log file (std_err, I guess) a statement when a routine is entered, and a statement when it is exited. For example, m_paw_numeric.F90:824 : enter and m_paw_numeric.F90:875 : exit.

I am currently trying to debug (again! I don't know who or how broke the code) the parallel part of berryopt with PAW, and when running a simple test calculation, the log file is over 1.5 GB in size. It contains for example 47.8 million references to m_paw_numeric. I don't think this is always helpful (sometimes it is of course) and it is making the test calcs take forever. Is there a way to control this behavior globally?

thanks,
Joe
Josef W. Zwanziger
Professor, Department of Chemistry
Canada Research Chair in NMR Studies of Materials
Dalhousie University
Halifax, NS B3H 4J3 Canada
jzwanzig@gmail.com

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Behavior with debug flags

Post by Jordan » Mon Mar 17, 2014 11:27 pm

Hi,

The way I do is to configure with the enable_debug="yes,enhanced,..." flag and compilte abinit.
Then I just open the config.h file and comment the #define ENABLE_DEBUG 1 line.
I "touch" paw_numerics module (or whatever module bothering you) and compile again so the DBG_ENTER and DBG_EXIT are not defined anymore.
That trick allows to control which file/module/routine uses the DEBUG verbosity.
Then if you are debuging a routine that needs this macro, don't forget to uncomment the line in the config.h file so the next time you compile your routine it still has the debug verbosity.

Also you could maybe use the fcflags_opt_repertoirename (eg fcflags_opt_62_ctqmc) variable in you .ac file and add the -UENABLE_DEBUG flag to it.
That should undefine the macro for the corresponding directory only.

Hope that helped.

Jordan

User avatar
jzwanzig
Posts: 504
Joined: Mon Aug 17, 2009 9:25 am

Re: Behavior with debug flags

Post by jzwanzig » Mon Mar 17, 2014 11:38 pm

Thanks, Jordan, those are good ideas. What I'm doing now is "enable_debug = no", "enable_optim = no", and then adding FCFLAGS and CFLAGS that do the job like "-O0 -g -fbounds-check". But I think the project needs a better solution. When a simple "enable_debug = yes" triggers 1.5 GB of output, it's really not useful.

Joe
Josef W. Zwanziger
Professor, Department of Chemistry
Canada Research Chair in NMR Studies of Materials
Dalhousie University
Halifax, NS B3H 4J3 Canada
jzwanzig@gmail.com

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Behavior with debug flags

Post by Jordan » Mon Mar 17, 2014 11:44 pm

If the trick proposed above is too much work, you can add

Code: Select all

#undef ENABLE_DEBUG

right after

Code: Select all

#include 'config.h'

and before

Code: Select all

#include 'abi_common.h'

in any file/module/routine that is too talkative

And then feel free to configure with enable_debug=yes,... and compile as usual.

But yes, I agree with you, this sentinel can be awkward !

Jordan

User avatar
gmatteo
Posts: 291
Joined: Sun Aug 16, 2009 5:40 pm

Re: Behavior with debug flags

Post by gmatteo » Tue Mar 18, 2014 12:30 am

Hi all,

I usually use DEBUG_MODE in a slightly different mode. First of all, I do not enable ENABLE_DEBUG in the
compilation, then I enable the sentinel on a per file (per module) basis by just adding

#defined DEBUG_MODE

#include "abi_common.h"

at the beginning of the file (module) so that all the procedures included in the file (module) will call the sentinel when entering/exiting.

When I have to debug the code without the help of a debugger, I usually have some idea
on the interested routines and I enable the debug mode only in these files.

I agree with Joe that ENABLE_DEBUG is not useful if it produces tons of Gigabytes.
I can easily change the code in m_errors so that we reduce to amount of output, we only have to specify some kind of
policy in terms of the numerical value of DEBUG_MODE e.g.

#ifdef DEBUG_MODE
#if DEBUG_MODE == 1
/* standard debugging level, call the sentinel every 20 procedure calls */
#elif DEBUG_MODE == N
/* Very verbose mode, call sentinel at every enter|exit */
...
#endif

Best,
Matteo

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Behavior with debug flags

Post by Jordan » Mon Apr 07, 2014 5:12 pm

This is a good idea, maybe one should consider a full verbosity for high level routines whereas a low verbosity is needed for low level routines
That is to say, e.g. dirs >70 always states de debug sentinel and dirs <70 call the sentinel once every X calls.

What do you think ?

Jordan

User avatar
pouillon
Posts: 651
Joined: Wed Aug 19, 2009 10:08 am
Location: Spain
Contact:

Re: Behavior with debug flags

Post by pouillon » Tue Apr 08, 2014 7:43 pm

We could indeed use a heuristic based of the frequency of calls to a routine during a run, for which what you propose is a good approximation.
Yann Pouillon
Simune Atomistics
Donostia-San Sebastián, Spain

Locked