Commit 41445775 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Operator for ID00
Browse files

Simplify calculation of CPUAffinity envelop in lists of objs:

* Proposed by S. Debionne
parent f6754333
Pipeline #5525 failed with stages
in 23 seconds
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "lima/CtControl.h" #include "lima/CtControl.h"
#include "lima/SimplePipe.h" #include "lima/SimplePipe.h"
#include <numeric>
namespace lima namespace lima
{ {
...@@ -214,11 +216,9 @@ typedef std::vector<CPUAffinity> CPUAffinityList; ...@@ -214,11 +216,9 @@ typedef std::vector<CPUAffinity> CPUAffinityList;
inline CPUAffinity CPUAffinityList_all(const CPUAffinityList& l) inline CPUAffinity CPUAffinityList_all(const CPUAffinityList& l)
{ {
CPUAffinity all; CPUAffinity all;
if (l.size() > 0) { if (!l.empty())
CPUAffinityList::const_iterator it, end = l.end(); all = std::accumulate(std::next(l.begin()), l.end(), l.front(),
for (all = *(it = l.begin())++; it != end; ++it) std::bit_or<CPUAffinity>());
all |= *it;
}
return all; return all;
} }
...@@ -368,6 +368,15 @@ bool operator !=(const NetDevGroupCPUAffinity& a, ...@@ -368,6 +368,15 @@ bool operator !=(const NetDevGroupCPUAffinity& a,
typedef std::vector<NetDevGroupCPUAffinity> NetDevGroupCPUAffinityList; typedef std::vector<NetDevGroupCPUAffinity> NetDevGroupCPUAffinityList;
inline CPUAffinity NetDevGroupCPUAffinityList_all(
const NetDevGroupCPUAffinityList& l)
{
CPUAffinityList netdev_aff_list;
NetDevGroupCPUAffinityList::const_iterator it, end = l.end();
for (it = l.begin(); it != end; ++it)
netdev_aff_list.push_back(it->all());
return CPUAffinityList_all(netdev_aff_list);
}
class SystemCPUAffinityMgr class SystemCPUAffinityMgr
{ {
...@@ -504,6 +513,15 @@ bool operator !=(const RecvCPUAffinity& a, const RecvCPUAffinity& b) ...@@ -504,6 +513,15 @@ bool operator !=(const RecvCPUAffinity& a, const RecvCPUAffinity& b)
typedef std::vector<RecvCPUAffinity> RecvCPUAffinityList; typedef std::vector<RecvCPUAffinity> RecvCPUAffinityList;
inline CPUAffinity RecvCPUAffinityList_all(const RecvCPUAffinityList& l)
{
CPUAffinityList recv_aff_list;
RecvCPUAffinityList::const_iterator it, end = l.end();
for (it = l.begin(); it != end; ++it)
recv_aff_list.push_back(it->all());
return CPUAffinityList_all(recv_aff_list);
}
struct GlobalCPUAffinity { struct GlobalCPUAffinity {
RecvCPUAffinityList recv; RecvCPUAffinityList recv;
CPUAffinity lima; CPUAffinity lima;
......
...@@ -292,6 +292,9 @@ struct NetDevGroupCPUAffinity { ...@@ -292,6 +292,9 @@ struct NetDevGroupCPUAffinity {
// typedef std::vector<SlsDetector::NetDevGroupCPUAffinity> // typedef std::vector<SlsDetector::NetDevGroupCPUAffinity>
// NetDevGroupCPUAffinityList; // NetDevGroupCPUAffinityList;
SlsDetector::CPUAffinity NetDevGroupCPUAffinityList_all(
const SlsDetector::NetDevGroupCPUAffinityList& l);
class SystemCPUAffinityMgr class SystemCPUAffinityMgr
{ {
public: public:
...@@ -329,6 +332,9 @@ struct RecvCPUAffinity { ...@@ -329,6 +332,9 @@ struct RecvCPUAffinity {
// typedef std::vector<RecvCPUAffinity> RecvCPUAffinityList; // typedef std::vector<RecvCPUAffinity> RecvCPUAffinityList;
SlsDetector::CPUAffinity RecvCPUAffinityList_all(
const SlsDetector::RecvCPUAffinityList& l);
struct GlobalCPUAffinity { struct GlobalCPUAffinity {
SlsDetector::RecvCPUAffinityList recv; SlsDetector::RecvCPUAffinityList recv;
SlsDetector::CPUAffinity lima; SlsDetector::CPUAffinity lima;
......
...@@ -1345,14 +1345,8 @@ RecvCPUAffinity& RecvCPUAffinity::operator =(CPUAffinity a) ...@@ -1345,14 +1345,8 @@ RecvCPUAffinity& RecvCPUAffinity::operator =(CPUAffinity a)
CPUAffinity GlobalCPUAffinity::all() const CPUAffinity GlobalCPUAffinity::all() const
{ {
CPUAffinity all = lima | other; return (RecvCPUAffinityList_all(recv) |
RecvCPUAffinityList::const_iterator rit, rend = recv.end(); NetDevGroupCPUAffinityList_all(netdev) | lima | other);
for (rit = recv.begin(); rit != rend; ++rit)
all |= rit->all();
NetDevGroupCPUAffinityList::const_iterator nit, nend = netdev.end();
for (nit = netdev.begin(); nit != nend; ++nit)
all |= nit->all();
return all;
} }
void GlobalCPUAffinity::updateRecvAffinity(CPUAffinity a) void GlobalCPUAffinity::updateRecvAffinity(CPUAffinity a)
...@@ -1626,12 +1620,8 @@ void GlobalCPUAffinityMgr::recvFinished() ...@@ -1626,12 +1620,8 @@ void GlobalCPUAffinityMgr::recvFinished()
if (m_state == Ready) if (m_state == Ready)
return; return;
CPUAffinity recv_all; CPUAffinity recv_all = RecvCPUAffinityList_all(m_curr.recv);
RecvCPUAffinityList::const_iterator it, end = m_curr.recv.end(); DEB_TRACE() << DEB_VAR2(m_curr.lima, recv_all);
if ((it = m_curr.recv.begin()) != end)
for (recv_all = (*it++).all(); it != end; ++it)
recv_all |= it->all();
if (m_curr.lima != recv_all) { if (m_curr.lima != recv_all) {
m_state = Changing; m_state = Changing;
AutoMutexUnlock u(l); AutoMutexUnlock u(l);
......
Supports Markdown
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