Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph events multi enqueue #15

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

raphacan
Copy link
Contributor

this PR contains the pipelining extension for events handling and multi graphs enqueuing.
conformance tests ran successfully:

conformance_tests/test_engine/test.h Outdated Show resolved Hide resolved
conformance_tests/test_tiovx/test_graph_pipeline.c Outdated Show resolved Hide resolved
source/framework/vx_data_ref_queue.c Outdated Show resolved Hide resolved
source/include/vx_graph.h Show resolved Hide resolved
source/framework/vx_event_queue.c Outdated Show resolved Hide resolved
source/framework/vx_graph_pipeline.c Outdated Show resolved Hide resolved
source/framework/vx_graph_pipeline.c Outdated Show resolved Hide resolved
conformance_tests/test_tiovx/test_graph_pipeline.c Outdated Show resolved Hide resolved
source/framework/vx_graph_pipeline.c Show resolved Hide resolved
source/framework/vx_graph_pipeline.c Show resolved Hide resolved
Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
@jessegv jessegv force-pushed the graph_events_multi_enqueue branch from cec56c6 to 4986eeb Compare January 21, 2025 22:30
Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
@@ -168,6 +170,26 @@ static vx_status ownGraphPipelineValidateRefsList(
return status;
}

static vx_status ownDecrementEnqueueCount(vx_reference ref)
{
ref->obj_desc->flags &= ~TIVX_OBJ_DESC_DATA_REF_GRAPH_PARAM_ENQUEUED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a check if ref is NULL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This internal function is used in the block from line 551 to 658. Every time we call this function, the ref is previously checked with ownIsValidSpecificReference (lines 581 & 587) and the ref_list is also checked at line 597
So if I add a check in the function to test if this can be NULL, I am afraid it will be difficult to do a test to achieve the branch testing.
What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it would be unlikely to reach via a test - in that case, would you mind adding a comment stating that the reference has previously been checked for NULL?

Copy link
Contributor Author

@raphacan raphacan Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can put a comment or add the condition check and later we put a deviation for the coverage? What do you prefer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment will be sufficient, thanks

vx_status status;
vx_context context = context_->vx_context_;

vx_graph graph1 = vxCreateGraph(context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use the ASSERT_VX_OBJECT macro for the vxCreate instances in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

TIVX_REFERENCE_BUFFER_IS_ALLOCATED = VX_ATTRIBUTE_BASE(VX_ID_TI, (vx_enum)VX_TYPE_REFERENCE) + 0x2,

/*! \brief Used to query the reference for the current enqueue count. Read-write. Use a <tt>\ref vx_uint32</tt> parameter. */
TIVX_REFERENCE_ENQUEUE_COUNT = VX_ATTRIBUTE_BASE(VX_ID_TI, (vx_enum)VX_TYPE_REFERENCE) + 0x3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Pipelining Extension says that this is added to main spec, except without the TI prefix. If there is not a plan to add to main header files, then perhaps we add it as a constant to the Pipelining extension since it is paired with that ... or at least change the name here to remove the TI prefix since it is specified in the pipelineing extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you want to do?

Copy link
Contributor

@jessegv jessegv Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line from tivx.h, and update the pipelining extension header file in this patch to match the latest one from gitlab, it has it defined there as of today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, updated with the latest pipelining header

* Notice that there is only one app_value per graph parameter.
*
*/
VX_API_ENTRY vx_status VX_API_CALL vxRegisterGraphEvent(vx_graph graph, enum vx_event_type_e type, vx_uint32 param, vx_uint32 app_value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API here should take a vx_reference as first parameter, which is called graph_or_node

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, code and test modified

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says that VX_EVENT_GRAPH_COMPLETED, VX_EVENT_NODE_COMPLETED, and VX_EVENT_NODE_ERROR should also be supported by this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header updated

*
* \ingroup group_event
*/
VX_API_ENTRY vx_status VX_API_CALL vxSendUserGraphEvent(vx_graph graph, vx_uint32 app_value, const void *parameter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this header file has both send user events with the last argument as a const qualified pointer, but the spec does not say that. I need to thing more ... should be be const or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question, the "const" says the value it points to is an input parameter (read only). Not sure if this is important for the user of the function as this is specified by the interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new header does not have the const anymore, discussion can be closed?

…h consumers

Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
…PI spec, adapt tests to cover all cases

Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
source/include/vx_graph.h Outdated Show resolved Hide resolved

ASSERT_EQ_VX_STATUS(VX_SUCCESS, vxGraphParameterEnqueueReadyRef(graph1, 0, (vx_reference *)&images[0], 1));
ASSERT_EQ_VX_STATUS(VX_SUCCESS, status = vxGraphParameterEnqueueReadyRef(graph1, 1, (vx_reference *)&images[0], 1));
if (VX_SUCCESS == status)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphacan I am trying to understand under which conditions it would enter the if statement vs the else statement. Would the else statement need to throw some kind of error or is this a valid condition?


Therefore, enqueuing the same reference twice SHOULD return an error!

Note: we modify this rule, proposed change is two rules:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphacan It looks like there was a recent change to the pipelining 2.0 spec, so can we re-word the comment to indicate that this is now mandated by the spec?

vx_context context = context_->vx_context_;
/* Check some basic error returns */
vx_graph graph = vxCreateGraph(context);
vx_image images[3] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphacan It might be a good idea to define and use a macro here for the size of this array and others within this test which also use this size.

source/framework/vx_graph_pipeline.c Outdated Show resolved Hide resolved
if (ref == graph->parameters[graph_parameter_index].refs_list[buf_id])
{
ownPlatformSystemLock((vx_enum)TIVX_PLATFORM_LOCK_DATA_REF_QUEUE);
tivx_obj_desc_t *objd = ref->obj_desc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphacan I am wondering if it makes sense to split out this section into its own dedicated function for readability sake. It seems to me that this section within the lock might be a good candidate for that

source/framework/vx_graph_pipeline.c Outdated Show resolved Hide resolved
source/framework/vx_graph_pipeline.c Outdated Show resolved Hide resolved
/* get queue object descriptor */
queue_obj_desc_id = data_ref_q->done_q_obj_desc_id;
ownPlatformSystemLock(TIVX_PLATFORM_LOCK_DATA_REF_QUEUE);
status = ownObjDescQueueDequeue(queue_obj_desc_id, &ref_obj_desc_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphacan Would this part of the code also be a good candidate for splitting out into its own function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you between the lock and unlock function calls?
what do you suggest for a function#s name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that probably makes sense, although it is a little hard to read fully in github, so if another spot makes more sense, I am open to it.

As far as a name, inferring from the details of the logic and using the typical convention we have, perhaps something like the below:

ownGraphPipelineDecrementEnqueueCount

source/framework/vx_graph_pipeline.c Outdated Show resolved Hide resolved
vx_status status = (vx_status)VX_SUCCESS;
vx_graph graph;
vx_node node;
if (VX_EVENT_GRAPH_PARAMETER_CONSUMED != type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says that VX_EVENT_GRAPH_COMPLETED, VX_EVENT_NODE_COMPLETED, and VX_EVENT_NODE_ERROR should also be supported by this function.

…misra corrections

Signed-off-by: Cano Raphael(XC-AS/EPO3) <Raphael.Cano2@de.bosch.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants