mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fix calculation of maximum number of signals in nodes/paths
This commit is contained in:
parent
f4044ff861
commit
599197a66f
9 changed files with 67 additions and 5 deletions
|
@ -75,4 +75,7 @@ void hook_list_stop(struct vlist *hs);
|
|||
|
||||
struct vlist * hook_list_get_signals(struct vlist *hs);
|
||||
|
||||
/** Get the maximum number of signals which is used by any of the hooks in the list. */
|
||||
unsigned hook_list_get_signals_max_cnt(struct vlist *hs);
|
||||
|
||||
json_t * hook_list_to_json(struct vlist *hs);
|
||||
|
|
|
@ -192,6 +192,10 @@ struct vlist * node_output_signals(struct vnode *n);
|
|||
|
||||
struct vlist * node_input_signals(struct vnode *n);
|
||||
|
||||
unsigned node_input_signals_max_cnt(struct vnode *n);
|
||||
|
||||
unsigned node_output_signals_max_cnt(struct vnode *n);
|
||||
|
||||
/** Reverse local and remote socket address.
|
||||
*
|
||||
* @see node_type::reverse
|
||||
|
|
|
@ -79,4 +79,6 @@ int node_direction_stop(struct vnode_direction *nd, struct vnode *n);
|
|||
|
||||
struct vlist * node_direction_get_signals(struct vnode_direction *nd);
|
||||
|
||||
unsigned node_direction_get_signals_max_cnt(struct vnode_direction *nd);
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -144,7 +144,9 @@ int path_destroy(struct vpath *p) __attribute__ ((warn_unused_result));
|
|||
const char * path_name(struct vpath *p);
|
||||
|
||||
/** Get a list of signals which is emitted by the path. */
|
||||
struct vlist * path_output_signals(struct vpath *n);
|
||||
struct vlist * path_output_signals(struct vpath *p);
|
||||
|
||||
unsigned path_output_signals_max_cnt(struct vpath *p);
|
||||
|
||||
/** Reverse a path */
|
||||
int path_reverse(struct vpath *p, struct vpath *r);
|
||||
|
|
|
@ -132,6 +132,7 @@ skip_add:
|
|||
sigs = h->getSignals();
|
||||
|
||||
auto logger = logging.get("hook");
|
||||
logger->debug("Signal list after hook {}:", i);
|
||||
signal_list_dump(logger, sigs);
|
||||
}
|
||||
}
|
||||
|
@ -210,6 +211,23 @@ struct vlist * hook_list_get_signals(struct vlist *hs)
|
|||
return h->getSignals();
|
||||
}
|
||||
|
||||
unsigned hook_list_get_signals_max_cnt(struct vlist *hs)
|
||||
{
|
||||
unsigned max_cnt = 0;
|
||||
|
||||
for (size_t i = 0; i < vlist_length(hs); i++) {
|
||||
Hook *h = (Hook *) vlist_at(hs, i);
|
||||
|
||||
struct vlist *sigs = h->getSignals();
|
||||
unsigned sigs_cnt = vlist_length(sigs);
|
||||
|
||||
if (sigs_cnt > max_cnt)
|
||||
max_cnt = sigs_cnt;
|
||||
}
|
||||
|
||||
return max_cnt;
|
||||
}
|
||||
|
||||
json_t * hook_list_to_json(struct vlist *hs)
|
||||
{
|
||||
json_t *json_hooks = json_array();
|
||||
|
|
13
lib/node.cpp
13
lib/node.cpp
|
@ -680,6 +680,19 @@ struct vlist * node_output_signals(struct vnode *n)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned node_input_signals_max_cnt(struct vnode *n)
|
||||
{
|
||||
return node_direction_get_signals_max_cnt(&n->in);
|
||||
}
|
||||
|
||||
unsigned node_output_signals_max_cnt(struct vnode *n)
|
||||
{
|
||||
if (n->out.path)
|
||||
return path_output_signals_max_cnt(n->out.path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
json_t * node_to_json(struct vnode *n)
|
||||
{
|
||||
struct vlist *output_signals;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <villas/hook.hpp>
|
||||
#include <villas/hook_list.hpp>
|
||||
#include <villas/node.h>
|
||||
#include <villas/utils.hpp>
|
||||
#include <villas/node_direction.h>
|
||||
#include <villas/exceptions.hpp>
|
||||
|
||||
|
@ -216,3 +217,13 @@ struct vlist * node_direction_get_signals(struct vnode_direction *nd)
|
|||
|
||||
return &nd->signals;
|
||||
}
|
||||
|
||||
unsigned node_direction_get_signals_max_cnt(struct vnode_direction *nd)
|
||||
{
|
||||
#ifdef WITH_HOOKS
|
||||
if (vlist_length(&nd->hooks) > 0)
|
||||
return MAX(vlist_length(&nd->signals), hook_list_get_signals_max_cnt(&nd->hooks));
|
||||
#endif /* WITH_HOOKS */
|
||||
|
||||
return vlist_length(&nd->signals);
|
||||
}
|
||||
|
|
13
lib/path.cpp
13
lib/path.cpp
|
@ -378,8 +378,7 @@ int path_prepare(struct vpath *p, NodeList &nodes)
|
|||
|
||||
/* Prepare pool */
|
||||
pool_size = MAX(1UL, vlist_length(&p->destinations)) * p->queuelen;
|
||||
ret = pool_init(&p->pool, pool_size, SAMPLE_LENGTH(vlist_length(path_output_signals(p))), pool_mt);
|
||||
|
||||
ret = pool_init(&p->pool, pool_size, SAMPLE_LENGTH(path_output_signals_max_cnt(p)), pool_mt);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -827,6 +826,16 @@ struct vlist * path_output_signals(struct vpath *p)
|
|||
return &p->signals;
|
||||
}
|
||||
|
||||
unsigned path_output_signals_max_cnt(struct vpath *p)
|
||||
{
|
||||
#ifdef WITH_HOOKS
|
||||
if (vlist_length(&p->hooks) > 0)
|
||||
return MAX(vlist_length(&p->signals), hook_list_get_signals_max_cnt(&p->hooks));
|
||||
#endif /* WITH_HOOKS */
|
||||
|
||||
return vlist_length(&p->signals);
|
||||
}
|
||||
|
||||
json_t * path_to_json(struct vpath *p)
|
||||
{
|
||||
char uuid[37];
|
||||
|
|
|
@ -52,12 +52,12 @@ int path_source_init_master(struct vpath_source *ps, struct vnode *n)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
int pool_size = MAX(DEFAULT_QUEUE_LENGTH, 40 * ps->node->in.vectorize);
|
||||
int pool_size = MAX(DEFAULT_QUEUE_LENGTH, 20 * ps->node->in.vectorize);
|
||||
|
||||
if (ps->node->_vt->pool_size)
|
||||
pool_size = ps->node->_vt->pool_size;
|
||||
|
||||
ret = pool_init(&ps->pool, pool_size, SAMPLE_LENGTH(vlist_length(node_input_signals(ps->node))), node_memory_type(ps->node));
|
||||
ret = pool_init(&ps->pool, pool_size, SAMPLE_LENGTH(node_input_signals_max_cnt(ps->node)), node_memory_type(ps->node));
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Reference in a new issue