12 static const size_t MAX_PREFIX_SIZE = 100;
15 static char prefix_[MAX_PREFIX_SIZE] =
"";
16 static FILE *outfile_ = stdout;
18 static const int MAX_BUFFER_SIZE = 1000;
19 static char buffer_[MAX_BUFFER_SIZE] =
"";
31 static bool init =
false;
32 static bool rank_verbosity =
false;
33 static char *rank_verbosity_env = getenv(
"QUDA_RANK_VERBOSITY");
35 if (!
init && rank_verbosity_env) {
36 std::stringstream rank_list(rank_verbosity_env);
39 while (rank_list >> rank_) {
40 if (
comm_rank() == rank_ || rank_ == -1) rank_verbosity =
true;
41 if (rank_list.peek() ==
',') rank_list.ignore();
48 return rank_verbosity;
53 static bool init =
false;
57 char *enable_tuning = getenv(
"QUDA_ENABLE_TUNING");
58 if (!enable_tuning || strcmp(enable_tuning,
"0")!=0) {
71 strncpy(prefix_, prefix, MAX_PREFIX_SIZE);
72 prefix_[MAX_PREFIX_SIZE-1] =
'\0';
81 static std::stack<QudaVerbosity> vstack;
88 if (vstack.size() > 15) {
89 warningQuda(
"Verbosity stack contains %u elements. Is there a missing popVerbosity() somewhere?",
90 static_cast<unsigned int>(vstack.size()));
97 errorQuda(
"popVerbosity() called with empty stack");
103 static std::stack<char *> pstack;
108 char *prefix_backup = (
char *)
safe_malloc(MAX_PREFIX_SIZE *
sizeof(
char));
110 pstack.push(prefix_backup);
115 if (pstack.size() > 15) {
116 warningQuda(
"Verbosity stack contains %u elements. Is there a missing popOutputPrefix() somewhere?",
117 static_cast<unsigned int>(vstack.size()));
123 if (pstack.empty()) {
errorQuda(
"popOutputPrefix() called with empty stack"); }
126 char *prefix_restore = pstack.top();
135 static char omp_thread_string[128];
136 static bool init =
false;
138 strcpy(omp_thread_string,
",omp_threads=");
139 char *omp_threads = getenv(
"OMP_NUM_THREADS");
140 strcat(omp_thread_string, omp_threads ? omp_threads :
"1");
143 return omp_thread_string;
int comm_rank_global(void)
enum QudaVerbosity_s QudaVerbosity
#define safe_malloc(size)
void init()
Create the BLAS context.
void pushVerbosity(QudaVerbosity verbosity)
Push a new verbosity onto the stack.
QudaTune getTuning()
Query whether autotuning is enabled or not. Default is enabled but can be overridden by setting QUDA_...
void popOutputPrefix()
Pop the output prefix restoring the prior one on the stack.
void popVerbosity()
Pop the verbosity restoring the prior one on the stack.
char * getOmpThreadStr()
Returns a string of the form ",omp_threads=$OMP_NUM_THREADS", which can be used for storing the numbe...
bool getRankVerbosity()
This function returns true if the calling rank is enabled for verbosity (e.g., whether printQuda and ...
void pushOutputPrefix(const char *prefix)
Push a new output prefix onto the stack.
QudaVerbosity getVerbosity()
void setVerbosity(QudaVerbosity verbosity)
void setOutputPrefix(const char *prefix)
void setOutputFile(FILE *outfile)