/* This file is part of the Vc library. Copyright (C) 2011-2012 Matthias Kretz Vc is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Vc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Vc. If not, see . */ #ifndef VC_SSE_DEBUG_H #define VC_SSE_DEBUG_H #ifndef NDEBUG #include "types.h" #include #include #endif namespace ROOT { namespace Vc { namespace SSE { #ifdef NDEBUG class DebugStream { public: DebugStream(const char *, const char *, int) {} template inline DebugStream &operator<<(const T &) { return *this; } }; #else class DebugStream { private: template static void printVector(V _x) { enum { Size = sizeof(V) / sizeof(T) }; union { V v; T m[Size]; } x = { _x }; std::cerr << '[' << std::setprecision(24) << x.m[0]; for (int i = 1; i < Size; ++i) { std::cerr << ", " << std::setprecision(24) << x.m[i]; } std::cerr << ']'; } public: DebugStream(const char *func, const char *file, int line) { std::cerr << "\033[1;40;33mDEBUG: " << file << ':' << line << ' ' << func << ' '; } template DebugStream &operator<<(const T &x) { std::cerr << x; return *this; } DebugStream &operator<<(__m128 x) { printVector(x); return *this; } DebugStream &operator<<(__m128d x) { printVector(x); return *this; } DebugStream &operator<<(__m128i x) { printVector(x); return *this; } ~DebugStream() { std::cerr << "\033[0m" << std::endl; } }; #endif #define VC_DEBUG ::ROOT::Vc::SSE::DebugStream(__PRETTY_FUNCTION__, __FILE__, __LINE__) } // namespace SSE } // namespace Vc } // namespace ROOT #endif // VC_SSE_DEBUG_H