Grid 0.7.0
Log.cc
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/Log.cc
6
7Copyright (C) 2015
8
9Author: Antonin Portelli <antonin.portelli@me.com>
10Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
11Author: Peter Boyle <paboyle@ph.ed.ac.uk>
12Author: paboyle <paboyle@ph.ed.ac.uk>
13
14This program is free software; you can redistribute it and/or modify
15it under the terms of the GNU General Public License as published by
16the Free Software Foundation; either version 2 of the License, or
17(at your option) any later version.
18
19This program is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22GNU General Public License for more details.
23
24You should have received a copy of the GNU General Public License along
25with this program; if not, write to the Free Software Foundation, Inc.,
2651 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
28See the full license in the file "LICENSE" in the top level distribution
29directory
30*************************************************************************************/
31 /* END LEGAL */
32#include <Grid/GridCore.h>
34
35#include <cxxabi.h>
36#include <memory>
37
39
40std::string demangle(const char* name) {
41
42 int status = -4; // some arbitrary value to eliminate the compiler warning
43
44 // enable c++11 by passing the flag -std=c++11 to g++
45 std::unique_ptr<char, void(*)(void*)> res {
46 abi::__cxa_demangle(name, NULL, NULL, &status),
47 std::free
48 };
49
50 return (status==0) ? res.get() : name ;
51}
52
55std::ostream Logger::devnull(0);
56
57void GridLogTimestamp(int on){
59}
60
62GridLogger GridLogMG (1, "MG" , GridLogColours, "NORMAL");
63GridLogger GridLogIRL (1, "IRL" , GridLogColours, "NORMAL");
64GridLogger GridLogSolver (1, "Solver", GridLogColours, "NORMAL");
66GridLogger GridLogWarning(1, "Warning", GridLogColours, "YELLOW");
67GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL");
68GridLogger GridLogMemory (1, "Memory", GridLogColours, "NORMAL");
69GridLogger GridLogTracing(1, "Tracing", GridLogColours, "NORMAL");
70GridLogger GridLogDebug (1, "Debug", GridLogColours, "PURPLE");
71GridLogger GridLogPerformance(1, "Performance", GridLogColours, "GREEN");
73GridLogger GridLogIterative (1, "Iterative", GridLogColours, "BLUE");
74GridLogger GridLogIntegrator (1, "Integrator", GridLogColours, "BLUE");
76
77void GridLogConfigure(std::vector<std::string> &logstreams) {
78 GridLogError.Active(1);
79 GridLogWarning.Active(0);
80 GridLogMessage.Active(1); // at least the messages should be always on
81 GridLogMemory.Active(0);
82 GridLogTracing.Active(0);
83 GridLogIterative.Active(0);
84 GridLogDebug.Active(0);
85 GridLogPerformance.Active(0);
86 GridLogDslash.Active(0);
87 GridLogIntegrator.Active(1);
88 GridLogColours.Active(0);
89 GridLogHMC.Active(1);
90
91 for (int i = 0; i < logstreams.size(); i++) {
92 if (logstreams[i] == std::string("Tracing")) GridLogTracing.Active(1);
93 if (logstreams[i] == std::string("Memory")) GridLogMemory.Active(1);
94 if (logstreams[i] == std::string("Warning")) GridLogWarning.Active(1);
95 if (logstreams[i] == std::string("NoMessage")) GridLogMessage.Active(0);
96 if (logstreams[i] == std::string("Iterative")) GridLogIterative.Active(1);
97 if (logstreams[i] == std::string("Debug")) GridLogDebug.Active(1);
98 if (logstreams[i] == std::string("Performance")) GridLogPerformance.Active(1);
99 if (logstreams[i] == std::string("Dslash")) GridLogDslash.Active(1);
100 if (logstreams[i] == std::string("NoIntegrator"))GridLogIntegrator.Active(0);
101 if (logstreams[i] == std::string("NoHMC")) GridLogHMC.Active(0);
102 if (logstreams[i] == std::string("Colours")) GridLogColours.Active(1);
103 }
104}
105
107// Verbose limiter on MPI tasks
110 int me = 0;
111#if defined(GRID_COMMS_MPI) || defined(GRID_COMMS_MPI3) || defined(GRID_COMMS_MPIT)
112 MPI_Comm_rank(MPI_COMM_WORLD, &me);
113#endif
114#ifdef GRID_COMMS_SHMEM
115 me = shmem_my_pe();
116#endif
117 if (me) {
118 std::cout.setstate(std::ios::badbit);
119 }
120}
121
123#if defined(GRID_COMMS_MPI) || defined(GRID_COMMS_MPI3) || defined(GRID_COMMS_MPIT)
124 std::cout.clear();
125#endif
126}
128
GridLogger GridLogIterative(1, "Iterative", GridLogColours, "BLUE")
GridLogger GridLogError(1, "Error", GridLogColours, "RED")
void GridLogTimestamp(int on)
Definition Log.cc:57
GridLogger GridLogIRL(1, "IRL", GridLogColours, "NORMAL")
GridLogger GridLogPerformance(1, "Performance", GridLogColours, "GREEN")
GridLogger GridLogDebug(1, "Debug", GridLogColours, "PURPLE")
GridLogger GridLogMG(1, "MG", GridLogColours, "NORMAL")
void Grid_quiesce_nodes(void)
Definition Log.cc:109
GridLogger GridLogIntegrator(1, "Integrator", GridLogColours, "BLUE")
GridLogger GridLogHMC(1, "HMC", GridLogColours, "BLUE")
void GridLogConfigure(std::vector< std::string > &logstreams)
Definition Log.cc:77
GridLogger GridLogMemory(1, "Memory", GridLogColours, "NORMAL")
std::string demangle(const char *name)
Definition Log.cc:40
GridLogger GridLogSolver(1, "Solver", GridLogColours, "NORMAL")
void Grid_unquiesce_nodes(void)
Definition Log.cc:122
GridLogger GridLogTracing(1, "Tracing", GridLogColours, "NORMAL")
Colours GridLogColours(0)
GridLogger GridLogDslash(1, "Dslash", GridLogColours, "BLUE")
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
GridLogger GridLogWarning(1, "Warning", GridLogColours, "YELLOW")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
Definition Log.h:46
static std::ostream devnull
Definition Log.h:97
static GridStopWatch GlobalStopWatch
Definition Log.h:94
static void Timestamp(int on)
Definition Log.h:115
static int timestamp
Definition Log.h:89