From 6274d7d244899097a3bf4ac930afc9dfb2a39ae9 Mon Sep 17 00:00:00 2001 From: Anatoly Volkov Date: Wed, 10 Jul 2024 05:02:37 -0700 Subject: [PATCH] Add debug prints --- cpp/daal/src/services/env_detect.cpp | 6 ++++++ cpp/daal/src/threading/threading.cpp | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cpp/daal/src/services/env_detect.cpp b/cpp/daal/src/services/env_detect.cpp index 3f3f08246df..14da127c40a 100644 --- a/cpp/daal/src/services/env_detect.cpp +++ b/cpp/daal/src/services/env_detect.cpp @@ -28,6 +28,7 @@ #include "src/externals/service_service.h" #include "src/threading/threading.h" #include "services/error_indexes.h" +#include #include "src/services/service_topo.h" #include "src/threading/service_thread_pinner.h" @@ -127,6 +128,7 @@ DAAL_EXPORT void daal::services::Environment::setDynamicLibraryThreadingTypeOnWi DAAL_EXPORT daal::services::Environment::Environment() { + std::cout << "Env constructor" << std::endl; _env.cpuid_init_flag = false; _env.cpuid = -1; this->setDefaultExecutionContext(internal::CpuExecutionContext()); @@ -138,6 +140,7 @@ DAAL_EXPORT daal::services::Environment::Environment(const Environment & e) : da DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() { if (isInit) return; + std::cout << "Inside init number of threads" << std::endl; /* if HT enabled - set _numThreads to physical cores num */ if (daal::internal::ServiceInst::serv_get_ht()) @@ -149,11 +152,13 @@ DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() if (ncores > 0) { + std::cout << "(ht enabled) init with " << ncores << std::endl; daal::services::Environment::setNumberOfThreads(ncores); } } else { + std::cout << "(ht disabled) init with " << _daal_threader_get_max_threads() << std::endl; daal::services::Environment::setNumberOfThreads(_daal_threader_get_max_threads()); } isInit = true; @@ -161,6 +166,7 @@ DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() DAAL_EXPORT daal::services::Environment::~Environment() { + std::cout << "Env destructor" << std::endl; daal::services::daal_free_buffers(); } diff --git a/cpp/daal/src/threading/threading.cpp b/cpp/daal/src/threading/threading.cpp index bf873bcf6a7..b0c4f696ac6 100644 --- a/cpp/daal/src/threading/threading.cpp +++ b/cpp/daal/src/threading/threading.cpp @@ -35,6 +35,7 @@ #include #include #include "services/daal_atomic_int.h" +#include #if defined(TBB_INTERFACE_VERSION) && TBB_INTERFACE_VERSION >= 12002 #include @@ -42,17 +43,23 @@ namespace daal { -ThreaderEnvironment::ThreaderEnvironment() : _numberOfThreads(1), _taskArena(nullptr) {} +ThreaderEnvironment::ThreaderEnvironment() : _numberOfThreads(1), _taskArena(nullptr) +{ + std::cout << "threader env constructor" << std::endl; +} ThreaderEnvironment::~ThreaderEnvironment() { + std::cout << "threader env destructor" << std::endl; if (_taskArena) { + std::cout << "delete task arena" << std::endl; delete reinterpret_cast(_taskArena); _taskArena = nullptr; } } void ThreaderEnvironment::setNumberOfThreads(size_t value) { + std::cout << "set number of threads from " << _numberOfThreads << " to " << value << std::endl; if (_taskArena) { delete reinterpret_cast(_taskArena); @@ -80,12 +87,14 @@ DAAL_EXPORT void _threaded_scalable_free(void * ptr) DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads) { + std::cout << "set nthreads " << numThreads << std::endl; static tbb::spin_mutex mt; tbb::spin_mutex::scoped_lock lock(mt); if (numThreads > 1) { const size_t maxNumThreads = _daal_threader_get_max_threads(); const size_t limitedNumThreads = numThreads < maxNumThreads ? numThreads : maxNumThreads; + std::cout << "Set number of threads to " << limitedNumThreads << " max(" << maxNumThreads << ")" << std::endl; daal::threader_env()->setNumberOfThreads(limitedNumThreads); return limitedNumThreads; }