SkePU
1.2
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Friends
Macros
Groups
Pages
include
skepu
src
debug.h
Go to the documentation of this file.
1
5
#ifndef DEBUG_H
6
#define DEBUG_H
7
8
#include <assert.h>
9
10
11
#ifndef SKEPU_DEBUG
12
#define SKEPU_DEBUG 0
13
#endif
14
15
16
#if SKEPU_TUNING_DEBUG > 0
17
#include <iostream>
18
#endif
19
20
#if SKEPU_TUNING_DEBUG > 1
21
#define DEBUG_TUNING_LEVEL2(text) std::cerr << "[SKEPU_TUNING_L1 " << __FILE__ << ":" << __LINE__ << "] " << text;
22
#else
23
#define DEBUG_TUNING_LEVEL2(text)
24
#endif
25
26
#if SKEPU_TUNING_DEBUG > 2
27
#define DEBUG_TUNING_LEVEL3(text) std::cerr << "[SKEPU_TUNING_L2 " << __FILE__ << ":" << __LINE__ << "] " << text;
28
#else
29
#define DEBUG_TUNING_LEVEL3(text)
30
#endif
31
32
#if SKEPU_DEBUG > 0
33
#include <iostream>
34
#endif
35
36
#if SKEPU_DEBUG > 0
37
#define DEBUG_TEXT_LEVEL1(text) std::cerr << "[SKEPU_DEBUG_L1 " << __FILE__ << ":" << __LINE__ << "] " << text;
38
#else
39
#define DEBUG_TEXT_LEVEL1(text)
40
#endif
41
42
#if SKEPU_DEBUG > 1
43
#define DEBUG_TEXT_LEVEL2(text) std::cerr << "[SKEPU_DEBUG_L2 " << __FILE__ << ":" << __LINE__ << "] " << text;
44
#else
45
#define DEBUG_TEXT_LEVEL2(text)
46
#endif
47
48
#if SKEPU_DEBUG > 2
49
#define DEBUG_TEXT_LEVEL3(text) std::cerr << "[SKEPU_DEBUG_L3 " << __FILE__ << ":" << __LINE__ << "] " << text;
50
#else
51
#define DEBUG_TEXT_LEVEL3(text)
52
#endif
53
54
55
#ifndef SKEPU_ASSERT
56
#define SKEPU_ASSERT(expr) assert(expr)
57
#endif
58
59
#define SKEPU_ERROR(text) { std::cerr << "[SKEPU_ERROR " << __FILE__ << ":" << __LINE__ << "] " << text; exit(0); }
60
61
#define SKEPU_WARNING(text) { std::cerr << "[SKEPU_WARNING " << __FILE__ << ":" << __LINE__ << "] " << text; }
62
63
#define SKEPU_EXIT() exit(0)
64
65
#ifdef __GNUC__
66
#define SKEPU_UNLIKELY(expr) (__builtin_expect(!!(expr),0))
67
#define SKEPU_LIKELY(expr) (__builtin_expect(!!(expr),1))
68
#define SKEPU_ATTRIBUTE_UNUSED __attribute__((unused))
69
#define SKEPU_ATTRIBUTE_INTERNAL __attribute__ ((visibility ("internal")))
70
#else
71
#define SKEPU_UNLIKELY(expr) (expr)
72
#define SKEPU_LIKELY(expr) (expr)
73
#define SKEPU_ATTRIBUTE_UNUSED
74
#define SKEPU_ATTRIBUTE_INTERNAL
75
#endif
76
77
#ifdef SKEPU_OPENCL
78
#define CL_CHECK_ERROR(err) if(err != CL_SUCCESS) {std::cerr<<"Error building OpenCL program!!\n" <<err <<"\n";}
79
#endif
80
81
82
83
84
85
86
87
#ifdef DEBUG_UTIL
88
89
#include <fstream>
90
#include <sstream>
91
92
class
FileWriter
93
{
94
std::string filename;
95
std::ofstream file;
96
public
:
97
FileWriter(std::string _filename): filename(_filename)
98
{
99
file.open(filename.c_str());
100
if
(!file.good())
101
SKEPU_ERROR(
"Error while opening file for writing: "
<< filename);
102
}
103
void
write(std::string line){
104
file << line;
105
}
106
~FileWriter() {
107
try
108
{
109
file.close();
110
}
catch
(...) {
111
SKEPU_WARNING(
"A problem occurred while closing the file: "
<< filename);
112
}
113
}
114
};
115
116
#define OPEN_FILE(filename) FileWriter f(filename);
117
#define WRITE_FILE(line) f.write(line);
118
119
#endif
120
121
122
// class skepu_error
123
// {
124
// private:
125
// std::string message;
126
//
127
// public:
128
// skepu_error(std::string m)
129
// {
130
// message = m;
131
// }
132
// inline std::string getMessage()
133
// {
134
// return message;
135
// };
136
// friend std::ostream& operator<<(std::ostream &os, skepu_error& err)
137
// {
138
// os<<"SKEPU: "<<(err.getMessage())<<"\n";
139
// return os;
140
// }
141
//
142
// };
143
//
144
// #ifndef _NO_EXCEPTION
145
//
146
// #define SKEPU_ERROR(ErrormMsg) throw skepu::skepu_error( ErrormMsg);
147
//
148
// #else
149
// inline void _skepu_error (const char* pErrMsg)
150
// {
151
// cerr << "SKEPU ERROR: " + pErrMsg << endl;
152
// exit(1);
153
// }
154
//
155
// #define SKEPU_ERROR(ErrormMsg) skepu::_skepu_error( ErrormMsg);
156
//
157
// #endif
158
159
160
161
162
#endif
163
164
Generated on Wed May 13 2015 11:04:37 for SkePU by
1.8.5