Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit c73fa10

Browse files
authored
Merge pull request #50 from rgiduthuri/rg/drama-rules
updated drama regen interface
2 parents 0b959a7 + 3f16356 commit c73fa10

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

openvx/ago/ago_drama_divide.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ THE SOFTWARE.
2626
#define SANITY_CHECK_DATA_TYPE(data,data_type) if(!data || data->ref.type != data_type) return -1
2727
#define SANITY_CHECK_DATA_TYPE_OPTIONAL(data,data_type) if( data && data->ref.type != data_type) return -1
2828

29-
int agoDramaDivideAppend(AgoNodeList * nodeList, AgoNode * anode, vx_enum new_kernel_id)
29+
int agoDramaDivideAppend(AgoNodeList * nodeList, AgoNode * anode, vx_enum new_kernel_id, vx_reference * paramList, vx_uint32 paramCount)
3030
{
3131
if (new_kernel_id == VX_KERNEL_AMD_INVALID) {
3232
// TBD: error handling
@@ -35,15 +35,26 @@ int agoDramaDivideAppend(AgoNodeList * nodeList, AgoNode * anode, vx_enum new_ke
3535
}
3636
// create a new AgoNode and add it to the nodeList
3737
AgoNode * childnode = agoCreateNode((AgoGraph *)anode->ref.scope, new_kernel_id);
38-
for (vx_uint32 i = 0; i < anode->paramCount; i++) {
39-
childnode->paramList[i] = anode->paramList[i];
38+
for (vx_uint32 i = 0; i < paramCount; i++) {
39+
childnode->paramList[i] = (AgoData *)paramList[i];
4040
}
41+
anode->drama_divide_invoked = true;
4142
// transfer attributes from anode to childnode
4243
agoImportNodeConfig(childnode, anode);
4344
// verify the node
4445
return agoVerifyNode(childnode);
4546
}
4647

48+
vx_status VX_CALLBACK agoDramaDivideAddNodeCallback(vx_node node, vx_enum kernel_id, vx_reference * paramList, vx_uint32 paramCount)
49+
{
50+
return agoDramaDivideAppend(&((AgoGraph *)node->ref.scope)->nodeList, node, kernel_id, paramList, paramCount);
51+
}
52+
53+
int agoDramaDivideAppend(AgoNodeList * nodeList, AgoNode * anode, vx_enum new_kernel_id)
54+
{
55+
return agoDramaDivideAppend(nodeList, anode, new_kernel_id, (vx_reference *)anode->paramList, anode->paramCount);
56+
}
57+
4758
int agoDramaDivideColorConvertNode(AgoNodeList * nodeList, AgoNode * anode)
4859
{
4960
// sanity checks
@@ -1975,10 +1986,11 @@ int agoOptimizeDramaDivide(AgoGraph * agraph)
19751986
}
19761987
else if (anode->akernel->regen_callback_f) {
19771988
// try regenerating the node
1978-
vx_bool regen_not_needed = vx_true_e;
1979-
vx_status status = anode->akernel->regen_callback_f(agraph, anode, regen_not_needed);
1989+
anode->drama_divide_invoked = false;
1990+
vx_bool replace_original = vx_true_e;
1991+
vx_status status = anode->akernel->regen_callback_f(anode, agoDramaDivideAddNodeCallback, replace_original);
19801992
if (status == VX_SUCCESS) {
1981-
if (regen_not_needed == vx_false_e) {
1993+
if (anode->drama_divide_invoked && replace_original) {
19821994
// remove and release the current node
19831995
if (aprev) aprev->next = anode->next;
19841996
else agraph->nodeList.head = anode->next;

openvx/ago/ago_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ struct AgoNode {
541541
vx_nodecomplete_f callback;
542542
AgoSuperNode * supernode;
543543
bool initialized;
544+
bool drama_divide_invoked;
544545
vx_uint32 valid_rect_num_inputs;
545546
vx_uint32 valid_rect_num_outputs;
546547
vx_rectangle_t ** valid_rect_inputs;

openvx/ago/ago_util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,7 @@ AgoNode::AgoNode()
30103010
: next{ nullptr }, akernel{ nullptr }, flags{ 0 }, localDataSize{ 0 }, localDataPtr{ nullptr }, localDataPtr_allocated{ nullptr },
30113011
valid_rect_reset{ vx_true_e }, valid_rect_num_inputs{ 0 }, valid_rect_num_outputs{ 0 }, valid_rect_inputs{ nullptr }, valid_rect_outputs{ nullptr },
30123012
paramCount{ 0 }, callback{ nullptr }, supernode{ nullptr }, initialized{ false }, target_support_flags{ 0 }, hierarchical_level{ 0 }, status{ VX_SUCCESS }
3013+
, drama_divide_invoked{ false }
30133014
#if ENABLE_OPENCL
30143015
, opencl_type{ 0 }, opencl_param_mem2reg_mask{ 0 }, opencl_param_discard_mask{ 0 }, opencl_param_as_value_mask{ 0 },
30153016
opencl_param_atomic_mask{ 0 }, opencl_local_buffer_usage_mask{ 0 }, opencl_local_buffer_size_in_bytes{ 0 }, opencl_work_dim{ 0 },

openvx/include/vx_ext_amd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ typedef vx_status(VX_CALLBACK * amd_kernel_opencl_codegen_callback_f) (
338338

339339
/*! \brief AMD usernode callback for regenerating a node.
340340
*/
341-
typedef vx_status(VX_CALLBACK * amd_kernel_node_regen_callback_f) (vx_graph graph, vx_node node, vx_bool& regen_not_needed);
341+
typedef vx_status(VX_CALLBACK * amd_drama_add_node_f)(vx_node node, vx_enum kernel_id, vx_reference * paramList, vx_uint32 paramCount);
342+
typedef vx_status(VX_CALLBACK * amd_kernel_node_regen_callback_f)(vx_node node, amd_drama_add_node_f add_node_f, vx_bool& replace_original);
342343

343344
/*! \brief AMD usernode callback for updating the OpenCL global_work[]. The framework will pass
344345
* OpenVX objects as parameters to OpenCL kernels in othe order they appear to OpenVX node and

0 commit comments

Comments
 (0)