From 1e18b5e64072f04f4c9eb5134aa51353e049ab5b Mon Sep 17 00:00:00 2001 From: Anatoly Volkov Date: Thu, 4 Jul 2024 08:03:04 -0700 Subject: [PATCH] Remove redundant comments and debug prints --- cpp/daal/include/services/env_detect.h | 1 - .../src/externals/core_threading_win_dll.cpp | 31 ++----------------- cpp/daal/src/services/env_detect.cpp | 11 ++----- cpp/daal/src/threading/threading.cpp | 21 ++----------- cpp/daal/src/threading/threading.h | 1 - 5 files changed, 7 insertions(+), 58 deletions(-) diff --git a/cpp/daal/include/services/env_detect.h b/cpp/daal/include/services/env_detect.h index 76d2f2bdbba..5d50892aa48 100644 --- a/cpp/daal/include/services/env_detect.h +++ b/cpp/daal/include/services/env_detect.h @@ -198,7 +198,6 @@ class DAAL_EXPORT Environment : public Base void initNumberOfThreads(); env _env; - // void * _globalControl; SharedPtr _executionContext; }; } // namespace interface1 diff --git a/cpp/daal/src/externals/core_threading_win_dll.cpp b/cpp/daal/src/externals/core_threading_win_dll.cpp index f3e6791b50d..bda02c19f66 100644 --- a/cpp/daal/src/externals/core_threading_win_dll.cpp +++ b/cpp/daal/src/externals/core_threading_win_dll.cpp @@ -142,8 +142,7 @@ typedef void (*_daal_run_task_group_t)(void * taskGroupPtr, daal::task * t); typedef void (*_daal_wait_task_group_t)(void * taskGroupPtr); typedef bool (*_daal_is_in_parallel_t)(); -// typedef void (*_daal_tbb_task_scheduler_free_t)(void *& globalControl); -typedef size_t (*_setNumberOfThreads_t)(const size_t); //, void **); +typedef size_t (*_setNumberOfThreads_t)(const size_t); typedef void * (*_daal_threader_env_t)(); typedef void (*_daal_parallel_sort_int32_t)(int *, int *); @@ -206,9 +205,8 @@ static _daal_run_task_group_t _daal_run_task_group_ptr = NULL; static _daal_wait_task_group_t _daal_wait_task_group_ptr = NULL; static _daal_is_in_parallel_t _daal_is_in_parallel_ptr = NULL; -// static _daal_tbb_task_scheduler_free_t _daal_tbb_task_scheduler_free_ptr = NULL; -static _setNumberOfThreads_t _setNumberOfThreads_ptr = NULL; -static _daal_threader_env_t _daal_threader_env_ptr = NULL; +static _setNumberOfThreads_t _setNumberOfThreads_ptr = NULL; +static _daal_threader_env_t _daal_threader_env_ptr = NULL; static _daal_parallel_sort_int32_t _daal_parallel_sort_int32_ptr = NULL; static _daal_parallel_sort_uint64_t _daal_parallel_sort_uint64_ptr = NULL; @@ -636,29 +634,6 @@ DAAL_EXPORT bool _daal_is_in_parallel() return _daal_is_in_parallel_ptr(); } -/* -DAAL_EXPORT void _daal_tbb_task_scheduler_free(void *& init) -{ - if (init == NULL) - { - // If threading library was not opened, there is nothing to free, - // so we do not need to load threading library. - // Moreover, loading threading library in the Environment destructor - // results in a crush because of the use of Wintrust library after it was unloaded. - // This happens due to undefined order of static objects deinitialization - // like Environment, and dependent libraries. - return; - } - - load_daal_thr_dll(); - if (_daal_tbb_task_scheduler_free_ptr == NULL) - { - _daal_tbb_task_scheduler_free_ptr = (_daal_tbb_task_scheduler_free_t)load_daal_thr_func("_daal_tbb_task_scheduler_free"); - } - return _daal_tbb_task_scheduler_free_ptr(init); -} -*/ - DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads /*, void ** init*/) { load_daal_thr_dll(); diff --git a/cpp/daal/src/services/env_detect.cpp b/cpp/daal/src/services/env_detect.cpp index 036f2801702..3f3f08246df 100644 --- a/cpp/daal/src/services/env_detect.cpp +++ b/cpp/daal/src/services/env_detect.cpp @@ -28,7 +28,6 @@ #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" @@ -126,13 +125,12 @@ DAAL_EXPORT void daal::services::Environment::setDynamicLibraryThreadingTypeOnWi initNumberOfThreads(); } -DAAL_EXPORT daal::services::Environment::Environment() /* : _globalControl {}*/ +DAAL_EXPORT daal::services::Environment::Environment() { - std::cerr << "Environment constructor" << std::endl; _env.cpuid_init_flag = false; _env.cpuid = -1; this->setDefaultExecutionContext(internal::CpuExecutionContext()); - daal::services::Environment::initNumberOfThreads(); + initNumberOfThreads(); } DAAL_EXPORT daal::services::Environment::Environment(const Environment & e) : daal::services::Environment::Environment() {} @@ -140,7 +138,6 @@ DAAL_EXPORT daal::services::Environment::Environment(const Environment & e) : da DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() { if (isInit) return; - std::cerr << "Inside init" << std::endl; /* if HT enabled - set _numThreads to physical cores num */ if (daal::internal::ServiceInst::serv_get_ht()) @@ -150,7 +147,6 @@ DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() /* Re-set number of threads if ncores is valid and different to _numThreads */ - std::cerr << "Init with " << ncores << std::endl; if (ncores > 0) { daal::services::Environment::setNumberOfThreads(ncores); @@ -158,7 +154,6 @@ DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() } else { - std::cerr << "Init with " << (_daal_threader_get_max_threads()) << std::endl; daal::services::Environment::setNumberOfThreads(_daal_threader_get_max_threads()); } isInit = true; @@ -166,9 +161,7 @@ DAAL_EXPORT void daal::services::Environment::initNumberOfThreads() DAAL_EXPORT daal::services::Environment::~Environment() { - std::cerr << "Env destructor" << std::endl; daal::services::daal_free_buffers(); - // _daal_tbb_task_scheduler_free(_globalControl); } void daal::services::Environment::_cpu_detect(int enable) diff --git a/cpp/daal/src/threading/threading.cpp b/cpp/daal/src/threading/threading.cpp index 73109fae214..bf873bcf6a7 100644 --- a/cpp/daal/src/threading/threading.cpp +++ b/cpp/daal/src/threading/threading.cpp @@ -35,7 +35,6 @@ #include #include #include "services/daal_atomic_int.h" -#include #if defined(TBB_INTERFACE_VERSION) && TBB_INTERFACE_VERSION >= 12002 #include @@ -43,13 +42,9 @@ namespace daal { -ThreaderEnvironment::ThreaderEnvironment() : _numberOfThreads(1), _taskArena(nullptr) -{ - std::cout << "ThreaderEnv constructor" << std::endl; -} +ThreaderEnvironment::ThreaderEnvironment() : _numberOfThreads(1), _taskArena(nullptr) {} ThreaderEnvironment::~ThreaderEnvironment() { - std::cerr << "ThreaderEnv destructor" << std::endl; if (_taskArena) { delete reinterpret_cast(_taskArena); @@ -58,7 +53,6 @@ ThreaderEnvironment::~ThreaderEnvironment() } void ThreaderEnvironment::setNumberOfThreads(size_t value) { - std::cerr << "setNumberOfThreads from " << (_numberOfThreads) << " to " << value << std::endl; if (_taskArena) { delete reinterpret_cast(_taskArena); @@ -84,15 +78,6 @@ DAAL_EXPORT void _threaded_scalable_free(void * ptr) scalable_aligned_free(ptr); } -// DAAL_EXPORT void _daal_tbb_task_scheduler_free(void *& globalControl) -// { -// if (globalControl) -// { -// delete reinterpret_cast(globalControl); -// globalControl = nullptr; -// } -// } - DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads) { static tbb::spin_mutex mt; @@ -101,11 +86,9 @@ DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads) { const size_t maxNumThreads = _daal_threader_get_max_threads(); const size_t limitedNumThreads = numThreads < maxNumThreads ? numThreads : maxNumThreads; - std::cerr << "_set nthreads " << numThreads << "(max " << maxNumThreads << ")" << std::endl; daal::threader_env()->setNumberOfThreads(limitedNumThreads); return limitedNumThreads; } - std::cerr << "_set nthreads 1" << std::endl; daal::threader_env()->setNumberOfThreads(1); return 1; } @@ -296,7 +279,7 @@ DAAL_EXPORT void _daal_static_threader_for(size_t n, const void * a, daal::funct { if (daal::threader_env()->getNumberOfThreads() > 1) { - const size_t nthreads = daal::threader_env()->getNumberOfThreads(); //_daal_threader_get_max_threads(); + const size_t nthreads = daal::threader_env()->getNumberOfThreads(); const size_t nblocks_per_thread = n / nthreads + !!(n % nthreads); tbb::task_arena * taskArena = reinterpret_cast(daal::threader_env()->getTaskArena()); taskArena->execute([&] { diff --git a/cpp/daal/src/threading/threading.h b/cpp/daal/src/threading/threading.h index 1bbe05f2de6..730f0e962d3 100644 --- a/cpp/daal/src/threading/threading.h +++ b/cpp/daal/src/threading/threading.h @@ -100,7 +100,6 @@ extern "C" DAAL_EXPORT void _daal_del_task_group(void * taskGroupPtr); DAAL_EXPORT void _daal_run_task_group(void * taskGroupPtr, daal::task * t); DAAL_EXPORT void _daal_wait_task_group(void * taskGroupPtr); - // DAAL_EXPORT void _daal_tbb_task_scheduler_free(void *& globalControl); DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads); DAAL_EXPORT void * _daal_threader_env();