Commit ff307a65 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Add RecvCPUAffinity with independent listeners and writers CPUAffinity

parent 309a1908
......@@ -148,10 +148,39 @@ class ProcCPUAffinityMgr
AutoPtr<WatchDog> m_watchdog;
};
struct RecvCPUAffinity {
CPUAffinity listeners;
CPUAffinity writers;
CPUAffinity all() const
{
return listeners | writers;
}
RecvCPUAffinity& operator =(CPUAffinity a)
{
listeners = writers = a;
return *this;
}
};
inline
bool operator ==(const RecvCPUAffinity& a, const RecvCPUAffinity& b)
{
return ((a.listeners == b.listeners) && (a.writers == b.writers));
}
inline
bool operator !=(const RecvCPUAffinity& a, const RecvCPUAffinity& b)
{
return !(a == b);
}
struct SystemCPUAffinity {
CPUAffinity recv;
CPUAffinity lima;
CPUAffinity other;
RecvCPUAffinity recv;
CPUAffinity lima;
CPUAffinity other;
};
typedef std::map<PixelDepth, SystemCPUAffinity> PixelDepthCPUAffinityMap;
......@@ -234,7 +263,7 @@ class SystemCPUAffinityMgr
};
void setLimaAffinity(CPUAffinity lima_affinity);
void setRecvAffinity(CPUAffinity recv_affinity);
void setRecvAffinity(const RecvCPUAffinity& recv_affinity);
AutoMutex lock()
{ return AutoMutex(m_cond.mutex()); }
......@@ -251,6 +280,7 @@ class SystemCPUAffinityMgr
};
std::ostream& operator <<(std::ostream& os, const CPUAffinity& a);
std::ostream& operator <<(std::ostream& os, const RecvCPUAffinity& a);
std::ostream& operator <<(std::ostream& os, const SystemCPUAffinity& a);
std::ostream& operator <<(std::ostream& os, const PixelDepthCPUAffinityMap& m);
......
......@@ -357,7 +357,7 @@ private:
void updateImageSize();
void updateTimeRanges();
void updateCPUAffinity(bool recv_restarted);
void setRecvCPUAffinity(CPUAffinity recv_affinity);
void setRecvCPUAffinity(const RecvCPUAffinity& recv_affinity);
static int64_t NSec(double x)
{ return int64_t(x * 1e9); }
......
......@@ -163,8 +163,16 @@ public:
SlsDetector::CPUAffinity affinity);
};
struct RecvCPUAffinity {
SlsDetector::CPUAffinity listeners;
SlsDetector::CPUAffinity writers;
SlsDetector::CPUAffinity all() const;
// RecvCPUAffinity& operator =(CPUAffinity a);
};
struct SystemCPUAffinity {
SlsDetector::CPUAffinity recv;
SlsDetector::RecvCPUAffinity recv;
SlsDetector::CPUAffinity lima;
SlsDetector::CPUAffinity other;
};
......
......@@ -603,7 +603,7 @@ void SystemCPUAffinityMgr::applyAndSet(const SystemCPUAffinity& o)
if (!m_cam)
THROW_HW_ERROR(InvalidValue) << "apply without camera";
CPUAffinity all_system = o.recv | o.lima | o.other;
CPUAffinity all_system = o.recv.all() | o.lima | o.other;
cpu_set_t all_cpu_set;
all_system.initCPUSet(all_cpu_set);
if (CPU_COUNT(&all_cpu_set) <= CPUAffinity::getNbCPUs() / 2)
......@@ -641,7 +641,7 @@ void SystemCPUAffinityMgr::setLimaAffinity(CPUAffinity lima_affinity)
m_curr.lima = lima_affinity;
}
void SystemCPUAffinityMgr::setRecvAffinity(CPUAffinity recv_affinity)
void SystemCPUAffinityMgr::setRecvAffinity(const RecvCPUAffinity& recv_affinity)
{
DEB_MEMBER_FUNCT();
......@@ -703,7 +703,7 @@ void SystemCPUAffinityMgr::recvFinished()
if (m_state == Ready)
return;
if (m_curr.lima != m_curr.recv) {
if (m_curr.lima != m_curr.recv.all()) {
m_state = Changing;
AutoMutexUnlock u(l);
ProcCPUAffinityMgr::Filter filter;
......@@ -712,7 +712,7 @@ void SystemCPUAffinityMgr::recvFinished()
m_curr.lima);
DEB_ALWAYS() << "Lima TIDs: " << PrettyIntList(m_lima_tids);
CPUAffinity lima_affinity = (uint64_t(m_curr.lima) |
uint64_t(m_curr.recv));
uint64_t(m_curr.recv.all()));
DEB_ALWAYS() << "Allowing Lima to run on Recv CPUs: "
<< lima_affinity;
setLimaAffinity(lima_affinity);
......@@ -777,6 +777,13 @@ ostream& lima::SlsDetector::operator <<(ostream& os, const CPUAffinity& a)
return os << hex << showbase << uint64_t(a) << dec << noshowbase;
}
ostream& lima::SlsDetector::operator <<(ostream& os, const RecvCPUAffinity& a)
{
os << "<";
os << "listeners=" << a.listeners << ", writers=" << a.writers;
return os << ">";
}
ostream& lima::SlsDetector::operator <<(ostream& os, const SystemCPUAffinity& a)
{
os << "<";
......
......@@ -767,27 +767,28 @@ void Camera::updateCPUAffinity(bool recv_restarted)
m_system_cpu_affinity_mgr.applyAndSet(system_affinity);
}
void Camera::setRecvCPUAffinity(CPUAffinity recv_affinity)
void Camera::setRecvCPUAffinity(const RecvCPUAffinity& recv_affinity)
{
DEB_MEMBER_FUNCT();
CPUAffinity listener_affinity(0xf00);
CPUAffinity writer_affinity(recv_affinity ^
(recv_affinity & listener_affinity));
CPUAffinity listeners_affinity = recv_affinity.listeners;
CPUAffinity writers_affinity = recv_affinity.writers;
cpu_set_t list_cpu_set;
listener_affinity.initCPUSet(list_cpu_set);
listeners_affinity.initCPUSet(list_cpu_set);
cpu_set_t writ_cpu_set;
writer_affinity.initCPUSet(writ_cpu_set);
writers_affinity.initCPUSet(writ_cpu_set);
for (unsigned int i = 0; i < m_recv_list.size(); ++i) {
DEB_TRACE() << "setting recv " << i << " "
<< "CPU mask to " << recv_affinity;
<< "listeners CPU mask to " << listeners_affinity;
DEB_TRACE() << "setting recv " << i << " "
<< "writers CPU mask to " << writers_affinity;
slsReceiverUsers *recv = m_recv_list[i]->m_recv;
recv->setThreadCPUAffinity(sizeof(list_cpu_set),
&list_cpu_set, &writ_cpu_set);
}
for (int i = 0; i < getTotNbPorts(); ++i) {
pid_t tid = m_buffer_thread[i].getTID();
writer_affinity.applyToTask(tid, false);
writers_affinity.applyToTask(tid, false);
}
}
......
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