14#include "arcane/impl/internal/ThreadBindingMng.h"
16#include "arcane/utils/ITraceMng.h"
18#include "arcane/utils/PlatformUtils.h"
19#include "arcane/utils/IProcessorAffinityService.h"
20#include "arcane/utils/internal/TaskFactoryInternal.h"
33: m_thread_created_callback(new ObserverT<ThreadBindingMng>(this, &ThreadBindingMng::_createThreadCallback))
44 delete m_thread_created_callback;
50void ThreadBindingMng::
51initialize(ITraceMng* tm,
const String& strategy)
54 m_bind_strategy = strategy;
57 if (!m_bind_strategy.null()){
58 if (m_bind_strategy!=
"Simple")
59 ARCANE_FATAL(
"Invalid strategy '{0}'. Valid values are : 'Simple'",m_bind_strategy);
60 m_max_thread = TaskFactory::nbAllowedThread();
62 tm->info() <<
"Thread binding strategy is '" << m_bind_strategy <<
"'";
63 TaskFactoryInternal::addThreadCreateObserver(m_thread_created_callback);
64 m_has_callback =
true;
71void ThreadBindingMng::
75 TaskFactoryInternal::removeThreadCreateObserver(m_thread_created_callback);
76 m_has_callback =
false;
83void ThreadBindingMng::
84_createThreadCallback()
88 ITraceMng* tm = m_trace_mng;
89 Int32 thread_index = m_current_thread_index;
90 ++m_current_thread_index;
92 IProcessorAffinityService* pas = platform::getProcessorAffinityService();
95 tm->info() <<
"WARNING: Can not bind thread because there is no 'IProcessorAffinityService'";
100 if (thread_index<m_max_thread){
101 pas->bindThread(thread_index);
102 tm->info() <<
"Binding thread index=" << thread_index <<
" cpuset=" << pas->cpuSetString();
105 tm->
info() <<
"WARNING: thread index is greater than maximum number of allowed thread. No binding done";
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classes, Types et macros pour gérer la concurrence.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
TraceMessage info() const
Flot pour un message d'information.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-