summaryrefslogtreecommitdiff
path: root/lib/graph
diff options
context:
space:
mode:
authorZhirun Yan <[email protected]>2023-06-14 23:58:58 +0800
committerDavid Marchand <[email protected]>2023-06-19 21:27:05 +0200
commit35dfd9b9fd85b8c297eeaf853b4c019a1131fd6d (patch)
treec3e1de6a1a80ed852eebe43a6fb1742ba90cf719 /lib/graph
parente7728f6d8f62d03c0ea9db2fbb7ed0c83fcc9810 (diff)
graph: introduce graph walk by cross-core dispatch
This patch introduces the task scheduler mechanism to enable dispatching tasks to another worker cores. Currently, there is only a local work queue for one graph to walk. We introduce a scheduler worker queue in each worker core for dispatching tasks. It will perform the walk on scheduler work queue first, then handle the local work queue. Signed-off-by: Haiyue Wang <[email protected]> Signed-off-by: Cunming Liang <[email protected]> Signed-off-by: Zhirun Yan <[email protected]> Acked-by: Jerin Jacob <[email protected]> Acked-by: Pavan Nikhilesh <[email protected]>
Diffstat (limited to 'lib/graph')
-rw-r--r--lib/graph/rte_graph_model_mcore_dispatch.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/graph/rte_graph_model_mcore_dispatch.h b/lib/graph/rte_graph_model_mcore_dispatch.h
index d3f4de2e78..3bf210a829 100644
--- a/lib/graph/rte_graph_model_mcore_dispatch.h
+++ b/lib/graph/rte_graph_model_mcore_dispatch.h
@@ -83,6 +83,49 @@ __rte_experimental
int rte_graph_model_mcore_dispatch_node_lcore_affinity_set(const char *name,
unsigned int lcore_id);
+/**
+ * Perform graph walk on the circular buffer and invoke the process function
+ * of the nodes and collect the stats.
+ *
+ * @param graph
+ * Graph pointer returned from rte_graph_lookup function.
+ *
+ * @see rte_graph_lookup()
+ */
+__rte_experimental
+static inline void
+rte_graph_walk_mcore_dispatch(struct rte_graph *graph)
+{
+ const rte_graph_off_t *cir_start = graph->cir_start;
+ const rte_node_t mask = graph->cir_mask;
+ uint32_t head = graph->head;
+ struct rte_node *node;
+
+ if (graph->dispatch.wq != NULL)
+ __rte_graph_mcore_dispatch_sched_wq_process(graph);
+
+ while (likely(head != graph->tail)) {
+ node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
+
+ /* skip the src nodes which not bind with current worker */
+ if ((int32_t)head < 0 && node->dispatch.lcore_id != graph->dispatch.lcore_id)
+ continue;
+
+ /* Schedule the node until all task/objs are done */
+ if (node->dispatch.lcore_id != RTE_MAX_LCORE &&
+ graph->dispatch.lcore_id != node->dispatch.lcore_id &&
+ graph->dispatch.rq != NULL &&
+ __rte_graph_mcore_dispatch_sched_node_enqueue(node, graph->dispatch.rq))
+ continue;
+
+ __rte_node_process(graph, node);
+
+ head = likely((int32_t)head > 0) ? head & mask : head;
+ }
+
+ graph->tail = 0;
+}
+
#ifdef __cplusplus
}
#endif