LAMA
|
00001 00034 #ifndef LAMA_TRACING_TRACE_CONFIG_HPP_ 00035 #define LAMA_TRACING_TRACE_CONFIG_HPP_ 00036 00037 // for dll_import 00038 #include <lama/config.hpp> 00039 00040 // base classes 00041 #include <lama/NonCopyable.hpp> 00042 00043 // others 00044 #include <lama/task/Thread.hpp> 00045 00046 #include <lama/Communicator.hpp> 00047 #include <lama/Context.hpp> 00048 00049 // boost 00050 #include <boost/shared_ptr.hpp> 00051 00052 #include <string> 00053 #include <map> 00054 00055 namespace tracing 00056 { 00057 00058 class RegionTable; 00059 00062 #define LAMA_ENV_TRACE_CONFIG "LAMA_TRACE" 00063 00078 class LAMA_DLL_IMPORTEXPORT TraceConfig : private lama::NonCopyable 00079 { 00080 public: 00081 00082 ~TraceConfig( ); 00083 00090 static TraceConfig& getInstance() { return *getInstancePtr(); } 00091 00095 static boost::shared_ptr<TraceConfig> getInstancePtr(); 00096 00100 bool isEnabled() { return mEnabled; } 00101 00102 bool isThreadEnabled( lama::Thread::Id threadId ) { return mThreadEnabled || threadId == mMaster; } 00103 00104 bool isVampirTraceEnabled() { return mVampirTraceEnabled; } 00105 00106 bool isTimeTraceEnabled() { return mTimeTraceEnabled; } 00107 00108 const char* getFilePrefix() const { return getInstance().mTraceFilePrefix.c_str(); } 00109 00115 RegionTable* getRegionTable(); 00116 00117 void traceOff(); 00118 00119 private: 00120 00121 TraceConfig( ); 00122 00123 void setParam( const std::string& param ); 00124 00125 void setKey( const std::string& key, const std::string& value ); 00126 00127 lama::Thread::Id mMaster; 00128 00129 bool mEnabled; 00130 00131 bool mTimeTraceEnabled; 00132 00133 bool mVampirTraceEnabled; 00134 00135 void enableVampirTrace( bool flag ); // switch trace on / off 00136 00137 bool mThreadEnabled; 00138 00139 std::string mTraceFilePrefix; 00140 00145 std::map<lama::Thread::Id, boost::shared_ptr<RegionTable> > mRegionTables; 00146 00147 RegionTable* getRegionTable( lama::Thread::Id ); 00148 00149 lama::CommunicatorPtr mComm; 00150 00151 lama::ContextPtr mCUDAContext; 00152 00155 static boost::shared_ptr<TraceConfig> config; 00156 00157 LAMA_LOG_DECL_STATIC_LOGGER( logger ); 00158 00159 }; 00160 00161 } // namespace tracing 00162 00163 #endif // LAMA_TRACING_TRACE_CONFIG_HPP_