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

smokeTest.vxRetainReference & smokeTestBase.vxSetReferenceName fix #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion amd_openvx/openvx/ago/ago_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ int agoReleaseContext(AgoContext * acontext)

vx_reference ref = (vx_reference)acontext;
ref->external_count = ref->external_count- 1;
if(ref->external_count >= 0)
acontext->num_active_references--;

if(ref->external_count == 0)
{
Expand Down Expand Up @@ -163,9 +165,10 @@ int agoReleaseGraph(AgoGraph * agraph)

int status = 0;
agraph->ref.external_count--;
if(agraph->ref.external_count >= 0)
agraph->ref.context->num_active_references--;
if (agraph->ref.external_count == 0) {
EnterCriticalSection(&agraph->cs);
agraph->ref.context->num_active_references--;
// stop graph thread
if (agraph->hThread) {
agraph->threadThreadTerminationState = 1;
Expand Down
1 change: 1 addition & 0 deletions amd_openvx/openvx/ago/ago_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ struct AgoNodeList {
};
struct AgoGraph {
AgoReference ref;
std::string name;
AgoGraph * next;
CRITICAL_SECTION cs;
HANDLE hThread, hSemToThread, hSemFromThread;
Expand Down
6 changes: 6 additions & 0 deletions amd_openvx/openvx/ago/ago_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,7 @@ AgoData * agoCreateDataFromDescription(AgoContext * acontext, AgoGraph * agraph,
agoResetReference(&data->ref, data->ref.type, acontext, data->isVirtual ? &agraph->ref : NULL);
if (isForExternalUse) {
data->ref.external_count = 1;
acontext->num_active_references++;
}
else {
data->ref.internal_count = 1;
Expand Down Expand Up @@ -2728,6 +2729,7 @@ void agoRetainData(AgoGraph * graph, AgoData * data, bool isForExternalUse)
{
if (isForExternalUse) {
data->ref.external_count++;
//data->ref.context->num_active_references++;
}
else {
data->ref.internal_count++;
Expand Down Expand Up @@ -2773,6 +2775,8 @@ int agoReleaseData(AgoData * data, bool isForExternalUse)
if (data->ref.internal_count > 0)
data->ref.internal_count--;
}
if(data->ref.external_count >= 0 && isForExternalUse && data->ref.internal_count >= 0)
graph->ref.context->num_active_references--;
if (data->ref.external_count == 0 && data->ref.internal_count == 0) {
// clear child link in it's paren link
if (data->parent) {
Expand Down Expand Up @@ -2813,6 +2817,8 @@ int agoReleaseData(AgoData * data, bool isForExternalUse)
data->ref.internal_count--;
}
}
if(data->ref.external_count >= 0 && isForExternalUse && data->ref.internal_count >= 0)
context->num_active_references--;
if (data->ref.external_count == 0 && data->ref.internal_count == 0) {
// clear child link in it's paren link
if (data->parent) {
Expand Down
37 changes: 28 additions & 9 deletions amd_openvx/openvx/api/vx_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,7 @@ VX_API_ENTRY vx_image VX_API_CALL vxCreateImageFromChannel(vx_image img, vx_enum
}
if (subImage) {
subImage->ref.external_count++;
subImage->ref.context->num_active_references++;
}
return (vx_image)subImage;
}
Expand Down Expand Up @@ -2330,8 +2331,6 @@ VX_API_ENTRY vx_kernel VX_API_CALL vxAddKernel(vx_context context,
kernel->importing_module_index_plus1 = context->importing_module_index_plus1;
kernel->user_kernel = vx_false_e;
agoAddKernel(&context->kernelList, kernel);
// update reference count
kernel->ref.context->num_active_references++;
}
}
return kernel;
Expand Down Expand Up @@ -2391,8 +2390,6 @@ VX_API_ENTRY vx_kernel VX_API_CALL vxAddUserKernel(vx_context context,
kernel->importing_module_index_plus1 = context->importing_module_index_plus1;
kernel->user_kernel = vx_true_e;
agoAddKernel(&context->kernelList, kernel);
// update reference count
kernel->ref.context->num_active_references++;
}
}
return kernel;
Expand Down Expand Up @@ -3645,6 +3642,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxQueryParameter(vx_parameter param, vx_enum
// TBD: handle optimized buffers and kernels
if (ref) {
ref->external_count++;
ref->context->num_active_references++;
}
status = VX_SUCCESS;
}
Expand Down Expand Up @@ -4156,10 +4154,20 @@ VX_API_ENTRY vx_status VX_API_CALL vxQueryReference(vx_reference ref, vx_enum at
break;
case VX_REFERENCE_NAME:
if (size == sizeof(vx_char*)) {
AgoData * data = (AgoData *)ref;
//strncpy((char *)ptr, data->name.c_str(), size);
*(vx_char**)ptr = &data->name[0];
status = VX_SUCCESS;
if(ref->type == VX_TYPE_GRAPH)
{
AgoGraph * graph = (AgoGraph *)ref;
//strncpy((char *)ptr, data->name.c_str(), size);
*(vx_char**)ptr = &graph->name[0];
status = VX_SUCCESS;
}
else
{
AgoData * data = (AgoData *)ref;
//strncpy((char *)ptr, data->name.c_str(), size);
*(vx_char**)ptr = &data->name[0];
status = VX_SUCCESS;
}
}
break;
default:
Expand Down Expand Up @@ -4265,6 +4273,8 @@ VX_API_ENTRY vx_status VX_API_CALL vxRetainReference(vx_reference ref)
vx_status status = VX_ERROR_INVALID_REFERENCE;
if (agoIsValidReference(ref)) {
ref->external_count++;
if (ref->type != VX_TYPE_KERNEL && ref->type != VX_TYPE_NODE && ref->type != VX_TYPE_PARAMETER)
ref->context->num_active_references++;
status = VX_SUCCESS;
}
return status;
Expand Down Expand Up @@ -4297,7 +4307,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxSetReferenceName(vx_reference ref, const vx
vx_status status = VX_ERROR_INVALID_REFERENCE;
if (agoIsValidReference(ref) && ((ref->type >= VX_TYPE_DELAY && ref->type <= VX_TYPE_REMAP) ||
(ref->type == VX_TYPE_TENSOR) ||
(ref->type >= VX_TYPE_VENDOR_OBJECT_START && ref->type <= VX_TYPE_VENDOR_OBJECT_END) || (ref->type == VX_TYPE_GRAPH)))
(ref->type >= VX_TYPE_VENDOR_OBJECT_START && ref->type <= VX_TYPE_VENDOR_OBJECT_END)))
{
AgoData * data = (AgoData *)ref;
//printf("%s %s %lu\n", data->name.c_str(), name, strlen(name));
Expand All @@ -4313,6 +4323,12 @@ VX_API_ENTRY vx_status VX_API_CALL vxSetReferenceName(vx_reference ref, const vx

status = VX_SUCCESS;
}
else if(agoIsValidReference(ref) && (ref->type == VX_TYPE_GRAPH))
{
AgoGraph * graph = (AgoGraph *)ref;
graph->name = name;
status = VX_SUCCESS;
}
return status;
}

Expand Down Expand Up @@ -6978,6 +6994,7 @@ VX_API_ENTRY vx_image VX_API_CALL vxGetPyramidLevel(vx_pyramid pyr, vx_uint32 in
if (agoIsValidData(data, VX_TYPE_PYRAMID) && (index < data->u.pyr.levels) && !data->isNotFullyConfigured) {
img = data->children[index];
agoRetainData((AgoGraph *)data->ref.scope, img, true);
data->ref.context->num_active_references++;
}
return (vx_image)img;
}
Expand Down Expand Up @@ -8598,6 +8615,8 @@ VX_API_ENTRY vx_reference VX_API_CALL vxGetObjectArrayItem(vx_object_array arr,
// convert the index from 0..-(N-1) to 0..N-1
if (index < data->u.objarr.numitems) {
item = data->children[index];
agoRetainData((AgoGraph *)data->ref.scope, item, true);
data->ref.context->num_active_references++;
}
}
return (vx_reference)item;
Expand Down