ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
debug.h
Go to the documentation of this file.
1 /* This file is part of the Vc library.
2 
3  Copyright (C) 2011-2012 Matthias Kretz <kretz@kde.org>
4 
5  Vc is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as
7  published by the Free Software Foundation, either version 3 of
8  the License, or (at your option) any later version.
9 
10  Vc is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with Vc. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef VC_SSE_DEBUG_H
21 #define VC_SSE_DEBUG_H
22 
23 #ifndef NDEBUG
24 #include "types.h"
25 #include <iostream>
26 #include <iomanip>
27 #endif
28 
29 namespace ROOT {
30 namespace Vc
31 {
32 namespace SSE
33 {
34 
35 #ifdef NDEBUG
36 class DebugStream
37 {
38  public:
39  DebugStream(const char *, const char *, int) {}
40  template<typename T> inline DebugStream &operator<<(const T &) { return *this; }
41 };
42 #else
44 {
45  private:
46  template<typename T, typename V> static void printVector(V _x)
47  {
48  enum { Size = sizeof(V) / sizeof(T) };
49  union { V v; T m[Size]; } x = { _x };
50  std::cerr << '[' << std::setprecision(24) << x.m[0];
51  for (int i = 1; i < Size; ++i) {
52  std::cerr << ", " << std::setprecision(24) << x.m[i];
53  }
54  std::cerr << ']';
55  }
56  public:
57  DebugStream(const char *func, const char *file, int line)
58  {
59  std::cerr << "\033[1;40;33mDEBUG: " << file << ':' << line << ' ' << func << ' ';
60  }
61 
62  template<typename T> DebugStream &operator<<(const T &x) { std::cerr << x; return *this; }
63 
65  printVector<float, __m128>(x);
66  return *this;
67  }
68  DebugStream &operator<<(__m128d x) {
69  printVector<double, __m128d>(x);
70  return *this;
71  }
72  DebugStream &operator<<(__m128i x) {
73  printVector<unsigned int, __m128i>(x);
74  return *this;
75  }
76 
78  {
79  std::cerr << "\033[0m" << std::endl;
80  }
81 };
82 #endif
83 
84 #define VC_DEBUG ::ROOT::Vc::SSE::DebugStream(__PRETTY_FUNCTION__, __FILE__, __LINE__)
85 
86 } // namespace SSE
87 } // namespace Vc
88 } // namespace ROOT
89 
90 #endif // VC_SSE_DEBUG_H
DebugStream(const char *func, const char *file, int line)
Definition: debug.h:57
TLine * line
const char * Size
Definition: TXMLSetup.cxx:56
DebugStream & operator<<(__m128 x)
Definition: debug.h:64
TTree * T
Double_t x[n]
Definition: legend1.C:17
DebugStream & operator<<(const T &x)
Definition: debug.h:62
SVector< double, 2 > v
Definition: Dict.h:5
TMarker * m
Definition: textangle.C:8
tuple file
Definition: fildir.py:20
double func(double *x, double *p)
Definition: stressTF1.cxx:213
#define SSE
Definition: global.h:84
DebugStream & operator<<(__m128d x)
Definition: debug.h:68
DebugStream & operator<<(__m128i x)
Definition: debug.h:72
static void printVector(V _x)
Definition: debug.h:46