Chaste
Release::2018.1
|
#include <iostream>
#include <cassert>
#include <sstream>
#include <string>
#include "PetscTools.hpp"
Go to the source code of this file.
Macros | |
#define | TRACE(stuff) std::cout << FormDebugHead() << stuff << std::endl << std::flush; |
#define | MARK std::cout << FormDebugHead() << __FILE__ << " at line " << __LINE__ << std::endl << std::flush; |
#define | MARK_ON_PROCESS(proc) if (PetscTools::GetMyRank()==proc) std::cout << FormDebugHead() << __FILE__ << " at line " << __LINE__ << std::endl << std::flush; |
#define | PRINT_VARIABLE(var) std::cout << FormDebugHead() << #var " = " << var << std::endl << std::flush; |
#define | PRINT_2_VARIABLES(var1, var2) |
#define | PRINT_3_VARIABLES(var1, var2, var3) |
#define | PRINT_4_VARIABLES(var1, var2, var3, var4) |
#define | PRINT_5_VARIABLES(var1, var2, var3, var4, var5) |
#define | QUIT_AFTER_N_VISITS(n) { static unsigned counter=0; if (++counter==(n)) {TRACE("User-forced quit."); assert(0);} } |
#define | HOW_MANY_TIMES_HERE(message) |
#define | TRACE_FROM_NTH_VISIT(stuff, n) |
#define | PRINT_VECTOR(v) |
#define | MARK_IN_ORDER PetscTools::BeginRoundRobin(); MARK; PetscTools::EndRoundRobin(); |
#define | STACK PrintTheStack(); |
#define | MARK_MEMORY MarkMemory(); |
#define | UNMARK_MEMORY UnmarkMemory(); |
#define | PRINT_MEMORY PrintMemory(); |
Functions | |
std::string | FormDebugHead () |
void | PrintTheStack () |
void | MarkMemory () |
void | UnmarkMemory () |
void | PrintMemory () |
Variables | |
double | eMemoryAtMarker |
A bunch of useful macros for debugging. These all output information to stdout as lines starting "DEBUG: ". When running in parallel the process number is also displayed. Each line is flushed as soon as it is written.
Definition in file Debug.hpp.
#define HOW_MANY_TIMES_HERE | ( | message | ) |
Print how many times this line has been reached, everytime it is reached.
message | message to include in brackets |
#define MARK std::cout << FormDebugHead() << __FILE__ << " at line " << __LINE__ << std::endl << std::flush; |
#define MARK_IN_ORDER PetscTools::BeginRoundRobin(); MARK; PetscTools::EndRoundRobin(); |
(For debugging on a seriously large number of processes) Show the mark that we have reached this line of code, but do it in process order, which is important if we suspect that one or more processes are missing.
This will also isolate all the MARKs which appear for a particular line of code, since all process have to synchronise at the beginning of the round-robin.
Note that this will change the parallel behaviour of the code – if one process really is missing then the first barrier inside the round-robin will cause deadlock.
#define MARK_MEMORY MarkMemory(); |
#define MARK_ON_PROCESS | ( | proc | ) | if (PetscTools::GetMyRank()==proc) std::cout << FormDebugHead() << __FILE__ << " at line " << __LINE__ << std::endl << std::flush; |
#define PRINT_2_VARIABLES | ( | var1, | |
var2 | |||
) |
Print the name and value of the given variables.
var1 | |
var2 |
#define PRINT_3_VARIABLES | ( | var1, | |
var2, | |||
var3 | |||
) |
Print the name and value of the given variables.
var1 | |
var2 | |
var3 |
#define PRINT_4_VARIABLES | ( | var1, | |
var2, | |||
var3, | |||
var4 | |||
) |
Print the name and value of the given variables.
var1 | |
var2 | |
var3 | |
var4 |
#define PRINT_5_VARIABLES | ( | var1, | |
var2, | |||
var3, | |||
var4, | |||
var5 | |||
) |
Print the name and value of the given variables.
var1 | |
var2 | |
var3 | |
var4 | |
var5 |
#define PRINT_MEMORY PrintMemory(); |
#define PRINT_VARIABLE | ( | var | ) | std::cout << FormDebugHead() << #var " = " << var << std::endl << std::flush; |
#define PRINT_VECTOR | ( | v | ) |
Display a std::vector.
v |
#define STACK PrintTheStack(); |
#define TRACE | ( | stuff | ) | std::cout << FormDebugHead() << stuff << std::endl << std::flush; |
Print a debug message.
stuff | what to print (can be a variable, or e.g. a << " " << b) |
Definition at line 96 of file Debug.hpp.
Referenced by MarkMemory(), PrintTheStack(), and UnmarkMemory().
#define TRACE_FROM_NTH_VISIT | ( | stuff, | |
n | |||
) |
Prints the given message, but only from the n-th time that line is reached, for the given n.
stuff | what to print |
n |
#define UNMARK_MEMORY UnmarkMemory(); |
std::string FormDebugHead | ( | ) |
Definition at line 47 of file Debug.cpp.
References PetscTools::GetMyRank(), and PetscTools::IsParallel().
Referenced by PrintMemory().
void MarkMemory | ( | ) |
Allows use of PRINT_MEMORY to give results relative to the footprint at this call.
Set sMemoryAtMarker to the current approximate memory footprint. This value is subtracted from the memory footprint if the macro PRINT_MEMORY is called.
This is used with the macro MARK_MEMORY
Definition at line 83 of file Debug.cpp.
References TRACE.
void PrintMemory | ( | ) |
Print the approximate memory footprint. This is the current memory footprint minus sMemoryAtMarker, which will be zero if the MARK_MEMORY macro has not been used.
This is used with the macro PRINT_MEMORY
Definition at line 105 of file Debug.cpp.
References eMemoryAtMarker, and FormDebugHead().
void PrintTheStack | ( | ) |
void UnmarkMemory | ( | ) |
double eMemoryAtMarker |
Can be set as approximate memory footprint in Mb at marker using the macro MARK_MEMORY
Definition at line 45 of file Debug.cpp.
Referenced by PrintMemory().