40 return spec.name ==
name;
47 const std::regex matcher(re);
50 return std::regex_match(spec.name.data(),
m, matcher);
58 for (
size_t ii = 0; ii <
a.inputs.size(); ++ii) {
59 for (
size_t oi = 0; oi <
b.outputs.size(); ++oi) {
77 auto checkSporadic = [](
InputSpec const& input) {
78 return input.lifetime == Lifetime::Sporadic;
80 bool isBWithSporadicInput = std::find_if(
b.inputs.begin(),
b.inputs.end(), checkSporadic) !=
b.inputs.end();
81 bool isAWithSporadicInput = std::find_if(
a.inputs.begin(),
a.inputs.end(), checkSporadic) !=
a.inputs.end();
83 if (!isAWithSporadicInput && !isBWithSporadicInput) {
87 if (isAWithSporadicInput && isBWithSporadicInput) {
91 if (isAWithSporadicInput && isBWithSporadicInput) {
97 if (isAWithSporadicInput) {
99 return !hasDependency;
109 O2_SIGNPOST_START(topology, sid,
"expendableDataDeps",
"Checking if %s depends on %s",
a.name.c_str(),
b.name.c_str());
110 if (
a.name.find(
"internal-dpl-injected-dummy-sink") != std::string::npos &&
111 b.name.find(
"internal-dpl-injected-dummy-sink") != std::string::npos) {
112 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. Dummy sink never depends on itself.");
116 if (
b.name.find(
"internal-dpl-injected-dummy-sink") != std::string::npos) {
117 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. %s is dummy sink and it nothing can depend on it.",
b.name.c_str());
120 if (
a.name.find(
"internal-dpl-injected-dummy-sink") != std::string::npos) {
121 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"true. %s is dummy sink and it nothing can depend on it.",
a.name.c_str());
126 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"true. %s has a data dependency on %s",
a.name.c_str(),
b.name.c_str());
133 if (
label.value ==
"expendable") {
140 if (
label.value ==
"resilient") {
146 bool isBExpendable = std::find_if(
b.labels.begin(),
b.labels.end(), checkExpendable) !=
b.labels.end();
147 bool isAExpendable = std::find_if(
a.labels.begin(),
a.labels.end(), checkExpendable) !=
a.labels.end();
148 bool bResilient = std::find_if(
b.labels.begin(),
b.labels.end(), checkResilient) !=
b.labels.end();
151 if (!isAExpendable && !isBExpendable) {
154 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. Neither %s nor %s are expendable. However the former has sporadic inputs so we sort it after.",
155 a.name.c_str(),
b.name.c_str());
158 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. Neither %s nor %s are expendable. No dependency beyond data deps.",
159 a.name.c_str(),
b.name.c_str());
163 if (isAExpendable && isBExpendable) {
166 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. Both %s and %s are expendable. However the former has sporadic inputs, so we sort it after.",
167 a.name.c_str(),
b.name.c_str());
170 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. Both %s and %s are expendable. No dependency.",
171 a.name.c_str(),
b.name.c_str());
176 if (isAExpendable && bResilient) {
179 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. %s is expendable but %s is resilient, however the former also has sporadic inputs, so we sort it after.",
180 a.name.c_str(),
b.name.c_str());
183 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. %s is expendable but %s is resilient. No need to do do anything.",
184 a.name.c_str(),
b.name.c_str());
191 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"%s is expendable. %s from %s to %s => %s.",
192 a.name.c_str(), hasDependency ?
"There is however an inverse dependency" :
"No inverse dependency",
b.name.c_str(),
a.name.c_str(),
193 !hasDependency ?
"true" :
"false");
194 if (!hasDependency) {
195 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"%s is expendable. There is however an inverse dependecy from %s to %s => true.",
196 a.name.c_str(),
b.name.c_str(),
a.name.c_str());
201 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"%s is expendable. No inverse dependency from %s to %s. However the former has an occasioanl input => true.",
202 a.name.c_str(),
b.name.c_str(),
a.name.c_str());
204 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"%s is expendable. No inverse dependency from %s to %s => false.",
205 a.name.c_str(),
b.name.c_str(),
a.name.c_str());
211 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. %s is expendable but %s is not. However the former has an sporadic input => true.",
212 b.name.c_str(),
a.name.c_str());
216 O2_SIGNPOST_END(topology, sid,
"expendableDataDeps",
"false. %s is expendable but %s is not. No need to add an unneeded dependency.",
217 b.name.c_str(),
a.name.c_str());
233 O2_SIGNPOST_START(topology, sid,
"alwaysDependent",
"Checking if %s depends on %s", dependent.
name.c_str(), ancestor.name.c_str());
234 if (dependent.
name == ancestor.name) {
235 O2_SIGNPOST_END(topology, sid,
"alwaysDependent",
"false. %s and %s are the same.", dependent.
name.c_str(), ancestor.name.c_str());
238 if (ancestor.name.find(
"internal-dpl-injected-dummy-sink") != std::string::npos) {
239 O2_SIGNPOST_END(topology, sid,
"alwaysDependent",
"false. Nothing can depend on %s by policy.", ancestor.name.c_str());
243 if (dependent.
name.find(
"internal-dpl-injected-dummy-sink") != std::string::npos) {
244 O2_SIGNPOST_END(topology, sid,
"alwaysDependent",
"true. %s is always last.", ancestor.name.c_str());
247 const std::regex matcher(
".*output-proxy.*");
250 bool isAncestorOutputProxy = std::regex_match(ancestor.name.data(),
m, matcher);
252 assert(std::regex_match(dependent.
name.data(),
m, matcher));
253 bool isAncestorExpendable = std::find_if(ancestor.labels.begin(), ancestor.labels.end(), [](
DataProcessorLabel const&
label) {
254 return label.value ==
"expendable";
255 }) != ancestor.labels.end();
258 return label.value ==
"resilient";
259 }) != dependent.
labels.end();
260 bool isAncestorResilient = std::find_if(ancestor.labels.begin(), ancestor.labels.end(), [](
DataProcessorLabel const&
label) {
261 return label.value ==
"resilient";
262 }) != ancestor.labels.end();
264 if (!isDependentResilient && isAncestorExpendable) {
265 O2_SIGNPOST_END(topology, sid,
"alwaysDependent",
"false. Ancestor %s is expendable while %s is non-resilient output proxy (dependent).",
266 ancestor.name.c_str(), dependent.
name.c_str());
270 if (isAncestorOutputProxy || (!isDependentResilient && isAncestorResilient)) {
271 bool hasDependency =
dataDeps(dependent, ancestor);
272 O2_SIGNPOST_END(topology, sid,
"alwaysDependent",
"%s. Dependent %s %s a dependency on ancestor %s.",
273 hasDependency ?
"true" :
"false", dependent.
name.c_str(), hasDependency ?
"has" :
"has not", ancestor.name.c_str());
274 return hasDependency;
276 O2_SIGNPOST_END(topology, sid,
"alwaysDependent",
"true by default. Ancestor %s is not an output proxy.", ancestor.name.c_str());
#define O2_DECLARE_DYNAMIC_LOG(name)
#define O2_SIGNPOST_END(log, id, name, format,...)
#define O2_SIGNPOST_ID_GENERATE(name, log)
#define O2_SIGNPOST_START(log, id, name, format,...)
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLuint GLsizei const GLchar * label
GLboolean GLboolean GLboolean GLboolean a
Defining PrimaryVertex explicitly as messageable.
bool expendableDataDeps(DataProcessorSpec const &a, DataProcessorSpec const &b)
bool sporadicDataDeps(DataProcessorSpec const &a, DataProcessorSpec const &b)
bool dataDeps(DataProcessorSpec const &a, DataProcessorSpec const &b)
A label that can be associated to a DataProcessorSpec.
std::vector< DataProcessorLabel > labels
static bool match(InputSpec const &spec, ConcreteDataMatcher const &target)
static TopologyPolicy::DependencyChecker dataDependency()
static TopologyPolicy::DataProcessorMatcher matchByRegex(std::string const &re)
static TopologyPolicy::DataProcessorMatcher matchAll()
static TopologyPolicy::DependencyChecker alwaysDependent()
static TopologyPolicy::DataProcessorMatcher matchByName(std::string const &name)
static std::vector< TopologyPolicy > createDefaultPolicies()
std::function< bool(DataProcessorSpec const &dependent, DataProcessorSpec const &ascendant)> DependencyChecker
std::function< bool(DataProcessorSpec const &device)> DataProcessorMatcher