@@ -230,21 +230,33 @@ void vxContaminateGraphs(vx_reference ref)
230230/* INTERNAL FUNCTIONS */
231231/* *****************************************************************************/
232232
233- Graph::Graph (vx_context context, vx_reference scope) : Reference(context, VX_TYPE_GRAPH, scope),
234- nodes(),
235- perf(),
236- numNodes(0 ),
237- heads(),
238- numHeads(0 ),
239- state(VX_FAILURE),
240- verified(vx_false_e),
241- reverify(vx_false_e),
242- lock(),
243- parameters(),
244- numParams(0 ),
245- shouldSerialize(vx_false_e),
246- parentGraph(nullptr ),
247- delays()
233+ Graph::Graph (vx_context context, vx_reference scope)
234+ : Reference(context, VX_TYPE_GRAPH, scope),
235+ nodes(),
236+ perf(),
237+ numNodes(0 ),
238+ heads(),
239+ numHeads(0 ),
240+ state(VX_FAILURE),
241+ verified(vx_false_e),
242+ reverify(vx_false_e),
243+ lock(),
244+ parameters(),
245+ numParams(0 ),
246+ shouldSerialize(vx_false_e),
247+ parentGraph(nullptr ),
248+ delays(),
249+ scheduleMode(VX_GRAPH_SCHEDULE_MODE_NORMAL),
250+ #ifdef OPENVX_USE_PIPELINING
251+ numEnqueableParams (0 ),
252+ scheduleCount(0 ),
253+ #endif /* OPENVX_USE_PIPELINING */
254+ #ifdef OPENVX_USE_STREAMING
255+ isStreamingEnabled (vx_false_e),
256+ isStreaming(vx_false_e),
257+ triggerNodeIndex(0 ),
258+ streamingThread()
259+ #endif /* OPENVX_USE_STREAMING */
248260{
249261}
250262
@@ -1723,6 +1735,35 @@ vx_status Graph::pipelineValidateRefsList(
17231735 return status;
17241736}
17251737
1738+ void Graph::streamingLoop ()
1739+ {
1740+ #ifdef OPENVX_USE_STREAMING
1741+ while (isStreaming)
1742+ {
1743+ /* Wait for trigger node event if set */
1744+ // if (triggerNodeIndex != UINT32_MAX)
1745+ // {
1746+ // /* Wait for the trigger node to complete */
1747+ // while (!nodes[triggerNodeIndex]->executed)
1748+ // {
1749+ // std::cout << "Waiting for trigger node to complete" << std::endl;
1750+ // std::this_thread::sleep_for(std::chrono::milliseconds(1));
1751+ // /* Allow clean exit */
1752+ // if (!isStreaming) return;
1753+ // }
1754+ // /* Reset the event for the next iteration */
1755+ // nodes[triggerNodeIndex]->executed = vx_false_e;
1756+ // }
1757+
1758+ /* Schedule and wait for the graph */
1759+ vx_status status = vxScheduleGraph (this );
1760+ if (status != VX_SUCCESS) break ;
1761+ status = vxWaitGraph (this );
1762+ if (status != VX_SUCCESS) break ;
1763+ }
1764+ #endif /* OPENVX_USE_STREAMING */
1765+ }
1766+
17261767void Graph::destruct ()
17271768{
17281769 while (numNodes)
@@ -2068,7 +2109,8 @@ VX_API_ENTRY vx_status VX_API_CALL vxVerifyGraph(vx_graph graph)
20682109 {
20692110 if (((graph->nodes [n]->kernel ->signature .directions [p] == VX_BIDIRECTIONAL) ||
20702111 (graph->nodes [n]->kernel ->signature .directions [p] == VX_INPUT)) &&
2071- (graph->nodes [n]->parameters [p] != nullptr ))
2112+ (graph->nodes [n]->parameters [p] != nullptr ) &&
2113+ (graph->nodes [n]->kernel ->validate_input != nullptr ))
20722114 {
20732115 vx_status input_validation_status = graph->nodes [n]->kernel ->validate_input ((vx_node)graph->nodes [n], p);
20742116 if (input_validation_status != VX_SUCCESS)
@@ -2100,25 +2142,30 @@ VX_API_ENTRY vx_status VX_API_CALL vxVerifyGraph(vx_graph graph)
21002142 if (graph->setupOutput (n, p, &vref, &metas[p], &status, &num_errors) ==
21012143 vx_false_e)
21022144 break ;
2103- output_validation_status = graph->nodes [n]->kernel ->validate_output (
2104- (vx_node)graph->nodes [n], p, metas[p]);
2105- if (output_validation_status == VX_SUCCESS)
2145+ if (graph->nodes [n]->kernel ->validate_output != nullptr )
21062146 {
2107- if (graph->postprocessOutput (n, p, &vref, metas[p], &status,
2108- &num_errors) == vx_false_e)
2147+ output_validation_status = graph->nodes [n]->kernel ->validate_output (
2148+ (vx_node)graph->nodes [n], p, metas[p]);
2149+ if (output_validation_status == VX_SUCCESS)
21092150 {
2110- break ;
2151+ if (graph->postprocessOutput (n, p, &vref, metas[p], &status,
2152+ &num_errors) == vx_false_e)
2153+ {
2154+ break ;
2155+ }
2156+ }
2157+ else
2158+ {
2159+ status = output_validation_status;
2160+ vxAddLogEntry (reinterpret_cast <vx_reference>(graph), status,
2161+ " Node %s: parameter[%u] failed output validation! "
2162+ " (status = %d)\n " ,
2163+ graph->nodes [n]->kernel ->name , p, status);
2164+ VX_PRINT (VX_ZONE_ERROR,
2165+ " Failed on validation of output parameter[%u] on kernel "
2166+ " %s, status=%d\n " ,
2167+ p, graph->nodes [n]->kernel ->name , status);
21112168 }
2112- }
2113- else
2114- {
2115- status = output_validation_status;
2116- vxAddLogEntry (reinterpret_cast <vx_reference>(graph), status, " Node %s: parameter[%u] failed output validation! (status = %d)\n " ,
2117- graph->nodes [n]->kernel ->name , p, status);
2118- VX_PRINT (VX_ZONE_ERROR," Failed on validation of output parameter[%u] on kernel %s, status=%d\n " ,
2119- p,
2120- graph->nodes [n]->kernel ->name ,
2121- status);
21222169 }
21232170 }
21242171 }
@@ -2511,6 +2558,7 @@ static vx_status vxExecuteGraph(vx_graph graph, vx_uint32 depth)
25112558 vx_uint32 next_nodes[VX_INT_MAX_REF];
25122559 vx_uint32 left_nodes[VX_INT_MAX_REF];
25132560 vx_context context = vxGetContext ((vx_reference)graph);
2561+ vx_uint32 max_pipeup_depth = 1 ;
25142562 (void )depth;
25152563
25162564#if defined(OPENVX_USE_SMP)
@@ -2640,6 +2688,34 @@ static vx_status vxExecuteGraph(vx_graph graph, vx_uint32 depth)
26402688 next_nodes[n],
26412689 target->name , node->kernel ->name );
26422690
2691+ /* Check for pipeup phase:
2692+ * If this is the first time we are executing the graph, we need to pipeup
2693+ * all nodes with kernels in the graph that need pipeup of refs.
2694+ */
2695+ max_pipeup_depth = std::max (
2696+ {max_pipeup_depth, node->kernel ->input_depth , node->kernel ->output_depth });
2697+ if (node->kernel ->pipeUpCounter < max_pipeup_depth - 1 )
2698+ {
2699+ node->state = VX_NODE_STATE_PIPEUP;
2700+ std::cout << " max_pipeup_depth: " << max_pipeup_depth << std::endl;
2701+ node->kernel ->pipeUpCounter ++;
2702+ // Retain input buffers during PIPEUP
2703+ for (vx_uint32 i = 0 ; i < node->kernel ->output_depth - 1 ; i++)
2704+ {
2705+ action = target->funcs .process (target, &node, 0 , 1 );
2706+ node->kernel ->pipeUpCounter ++;
2707+ }
2708+ // For source nodes, provide new output buffers during PIPEUP
2709+ for (vx_uint32 i = 0 ; i < node->kernel ->input_depth - 1 ; i++)
2710+ {
2711+ action = target->funcs .process (target, &node, 0 , 1 );
2712+ node->kernel ->pipeUpCounter ++;
2713+ }
2714+ }
2715+
2716+ /* If this node was in pipeup, update its state */
2717+ node->state = VX_NODE_STATE_STEADY;
2718+
26432719 action = target->funcs .process (target, &node, 0 , 1 );
26442720
26452721 VX_PRINT (VX_ZONE_GRAPH, " Returned Node[%u] %s:%s Action %d\n " ,
0 commit comments