Skip to content

Commit

Permalink
Add arena initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
avolkov-intel committed Jul 12, 2024
1 parent 6274d7d commit c2b2b08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cpp/daal/src/threading/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@

namespace daal
{
ThreaderEnvironment::ThreaderEnvironment() : _numberOfThreads(1), _taskArena(nullptr)
ThreaderEnvironment::ThreaderEnvironment() : _numberOfThreads(1), _taskArena(nullptr), _schedulerHandle(nullptr)
{
std::cout << "threader env constructor" << std::endl;
#if defined(TARGET_X86_64)
_schedulerHandle = reinterpret_cast<void*>(new tbb::task_scheduler_handle(tbb::attach {}));
#endif
tbb::task_arena {}.initialize();
std::cout << "threader env constructor end" << std::endl;

Check notice on line 54 in cpp/daal/src/threading/threading.cpp

View check run for this annotation

codefactor.io / CodeFactor

cpp/daal/src/threading/threading.cpp#L54

Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
}
ThreaderEnvironment::~ThreaderEnvironment()
{
Expand All @@ -55,6 +61,7 @@ ThreaderEnvironment::~ThreaderEnvironment()
std::cout << "delete task arena" << std::endl;
delete reinterpret_cast<tbb::task_arena *>(_taskArena);
_taskArena = nullptr;
std::cout << "after delete task arena" << std::endl;
}
}
void ThreaderEnvironment::setNumberOfThreads(size_t value)
Expand All @@ -67,7 +74,9 @@ void ThreaderEnvironment::setNumberOfThreads(size_t value)
}
if (value > 1)
{
_taskArena = reinterpret_cast<void *>(new tbb::task_arena(value));
tbb::task_arena* arenaPtr = new tbb::task_arena(value);
// arenaPtr->initialize();
_taskArena = reinterpret_cast<void *>(arenaPtr);
}
_numberOfThreads = value;
}
Expand Down
1 change: 1 addition & 0 deletions cpp/daal/src/threading/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class ThreaderEnvironment
private:
size_t _numberOfThreads;
void * _taskArena;
void * _schedulerHandle;
};

inline ThreaderEnvironment * threader_env()
Expand Down

0 comments on commit c2b2b08

Please sign in to comment.