Skip to content

Commit

Permalink
Remove redundant comments and debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
avolkov-intel committed Jul 4, 2024
1 parent c960c03 commit 1e18b5e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 58 deletions.
1 change: 0 additions & 1 deletion cpp/daal/include/services/env_detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class DAAL_EXPORT Environment : public Base
void initNumberOfThreads();

env _env;
// void * _globalControl;
SharedPtr<services::internal::sycl::ExecutionContextIface> _executionContext;
};
} // namespace interface1
Expand Down
31 changes: 3 additions & 28 deletions cpp/daal/src/externals/core_threading_win_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 2 additions & 9 deletions cpp/daal/src/services/env_detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "src/externals/service_service.h"
#include "src/threading/threading.h"
#include "services/error_indexes.h"
#include <iostream>

#include "src/services/service_topo.h"
#include "src/threading/service_thread_pinner.h"
Expand Down Expand Up @@ -126,21 +125,19 @@ 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() {}

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())
Expand All @@ -150,25 +147,21 @@ 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);
}
}
else
{
std::cerr << "Init with " << (_daal_threader_get_max_threads()) << std::endl;
daal::services::Environment::setNumberOfThreads(_daal_threader_get_max_threads());
}
isInit = true;
}

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)
Expand Down
21 changes: 2 additions & 19 deletions cpp/daal/src/threading/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,16 @@
#include <tbb/global_control.h>
#include <tbb/task_arena.h>
#include "services/daal_atomic_int.h"
#include <iostream>

#if defined(TBB_INTERFACE_VERSION) && TBB_INTERFACE_VERSION >= 12002
#include <tbb/task.h>
#endif

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<tbb::task_arena *>(_taskArena);
Expand All @@ -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<tbb::task_arena *>(_taskArena);
Expand All @@ -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<tbb::global_control *>(globalControl);
// globalControl = nullptr;
// }
// }

DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads)
{
static tbb::spin_mutex mt;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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<tbb::task_arena *>(daal::threader_env()->getTaskArena());
taskArena->execute([&] {
Expand Down
1 change: 0 additions & 1 deletion cpp/daal/src/threading/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1e18b5e

Please sign in to comment.