mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
instrumentation: minor refactoring, wrap OpenCL
- calculate ticksTotal instead of ticksMean - local / global width is based on ticksTotal value - added instrumentation for OpenCL program compilation - added instrumentation for OpenCL kernel execution
This commit is contained in:
@@ -476,7 +476,7 @@ public:
|
||||
class CV_EXPORTS IntrumentationRegion
|
||||
{
|
||||
public:
|
||||
IntrumentationRegion(const char* funName, const char* fileName, int lineNum, int instrType = TYPE_GENERAL, int implType = IMPL_PLAIN);
|
||||
IntrumentationRegion(const char* funName, const char* fileName, int lineNum, TYPE instrType = TYPE_GENERAL, IMPL implType = IMPL_PLAIN);
|
||||
~IntrumentationRegion();
|
||||
|
||||
private:
|
||||
@@ -492,7 +492,7 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
|
||||
///// General instrumentation
|
||||
// Instrument region
|
||||
#define CV_INSTRUMENT_REGION_META(TYPE, IMPL, ...) ::cv::instr::IntrumentationRegion __instr_region__(__FUNCTION__, __FILE__, __LINE__, TYPE, IMPL);
|
||||
#define CV_INSTRUMENT_REGION_META(NAME, TYPE, IMPL) ::cv::instr::IntrumentationRegion __instr_region__(NAME, __FILE__, __LINE__, TYPE, IMPL);
|
||||
// Instrument functions with non-void return type
|
||||
#define CV_INSTRUMENT_FUN_RT_META(TYPE, IMPL, ERROR_COND, FUN, ...) ([&]()\
|
||||
{\
|
||||
@@ -535,13 +535,13 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
|
||||
///// General instrumentation
|
||||
// General OpenCV region instrumentation macro
|
||||
#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_META(cv::instr::TYPE_GENERAL, cv::instr::IMPL_PLAIN)
|
||||
#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_META(__FUNCTION__, cv::instr::TYPE_GENERAL, cv::instr::IMPL_PLAIN)
|
||||
// Parallel OpenCV region instrumentation macro
|
||||
#define CV_INSTRUMENT_REGION_MT() CV_INSTRUMENT_REGION_MT_META(cv::instr::TYPE_GENERAL, cv::instr::IMPL_PLAIN)
|
||||
|
||||
///// IPP instrumentation
|
||||
// Wrapper region instrumentation macro
|
||||
#define CV_INSTRUMENT_REGION_IPP() CV_INSTRUMENT_REGION_META(::cv::instr::TYPE_WRAPPER, ::cv::instr::IMPL_IPP)
|
||||
#define CV_INSTRUMENT_REGION_IPP() CV_INSTRUMENT_REGION_META(__FUNCTION__, ::cv::instr::TYPE_WRAPPER, ::cv::instr::IMPL_IPP)
|
||||
// Function instrumentation macro
|
||||
#define CV_INSTRUMENT_FUN_IPP(FUN, ...) CV_INSTRUMENT_FUN_RT_META(::cv::instr::TYPE_FUN, ::cv::instr::IMPL_IPP, status < 0, FUN, __VA_ARGS__)
|
||||
// Diagnostic markers
|
||||
@@ -549,12 +549,15 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
|
||||
///// OpenCL instrumentation
|
||||
// Wrapper region instrumentation macro
|
||||
#define CV_INSTRUMENT_REGION_OPENCL() CV_INSTRUMENT_REGION_META(::cv::instr::TYPE_WRAPPER, ::cv::instr::IMPL_OPENCL)
|
||||
#define CV_INSTRUMENT_REGION_OPENCL() CV_INSTRUMENT_REGION_META(__FUNCTION__, ::cv::instr::TYPE_WRAPPER, ::cv::instr::IMPL_OPENCL)
|
||||
#define CV_INSTRUMENT_REGION_OPENCL_(NAME) CV_INSTRUMENT_REGION_META(NAME, ::cv::instr::TYPE_WRAPPER, ::cv::instr::IMPL_OPENCL)
|
||||
// Function instrumentation macro
|
||||
#define CV_INSTRUMENT_FUN_OPENCL_KERNEL(FUN, ...) CV_INSTRUMENT_FUN_RT_META(::cv::instr::TYPE_FUN, ::cv::instr::IMPL_OPENCL, status == 0, FUN, __VA_ARGS__)
|
||||
// Diagnostic markers
|
||||
#define CV_INSTRUMENT_MARK_OPENCL(NAME) CV_INSTRUMENT_MARK_META(::cv::instr::IMPL_OPENCL, NAME)
|
||||
#else
|
||||
#define CV_INSTRUMENT_REGION_META(...)
|
||||
|
||||
#define CV_INSTRUMENT_REGION()
|
||||
#define CV_INSTRUMENT_REGION_MT()
|
||||
|
||||
@@ -563,6 +566,7 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
#define CV_INSTRUMENT_MARK_IPP(NAME)
|
||||
|
||||
#define CV_INSTRUMENT_REGION_OPENCL()
|
||||
#define CV_INSTRUMENT_REGION_OPENCL_(...)
|
||||
#define CV_INSTRUMENT_FUN_OPENCL_KERNEL(FUN, ...) ((FUN)(__VA_ARGS__))
|
||||
#define CV_INSTRUMENT_MARK_OPENCL(NAME)
|
||||
#endif
|
||||
|
||||
@@ -1076,7 +1076,10 @@ public:
|
||||
// Instrumentation external interface
|
||||
namespace instr
|
||||
{
|
||||
enum
|
||||
|
||||
#if !defined OPENCV_ABI_CHECK
|
||||
|
||||
enum TYPE
|
||||
{
|
||||
TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function
|
||||
TYPE_MARKER, // Information marker
|
||||
@@ -1084,48 +1087,60 @@ enum
|
||||
TYPE_FUN, // Simple function call
|
||||
};
|
||||
|
||||
enum
|
||||
enum IMPL
|
||||
{
|
||||
IMPL_PLAIN = 0,
|
||||
IMPL_IPP,
|
||||
IMPL_OPENCL,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FLAGS_MAPPING = 0x01,
|
||||
};
|
||||
|
||||
class CV_EXPORTS NodeData
|
||||
{
|
||||
public:
|
||||
NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, int instrType = TYPE_GENERAL, int implType = IMPL_PLAIN);
|
||||
NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, cv::instr::TYPE instrType = TYPE_GENERAL, cv::instr::IMPL implType = IMPL_PLAIN);
|
||||
NodeData(NodeData &ref);
|
||||
~NodeData();
|
||||
NodeData& operator=(const NodeData&);
|
||||
|
||||
cv::String m_funName;
|
||||
int m_instrType;
|
||||
int m_implType;
|
||||
cv::String m_fileName;
|
||||
cv::instr::TYPE m_instrType;
|
||||
cv::instr::IMPL m_implType;
|
||||
const char* m_fileName;
|
||||
int m_lineNum;
|
||||
|
||||
bool m_funError;
|
||||
volatile int m_counter;
|
||||
bool m_stopPoint;
|
||||
uint64 m_ticksMean;
|
||||
volatile uint64 m_ticksTotal;
|
||||
|
||||
// No synchronization
|
||||
double getTotalMs() const { return (double)m_ticksTotal * 1000. / cv::getTickFrequency(); }
|
||||
// No synchronization
|
||||
double getMeanMs() const { return (double)m_ticksTotal * 1000. / (m_counter * cv::getTickFrequency()); }
|
||||
|
||||
bool m_funError;
|
||||
bool m_stopPoint;
|
||||
};
|
||||
bool operator==(const NodeData& lhs, const NodeData& rhs);
|
||||
|
||||
typedef Node<NodeData> InstrNode;
|
||||
|
||||
CV_EXPORTS InstrNode* getTrace();
|
||||
|
||||
#endif // !defined OPENCV_ABI_CHECK
|
||||
|
||||
|
||||
CV_EXPORTS bool useInstrumentation();
|
||||
CV_EXPORTS void setUseInstrumentation(bool flag);
|
||||
CV_EXPORTS InstrNode* getTrace();
|
||||
CV_EXPORTS void resetTrace();
|
||||
CV_EXPORTS void setFlags(int modeFlags);
|
||||
CV_EXPORTS int getFlags();
|
||||
|
||||
enum FLAGS
|
||||
{
|
||||
FLAGS_NONE = 0,
|
||||
FLAGS_MAPPING = 1 << 0,
|
||||
};
|
||||
|
||||
CV_EXPORTS void setFlags(FLAGS modeFlags);
|
||||
static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
|
||||
CV_EXPORTS FLAGS getFlags();
|
||||
}
|
||||
|
||||
} //namespace cv
|
||||
|
||||
Reference in New Issue
Block a user