mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
--perf_instrument parameter now has int type and 0, 1, 2 modes (1 - simple trees, 2 - expanded trees for functions with same name but different calling address);
Maximum depth limit var was added to the instrumentation structure; Trace names output console output fix: improper tree formatting could happen; Output in case of error was added; Custom regions improvements; Improved timing and weight calculation for parallel regions; New TC (threads counter) value to indicate how many different threads accessed particular node; parallel_for, warnings fixes and ReturnAddress code from Alexander Alekhin;
This commit is contained in:
+52
-50
@@ -1340,7 +1340,7 @@ void resetTrace()
|
||||
void setFlags(FLAGS modeFlags)
|
||||
{
|
||||
#ifdef ENABLE_INSTRUMENTATION
|
||||
getInstrumentStruct().enableMapping = (modeFlags & FLAGS_MAPPING);
|
||||
getInstrumentStruct().flags = modeFlags;
|
||||
#else
|
||||
CV_UNUSED(modeFlags);
|
||||
#endif
|
||||
@@ -1348,31 +1348,27 @@ void setFlags(FLAGS modeFlags)
|
||||
FLAGS getFlags()
|
||||
{
|
||||
#ifdef ENABLE_INSTRUMENTATION
|
||||
int flags = 0;
|
||||
if(getInstrumentStruct().enableMapping)
|
||||
flags |= FLAGS_MAPPING;
|
||||
return (FLAGS)flags;
|
||||
return (FLAGS)getInstrumentStruct().flags;
|
||||
#else
|
||||
return (FLAGS)0;
|
||||
#endif
|
||||
}
|
||||
|
||||
NodeData::NodeData(const char* funName, const char* fileName, int lineNum, cv::instr::TYPE instrType, cv::instr::IMPL implType)
|
||||
NodeData::NodeData(const char* funName, const char* fileName, int lineNum, void* retAddress, bool alwaysExpand, cv::instr::TYPE instrType, cv::instr::IMPL implType)
|
||||
{
|
||||
m_instrType = TYPE_GENERAL;
|
||||
m_implType = IMPL_PLAIN;
|
||||
m_funName = funName;
|
||||
m_instrType = instrType;
|
||||
m_implType = implType;
|
||||
m_fileName = fileName;
|
||||
m_lineNum = lineNum;
|
||||
m_retAddress = retAddress;
|
||||
m_alwaysExpand = alwaysExpand;
|
||||
|
||||
m_funName = funName;
|
||||
m_instrType = instrType;
|
||||
m_implType = implType;
|
||||
m_fileName = fileName;
|
||||
m_lineNum = lineNum;
|
||||
|
||||
m_counter = 0;
|
||||
m_threads = 1;
|
||||
m_counter = 0;
|
||||
m_ticksTotal = 0;
|
||||
|
||||
m_funError = false;
|
||||
m_stopPoint = false;
|
||||
m_funError = false;
|
||||
}
|
||||
NodeData::NodeData(NodeData &ref)
|
||||
{
|
||||
@@ -1380,15 +1376,20 @@ NodeData::NodeData(NodeData &ref)
|
||||
}
|
||||
NodeData& NodeData::operator=(const NodeData &right)
|
||||
{
|
||||
this->m_funName = right.m_funName;
|
||||
this->m_instrType = right.m_instrType;
|
||||
this->m_implType = right.m_implType;
|
||||
this->m_fileName = right.m_fileName;
|
||||
this->m_lineNum = right.m_lineNum;
|
||||
this->m_funName = right.m_funName;
|
||||
this->m_instrType = right.m_instrType;
|
||||
this->m_implType = right.m_implType;
|
||||
this->m_fileName = right.m_fileName;
|
||||
this->m_lineNum = right.m_lineNum;
|
||||
this->m_retAddress = right.m_retAddress;
|
||||
this->m_alwaysExpand = right.m_alwaysExpand;
|
||||
|
||||
this->m_threads = right.m_threads;
|
||||
this->m_counter = right.m_counter;
|
||||
this->m_ticksTotal = right.m_ticksTotal;
|
||||
|
||||
this->m_funError = right.m_funError;
|
||||
this->m_stopPoint = right.m_stopPoint;
|
||||
|
||||
return *this;
|
||||
}
|
||||
NodeData::~NodeData()
|
||||
@@ -1397,7 +1398,10 @@ NodeData::~NodeData()
|
||||
bool operator==(const NodeData& left, const NodeData& right)
|
||||
{
|
||||
if(left.m_lineNum == right.m_lineNum && left.m_funName == right.m_funName && left.m_fileName == right.m_fileName)
|
||||
return true;
|
||||
{
|
||||
if(left.m_retAddress == right.m_retAddress || !(cv::instr::getFlags()&cv::instr::FLAGS_EXPAND_SAME_NAMES || left.m_alwaysExpand))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1418,7 +1422,7 @@ InstrNode* getCurrentNode()
|
||||
return getInstrumentTLSStruct().pCurrentNode;
|
||||
}
|
||||
|
||||
IntrumentationRegion::IntrumentationRegion(const char* funName, const char* fileName, int lineNum, TYPE instrType, IMPL implType)
|
||||
IntrumentationRegion::IntrumentationRegion(const char* funName, const char* fileName, int lineNum, void *retAddress, bool alwaysExpand, TYPE instrType, IMPL implType)
|
||||
{
|
||||
m_disabled = false;
|
||||
m_regionTicks = 0;
|
||||
@@ -1435,14 +1439,17 @@ IntrumentationRegion::IntrumentationRegion(const char* funName, const char* file
|
||||
return;
|
||||
}
|
||||
|
||||
m_disabled = pTLS->pCurrentNode->m_payload.m_stopPoint;
|
||||
if(m_disabled)
|
||||
int depth = pTLS->pCurrentNode->getDepth();
|
||||
if(pStruct->maxDepth && pStruct->maxDepth <= depth)
|
||||
{
|
||||
m_disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
NodeData payload(funName, fileName, lineNum, instrType, implType);
|
||||
NodeData payload(funName, fileName, lineNum, retAddress, alwaysExpand, instrType, implType);
|
||||
Node<NodeData>* pChild = NULL;
|
||||
|
||||
if(pStruct->enableMapping)
|
||||
if(pStruct->flags&FLAGS_MAPPING)
|
||||
{
|
||||
// Critical section
|
||||
cv::AutoLock guard(pStruct->mutexCreate); // Guard from concurrent child creation
|
||||
@@ -1458,7 +1465,7 @@ IntrumentationRegion::IntrumentationRegion(const char* funName, const char* file
|
||||
pChild = pTLS->pCurrentNode->findChild(payload);
|
||||
if(!pChild)
|
||||
{
|
||||
pTLS->pCurrentNode->m_payload.m_stopPoint = true;
|
||||
m_disabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1476,28 +1483,23 @@ IntrumentationRegion::~IntrumentationRegion()
|
||||
if(!m_disabled)
|
||||
{
|
||||
InstrTLSStruct *pTLS = &getInstrumentTLSStruct();
|
||||
if(pTLS->pCurrentNode->m_payload.m_stopPoint)
|
||||
{
|
||||
pTLS->pCurrentNode->m_payload.m_stopPoint = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pTLS->pCurrentNode->m_payload.m_implType == cv::instr::IMPL_OPENCL &&
|
||||
(pTLS->pCurrentNode->m_payload.m_instrType == cv::instr::TYPE_FUN ||
|
||||
pTLS->pCurrentNode->m_payload.m_instrType == cv::instr::TYPE_WRAPPER))
|
||||
{
|
||||
cv::ocl::finish(); // TODO Support "async" OpenCL instrumentation
|
||||
}
|
||||
|
||||
uint64 ticks = (getTickCount() - m_regionTicks);
|
||||
{
|
||||
cv::AutoLock guard(pStruct->mutexCount); // Concurrent ticks accumulation
|
||||
pTLS->pCurrentNode->m_payload.m_counter++;
|
||||
pTLS->pCurrentNode->m_payload.m_ticksTotal += ticks;
|
||||
}
|
||||
|
||||
pTLS->pCurrentNode = pTLS->pCurrentNode->m_pParent;
|
||||
if (pTLS->pCurrentNode->m_payload.m_implType == cv::instr::IMPL_OPENCL &&
|
||||
(pTLS->pCurrentNode->m_payload.m_instrType == cv::instr::TYPE_FUN ||
|
||||
pTLS->pCurrentNode->m_payload.m_instrType == cv::instr::TYPE_WRAPPER))
|
||||
{
|
||||
cv::ocl::finish(); // TODO Support "async" OpenCL instrumentation
|
||||
}
|
||||
|
||||
uint64 ticks = (getTickCount() - m_regionTicks);
|
||||
{
|
||||
cv::AutoLock guard(pStruct->mutexCount); // Concurrent ticks accumulation
|
||||
pTLS->pCurrentNode->m_payload.m_counter++;
|
||||
pTLS->pCurrentNode->m_payload.m_ticksTotal += ticks;
|
||||
pTLS->pCurrentNode->m_payload.m_tls.get()->m_ticksTotal += ticks;
|
||||
}
|
||||
|
||||
pTLS->pCurrentNode = pTLS->pCurrentNode->m_pParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user