ergo
DebugPolicies.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
44 #ifndef MAT_DEBUGPOLICIES
45 #define MAT_DEBUGPOLICIES
46 
47 #include <cstdlib>
48 
49 namespace mat{
50 #if 0
51 #define ASSERTALWAYS(x) \
52  this->assertAlways(__FILE__, __LINE__, __DATE__, __TIME__,x)
53 #define ASSERTDEBUG(x) \
54  this->assertDebug(__FILE__, __LINE__, __DATE__, __TIME__,x)
55  /* debugPolicies */
56 
57  class DebugLevelHigh {
58  public:
59  void assertAlways(char const * theFile, int const theLine,
60  char const * theDate, char const * theTime,
61  bool const statement) const {
62  if (!statement) {
63  std::cout<<"Assertion failed: "<<theFile<<":"<<theLine
64  <<" Compiled on "<<theDate<<" at "<<theTime<<".\n";
65  std::exit(1);
66  }
67  }
68  inline void assertDebug(char const * theFile, int const theLine,
69  char const * theDate, char const * theTime,
70  bool const statement) const {
71  assertAlways(theFile, theLine, theDate, theTime, statement);
72  }
73  };
74  class DebugLevelMedium : public DebugLevelHigh {};
75  class DebugLevelLow : public DebugLevelMedium {
76  public:
77  inline void assertDebug(char const * theFile, int const theLine,
78  char const * theDate, char const * theTime,
79  bool const statement) const {}
80  };
81 
82 #else
83 
84 
85 #define ASSERTALWAYS(x) \
86  this->assertAlways(__FILE__, __LINE__, __ID__,x)
87 #define ASSERTDEBUG(x) \
88  this->assertDebug(__FILE__, __LINE__, __ID__,x)
89 #endif
90  /* debugPolicies */
92  public:
93  void assertAlways(char const * theFile, int const theLine,
94  char const * theId, bool const statement) const {
95  if (!statement) {
96  std::cout<<"Assertion failed: "<<theFile<<":"<<theLine
97  <<" svn info: "<<theId<<".\n";
98  std::exit(1);
99  }
100  }
101  inline void assertDebug(char const * theFile, int const theLine,
102  char const * theId, bool const statement) const {
103  assertAlways(theFile, theLine, theId, statement);
104  }
105  };
106  class DebugLevelMedium : public DebugLevelHigh {};
108  public:
109  inline void assertDebug(char const * theFile, int const theLine,
110  char const * theId, bool const statement) const {}
111  };
112 
113 
114 
115 } /* end namespace mat */
116 #endif
tomatlabfile
static void tomatlabfile(char *name, T *values, int s, std::ofstream &output)
mat::DebugLevelMedium
Definition: DebugPolicies.h:106
real
ergo_real real
Definition: test.cc:46
mat_gblas.h
mat::DebugLevelLow
Definition: DebugPolicies.h:107
B
#define B
mat::gemm
static void gemm(const char *ta, const char *tb, const int *n, const int *k, const int *l, const T *alpha, const T *A, const int *lda, const T *B, const int *ldb, const T *beta, T *C, const int *ldc)
Definition: mat_gblas.h:232
mat::DebugLevelHigh
Definition: DebugPolicies.h:91
mat
Definition: allocate.cc:39
A
#define A
mat::DebugLevelLow::assertDebug
void assertDebug(char const *theFile, int const theLine, char const *theId, bool const statement) const
Definition: DebugPolicies.h:109
SIZE_INCREMENT
static const int SIZE_INCREMENT
Definition: blastime.cc:49
MIN_TIME_PER_STEP
static const int MIN_TIME_PER_STEP
Definition: blastime.cc:48
get_wall_seconds
static double get_wall_seconds()
Definition: blastime.cc:51
mainFun
int mainFun(int maxDim, double *timev, double *gflops, bool writeTomFile)
Definition: blastime.cc:62
main
int main(int argc, char *argv[])
Definition: blastime.cc:160
mat::DebugLevelHigh::assertDebug
void assertDebug(char const *theFile, int const theLine, char const *theId, bool const statement) const
Definition: DebugPolicies.h:101
mat::DebugLevelHigh::assertAlways
void assertAlways(char const *theFile, int const theLine, char const *theId, bool const statement) const
Definition: DebugPolicies.h:93