mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Merge pull request #16093 from alalek:core_itt_thread_name_16072
This commit is contained in:
commit
a2642d83d3
@ -16,6 +16,8 @@
|
|||||||
//#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
|
//#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
|
||||||
#include <opencv2/core/utils/logger.hpp>
|
#include <opencv2/core/utils/logger.hpp>
|
||||||
|
|
||||||
|
#include <opencv2/core/utils/trace.private.hpp>
|
||||||
|
|
||||||
//#define CV_PROFILE_THREADS 64
|
//#define CV_PROFILE_THREADS 64
|
||||||
//#define getTickCount getCPUTickCount // use this if getTickCount() calls are expensive (and getCPUTickCount() is accurate)
|
//#define getTickCount getCPUTickCount // use this if getTickCount() calls are expensive (and getCPUTickCount() is accurate)
|
||||||
|
|
||||||
@ -276,6 +278,9 @@ public:
|
|||||||
void thread_body();
|
void thread_body();
|
||||||
static void* thread_loop_wrapper(void* thread_object)
|
static void* thread_loop_wrapper(void* thread_object)
|
||||||
{
|
{
|
||||||
|
#ifdef OPENCV_WITH_ITT
|
||||||
|
__itt_thread_set_name(cv::format("OpenCVThread-%03d", cv::utils::getThreadID()).c_str());
|
||||||
|
#endif
|
||||||
((WorkerThread*)thread_object)->thread_body();
|
((WorkerThread*)thread_object)->thread_body();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1888,6 +1888,15 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID lpReserved)
|
|||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
#ifdef OPENCV_WITH_ITT
|
||||||
|
bool overrideThreadName()
|
||||||
|
{
|
||||||
|
static bool param = utils::getConfigurationParameterBool("OPENCV_TRACE_ITT_SET_THREAD_NAME", false);
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int g_threadNum = 0;
|
static int g_threadNum = 0;
|
||||||
class ThreadID {
|
class ThreadID {
|
||||||
public:
|
public:
|
||||||
@ -1896,7 +1905,8 @@ public:
|
|||||||
id(CV_XADD(&g_threadNum, 1))
|
id(CV_XADD(&g_threadNum, 1))
|
||||||
{
|
{
|
||||||
#ifdef OPENCV_WITH_ITT
|
#ifdef OPENCV_WITH_ITT
|
||||||
__itt_thread_set_name(cv::format("OpenCVThread-%03d", id).c_str());
|
if (overrideThreadName())
|
||||||
|
__itt_thread_set_name(cv::format("OpenCVThread-%03d", id).c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user