Commit 8fc4a7d0 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

slsDetectorPackage: formalize CPU & NUMA affinities

parent 37563769
Pipeline #50796 failed with stages
in 12 minutes and 50 seconds
......@@ -176,9 +176,6 @@ class CPUAffinity
bool isDefault() const
{ return m_mask.none() || (m_mask == allCPUs()); }
void getNUMANodeMask(std::vector<unsigned long>& node_mask,
int& max_node);
static std::string getProcDir(bool local_threads);
static std::string getTaskProcDir(pid_t task, bool is_thread);
......
......@@ -292,9 +292,6 @@ public:
bool isDefault() const;
void getNUMANodeMask(std::vector<unsigned long>& node_mask /Out/,
int& max_node /Out/);
static std::string getProcDir(bool local_threads);
static std::string getTaskProcDir(int task, bool is_thread);
};
......
Subproject commit 04548fc48c7fb634cafc65ff5ac807a3580b4fb5
Subproject commit 54ab3977285689830b603cb440402ddad7f4e91f
......@@ -64,6 +64,9 @@ void BufferMgr::setBufferCPUAffinity(CPUAffinity buffer_affinity)
{
DEB_MEMBER_FUNCT();
DEB_ALWAYS() << DEB_VAR1(buffer_affinity);
DEB_ALWAYS() << "node_mask="
<< NumaNodeMask::fromCPUMask(buffer_affinity.getMask());
BufferCtrlObj *buffer = getBufferCtrlObj();
if (buffer)
buffer->setCPUAffinityMask(buffer_affinity.getMask());
......
......@@ -452,45 +452,6 @@ void CPUAffinity::applyWithSetAffinity(pid_t task, bool incl_threads) const
}
}
void CPUAffinity::getNUMANodeMask(vector<unsigned long>& node_mask,
int& max_node)
{
DEB_MEMBER_FUNCT();
typedef vector<unsigned long> Array;
int nb_nodes = numa_max_node() + 1;
const int item_bits = sizeof(Array::reference) * 8;
int nb_items = nb_nodes / item_bits;
if (nb_nodes % item_bits != 0)
++nb_items;
DEB_PARAM() << DEB_VAR2(*this, nb_items);
max_node = nb_nodes + 1;
node_mask.assign(nb_items, 0);
Mask mask = getMask();
for (unsigned int i = 0; i < MaxNbCPUs; ++i) {
if (mask.test(i)) {
unsigned int n = numa_node_of_cpu(i);
Array::reference v = node_mask[n / item_bits];
v |= 1L << (n % item_bits);
}
}
if (DEB_CHECK_ANY(DebTypeReturn)) {
ostringstream os;
os << hex << "0x" << setw(nb_nodes / 4) << setfill('0');
bool first = true;
Array::reverse_iterator it, end = node_mask.rend();
for (it = node_mask.rbegin(); it != end; ++it, first = false)
os << (!first ? "," : "") << *it;
DEB_RETURN() << "node_mask=" << os.str() << ", "
<< DEB_VAR1(max_node);
}
}
void CPUAffinity::maskToULongArray(const Mask& mask, ULongArray& array)
{
constexpr Mask ULongMask(std::numeric_limits<unsigned long>::max());
......
......@@ -88,45 +88,14 @@ void Receiver::setCPUAffinity(const RecvCPUAffinity& recv_affinity)
{
DEB_MEMBER_FUNCT();
using namespace sls::CPUAffinity;
const CPUAffinityList& aff_list = recv_affinity.listeners;
slsDetectorDefs::CPUMaskList cpu_masks(aff_list.size());
slsDetectorDefs::CPUMaskList::iterator mit = cpu_masks.begin();
FixedCPUSetAffinityList cpu_masks(aff_list.size());
FixedCPUSetAffinityList::iterator mit = cpu_masks.begin();
CPUAffinityList::const_iterator it, end = aff_list.end();
for (it = aff_list.begin(); it != end; ++it, ++mit)
it->initCPUSet(*mit);
m_recv->setThreadCPUAffinity(cpu_masks);
string deb_head;
if (DEB_CHECK_ANY(DebTypeTrace) || DEB_CHECK_ANY(DebTypeWarning)) {
ostringstream os;
os << "setting recv " << m_idx << " ";
deb_head = os.str();
}
CPUAffinity aff = recv_affinity.all();
int max_node;
typedef vector<unsigned long> NumaNodeList;
NumaNodeList mlist;
aff.getNUMANodeMask(mlist, max_node);
if (mlist.size() > 1) {
bool ok = true;
NumaNodeList::iterator it, end = mlist.end();
for (it = mlist.begin() + 1; ok && (it != end); ++it)
ok = (*it == 0);
if (!ok) {
PrettyList<NumaNodeList> pretty_list(mlist);
THROW_HW_ERROR(Error) << "Recv " << m_idx << " "
<< "uses more than one node:"
<< pretty_list;
}
}
unsigned long& fifo_node_mask = mlist[0];
int c = bitset<64>(fifo_node_mask).count();
if (c != 1)
DEB_WARNING() << deb_head << "Fifo NUMA node mask has "
<< c << " nodes";
DEB_ALWAYS() << deb_head << DEB_VAR2(DEB_HEX(fifo_node_mask), max_node);
m_recv->setBufferNodeAffinity(fifo_node_mask, max_node);
it->initCPUSet(mit->cpu_mask().cpu_set());
m_recv->setListenersCPUAffinity(cpu_masks);
}
AutoPtr<Receiver::ImagePackets> Receiver::readSkippableImagePackets()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment