ROOT  6.06/09
Reference Guide
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_AVX_DEBUG_H
21 #define VC_AVX_DEBUG_H
22 
23 #ifndef NDEBUG
24 #include "vectorbase.h"
25 #include <iostream>
26 #include <iomanip>
27 #endif
28 
29 namespace ROOT {
30 namespace Vc
31 {
32 namespace AVX
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  }
69  printVector<float, __m256>(x);
70  return *this;
71  }
72  DebugStream &operator<<(__m128d x) {
73  printVector<double, __m128d>(x);
74  return *this;
75  }
76  DebugStream &operator<<(__m256d x) {
77  printVector<double, __m256d>(x);
78  return *this;
79  }
80  DebugStream &operator<<(__m128i x) {
81  printVector<unsigned int, __m128i>(x);
82  return *this;
83  }
84  DebugStream &operator<<(__m256i x) {
85  printVector<unsigned int, __m256i>(x);
86  return *this;
87  }
88 
90  {
91  std::cerr << "\033[0m" << std::endl;
92  }
93 };
94 #endif
95 
96 #define VC_DEBUG ::ROOT::Vc::AVX::DebugStream(__PRETTY_FUNCTION__, __FILE__, __LINE__)
97 
98 } // namespace AVX
99 } // namespace Vc
100 } // namespace ROOT
101 
102 #endif // VC_AVX_DEBUG_H
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
TLine * line
const char * Size
Definition: TXMLSetup.cxx:56
double T(double x)
Definition: ChebyshevPol.h:34
DebugStream(const char *func, const char *file, int line)
Definition: debug.h:57
DebugStream & operator<<(__m128 x)
Definition: debug.h:64
static void printVector(V _x)
Definition: debug.h:46
Double_t x[n]
Definition: legend1.C:17
DebugStream & operator<<(__m128i x)
Definition: debug.h:80
DebugStream & operator<<(__m256 x)
Definition: debug.h:68
#define AVX
Definition: global.h:90
SVector< double, 2 > v
Definition: Dict.h:5
TMarker * m
Definition: textangle.C:8
double func(double *x, double *p)
Definition: stressTF1.cxx:213
DebugStream & operator<<(__m128d x)
Definition: debug.h:72
DebugStream & operator<<(__m256d x)
Definition: debug.h:76
Definition: casts.h:28
DebugStream & operator<<(const T &x)
Definition: debug.h:62
DebugStream & operator<<(__m256i x)
Definition: debug.h:84