Blaze 3.9
FunctionTrace.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_UTIL_TRACING_FUNCTIONTRACE_H_
36#define _BLAZE_UTIL_TRACING_FUNCTIONTRACE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#if BLAZE_HPX_PARALLEL_MODE
44# include <hpx/include/threads.hpp>
45#elif BLAZE_CPP_THREADS_PARALLEL_MODE
46# include <thread>
47#elif BLAZE_BOOST_THREADS_PARALLEL_MODE
48# include <boost/thread/thread.hpp>
49#elif BLAZE_OPENMP_PARALLEL_MODE
50# include <omp.h>
51#endif
52
53#include <iostream>
54#include <new>
55#include <sstream>
56#include <string>
59#include <blaze/system/SMP.h>
60
61
62namespace blaze {
63
64//=================================================================================================
65//
66// CLASS DEFINITION
67//
68//=================================================================================================
69
70//*************************************************************************************************
79{
80 public:
81 //**Constructors********************************************************************************
84 inline FunctionTrace( const std::string& file, const std::string& function );
86 //**********************************************************************************************
87
88 //**Destructor**********************************************************************************
91 inline ~FunctionTrace();
93 //**********************************************************************************************
94
95 //**Forbidden operations************************************************************************
98 FunctionTrace( const FunctionTrace& ) = delete;
99 FunctionTrace( FunctionTrace&& ) = delete;
100
101 FunctionTrace& operator=( const FunctionTrace& ) = delete;
102 FunctionTrace& operator=( FunctionTrace&& ) = delete;
103
104 void* operator new ( std::size_t ) = delete;
105 void* operator new[]( std::size_t ) = delete;
106 void* operator new ( std::size_t, const std::nothrow_t& ) noexcept = delete;
107 void* operator new[]( std::size_t, const std::nothrow_t& ) noexcept = delete;
108
109 void operator delete ( void* ) noexcept = delete;
110 void operator delete[]( void* ) noexcept = delete;
111 void operator delete ( void*, const std::nothrow_t& ) noexcept = delete;
112 void operator delete[]( void*, const std::nothrow_t& ) noexcept = delete;
114 //**********************************************************************************************
115
116 private:
117 //**Member variables****************************************************************************
120 std::string file_;
121 std::string function_;
123 //**********************************************************************************************
124};
125//*************************************************************************************************
126
127
128
129
130//=================================================================================================
131//
132// CONSTRUCTORS
133//
134//=================================================================================================
135
136//*************************************************************************************************
142inline FunctionTrace::FunctionTrace( const std::string& file, const std::string& function )
143 : file_ ( file ) // The file name the traced function is contained in
144 , function_( function ) // The name of the traced function
145{
146 std::ostringstream oss;
147 oss << " + ";
148
149#if BLAZE_HPX_PARALLEL_MODE
150 oss << "[Thread " << hpx::this_thread::get_id() << "]";
151#elif BLAZE_CPP_THREADS_PARALLEL_MODE
152 oss << "[Thread " << std::this_thread::get_id() << "]";
153#elif BLAZE_BOOST_THREADS_PARALLEL_MODE
154 oss << "[Thread " << boost::this_thread::get_id() << "]";
155#elif BLAZE_OPENMP_PARALLEL_MODE
156 oss << "[Thread " << omp_get_thread_num() << "]";
157#endif
158
159 oss << " Entering function '" << function_ << "' in file '" << file_ << "'\n";
160 std::cerr << oss.str();
161}
162//*************************************************************************************************
163
164
165
166
167//=================================================================================================
168//
169// DESTRUCTOR
170//
171//=================================================================================================
172
173//*************************************************************************************************
177{
178 std::ostringstream oss;
179 oss << " - ";
180
181#if BLAZE_OPENMP_PARALLEL_MODE
182 oss << "[Thread " << omp_get_thread_num() << "]";
183#elif BLAZE_CPP_THREADS_PARALLEL_MODE
184 oss << "[Thread " << std::this_thread::get_id() << "]";
185#elif BLAZE_BOOST_THREADS_PARALLEL_MODE
186 oss << "[Thread " << boost::this_thread::get_id() << "]";
187#elif BLAZE_HPX_PARALLEL_MODE
188 oss << "[Thread " << hpx::this_thread::get_id() << "]";
189#endif
190
191 oss << " Leaving function '" << function_ << "' in file '" << file_ << "'\n";
192 std::cerr << oss.str();
193}
194//*************************************************************************************************
195
196} // namespace blaze
197
198#endif
Header file for a compiler independent type/function signature macro.
RAII object for function tracing.
Definition: FunctionTrace.h:79
~FunctionTrace()
Destructor for the FunctionTrace class.
Definition: FunctionTrace.h:176
FunctionTrace(const std::string &file, const std::string &function)
Constructor for the FunctionTrace class.
Definition: FunctionTrace.h:142
std::string file_
The file name the traced function is contained in.
Definition: FunctionTrace.h:120
std::string function_
The name of the traced function.
Definition: FunctionTrace.h:121
System settings for the debugging policy of the Blaze library.
System settings for the shared-memory parallelization.