Skip to content

Commit 4924adc

Browse files
authored
Added additional quality copts (#2)
* Re-enabling werror and enabling wall, wextra, and pendantic * Fixing warnings (treated as errors) that were only visible on linux * Removing debug code used in troubleshooting * Adding openvx integration test in CI * Fixed issue with linking on linux
1 parent 5f341c6 commit 4924adc

40 files changed

+267
-229
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ common --enable_bzlmod
55
build --compiler=g++ # Specify the compiler if needed, e.g., gcc, clang
66
build --cxxopt=-std=c++23 # Use C++23 standard (adjust if needed)
77
build --cxxopt=-DCL_TARGET_OPENCL_VERSION=300
8-
# build --per_file_copt=.*,-tests/*.cpp@-Werror
8+
build --per_file_copt=.*,-tests/*.cpp@-Werror,-Wall,-Wextra,-Wpedantic,-Wno-deprecated-declarations
99

1010
# Test settings
1111
test --test_output=errors # Show errors from tests

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
- name: Build the code
3636
run: bazel build //...
3737

38+
# Run OpenVX Integration test
39+
- name: OpenVX Integration Test
40+
run: VX_CL_SOURCE_DIR=$GITHUB_WORKSPACE/kernels/opencl bazel run //tests:vx_test
41+
3842
# Test the project
3943
# - name: Run Bazel tests
4044
# run: |

framework/include/vx_scalar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Scalar : public Reference
9393
/*! \brief Signed 64 bit */
9494
vx_int64 s64;
9595
/*! \brief Unsigned 64 bit */
96-
vx_int64 u64;
96+
vx_uint64 u64;
9797
#if defined(EXPERIMENTAL_PLATFORM_SUPPORTS_16_FLOAT)
9898
/*! \brief 16 bit float */
9999
vx_float16 f16;

framework/src/vx_context.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,28 @@ vx_status Context::loadTarget(const vx_char* targetName)
254254

255255
vx_status Context::unloadTarget(const vx_char* targetName)
256256
{
257-
return VX_ERROR_NOT_IMPLEMENTED;
257+
vx_status status = VX_FAILURE;
258+
259+
for (vx_uint32 t = 0u; t < context->num_targets; t++)
260+
{
261+
if (context->targets[t] &&
262+
strncmp(context->targets[t]->name, targetName, VX_MAX_TARGET_NAME) == 0)
263+
{
264+
memset(&context->targets[t]->funcs, 0xFE, sizeof(vx_target_funcs_t));
265+
if (context->targets[t]->decrementReference(VX_INTERNAL) == 0)
266+
{
267+
/* The ReleaseReference() below errors out if the internal index is 0 */
268+
context->targets[t]->incrementReference(VX_INTERNAL);
269+
}
270+
Osal::unloadModule(context->targets[t]->module.handle);
271+
context->targets[t]->module.handle = VX_MODULE_INIT;
272+
273+
memset(context->targets[t]->module.name, 0, sizeof(context->targets[t]->module.name));
274+
status = Reference::releaseReference((vx_reference*)&context->targets[t], VX_TYPE_TARGET, VX_INTERNAL, nullptr);
275+
}
276+
}
277+
278+
return status;
258279
}
259280

260281
vx_status Context::unloadTarget(vx_uint32 index, vx_bool unload_module)
@@ -758,8 +779,8 @@ VX_API_ENTRY vx_context VX_API_CALL vxCreateContext(void)
758779
if (context->num_targets == 0)
759780
{
760781
VX_PRINT(VX_ZONE_ERROR, "No targets loaded!\n");
761-
// free(context);
762782
Osal::semPost(&context_lock);
783+
single_context.reset();
763784
return nullptr;
764785
}
765786

@@ -774,8 +795,11 @@ VX_API_ENTRY vx_context VX_API_CALL vxCreateContext(void)
774795
{
775796
VX_PRINT(VX_ZONE_WARNING, "Target %s failed to initialize!\n", context->targets[t]->name);
776797
/* unload this module */
777-
context->unloadTarget(t, vx_true_e);
778-
break;
798+
/* @TODO: unload target now or on context release? */
799+
/*
800+
* context->unloadTarget(t, vx_true_e);
801+
* break;
802+
*/
779803
}
780804
else
781805
{
@@ -922,7 +946,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxReleaseContext(vx_context* c)
922946
/* de-initialize and unload each target */
923947
for (t = 0u; t < context->num_targets; t++)
924948
{
925-
if (context->targets[t]->enabled == vx_true_e)
949+
/* if (context->targets[t]->enabled == vx_true_e) */
926950
{
927951
context->targets[t]->funcs.deinit(context->targets[t]);
928952
context->targets[t]->enabled = vx_false_e;
@@ -1118,7 +1142,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxQueryContext(vx_context context, vx_enum at
11181142
case VX_CONTEXT_EXTENSIONS:
11191143
if (size <= sizeof(extensions) && ptr)
11201144
{
1121-
strncpy(reinterpret_cast<char*>(ptr), extensions, sizeof(extensions));
1145+
strncpy(reinterpret_cast<char*>(ptr), extensions, size);
11221146
}
11231147
else
11241148
{

framework/src/vx_dot.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxExportGraphToDot(vx_graph graph, vx_char do
8888
{
8989
vx_pyramid pyr = (vx_pyramid)data[d];
9090
fprintf(fp, "\tD%u [shape=triangle label=\"Pyramid\\n%lfx" VX_FMT_REF "\\nLevels: %zu\"];\n",
91-
d, pyr->scale, pyr->levels, pyr->numLevels);
91+
d, pyr->scale, (void*)pyr->levels, pyr->numLevels);
9292
break;
9393
}
9494
case VX_TYPE_SCALAR:
@@ -155,6 +155,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxExportGraphToDot(vx_graph graph, vx_char do
155155
{
156156
fprintf(fp, "\tD%u [shape=box label=\"Distribution\"];\n", d);
157157
}
158+
break;
158159
}
159160
case VX_TYPE_LUT:
160161
{

framework/src/vx_error.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ status(VX_SUCCESS)
2929
Error::~Error()
3030
{
3131
vx_error ref = this;
32-
releaseError(&ref);
32+
if (internal_count)
33+
releaseError(&ref);
3334
}
3435

3536
void Error::releaseError(vx_error* error)

framework/src/vx_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ vx_node vxCreateNodeByStructure(vx_graph graph,
160160
vx_node node = 0;
161161
vx_context context = vxGetContext((vx_reference)graph);
162162
vx_kernel kernel = vxGetKernelByEnum(context, kernelenum);
163-
if (kernel)
163+
if (VX_SUCCESS == vxGetStatus((vx_reference)kernel))
164164
{
165165
node = vxCreateGenericNode(graph, kernel);
166166
if (vxGetStatus((vx_reference)node) == VX_SUCCESS)

framework/src/vx_ix_export.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ static void calculateUses(VXBinExport *xport)
268268
break; /* Already assigned, do nothing */
269269
case VX_OUTPUT: /* Part processed by putInTable, is a net output */
270270
xport->ref_table[i].use = VX_IX_USE_NO_EXPORT_VALUES;
271+
break;
271272
default: /* All other cases, assume we need to export values unless virtual */
272273
xport->ref_table[i].use = xport->ref_table[i].ref->is_virtual ?
273274
VX_IX_USE_NO_EXPORT_VALUES :

framework/src/vx_kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Kernel::Kernel(vx_context context,
4444
vx_char name[VX_MAX_KERNEL_NAME],
4545
vx_param_description_t *parameters,
4646
vx_uint32 numParams,
47-
vx_reference scope) : Reference(context, VX_TYPE_KERNEL, context)
47+
vx_reference scope) : Reference(context, VX_TYPE_KERNEL, scope)
4848
{
4949
/* setup the kernel meta-data */
5050
strncpy(this->name, name, VX_MAX_KERNEL_NAME - 1);
@@ -556,7 +556,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxReleaseKernel(vx_kernel *kernel)
556556
if (nullptr != kernel)
557557
{
558558
vx_kernel ref = *kernel;
559-
if (vx_true_e == Reference::isValidReference(ref, VX_TYPE_KERNEL) == vx_true_e)
559+
if (vx_true_e == Reference::isValidReference(ref, VX_TYPE_KERNEL))
560560
{
561561
VX_PRINT(VX_ZONE_KERNEL, "Releasing kernel " VX_FMT_REF "\n", (void *)ref);
562562

framework/src/vx_khr_import_kernel.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ static inline void copy_dims(const vx_int32 *dims, vx_int32 num_dims, vx_size *d
7171
static vx_status VX_CALLBACK vxNNEFInitializer(vx_node node, const vx_reference parameters[], vx_uint32 num)
7272
{
7373
vx_char perror[MAXLEN] = "";
74-
7574
vx_status status = VX_SUCCESS;
75+
(void)parameters;
76+
(void)num;
7677

7778
// copy NNEF graph to node
7879
node->attributes.localDataPtr = nnef_graph_copy(node->kernel->attributes.localDataPtr);
@@ -90,8 +91,8 @@ static vx_status VX_CALLBACK vxNNEFInitializer(vx_node node, const vx_reference
9091
static vx_status VX_CALLBACK vxNNEFDeinitializer(vx_node node, const vx_reference parameters[], vx_uint32 num)
9192
{
9293
vx_status status = VX_SUCCESS;
93-
vx_int32 i = 0;
94-
94+
vx_uint32 i = 0;
95+
(void)parameters;
9596
vx_meta_format *meta = node->kernel->signature.meta_formats;;
9697

9798
for (i = 0; i < num; i++)
@@ -124,8 +125,8 @@ static vx_status VX_CALLBACK vxNNEFKernelDeinitializer(vx_kernel nn_kernel)
124125
static vx_status VX_CALLBACK vxNNEFValidator(vx_node node, const vx_reference parameters[], vx_uint32 num, vx_meta_format meta[])
125126
{
126127
vx_status status = VX_SUCCESS;
127-
vx_int32 i = 0;
128-
128+
vx_uint32 i = 0;
129+
(void)node;
129130
for (i = 0; i < num; i++)
130131
{
131132
status = vxSetMetaFormatFromReference(meta[i], parameters[i]);
@@ -233,7 +234,7 @@ static vx_kernel CreateNNEFKernel(vx_context context, vx_int32 input_num, vx_int
233234

234235
if (kernel)
235236
{
236-
vx_uint32 p = 0;
237+
vx_int32 p = 0;
237238
for (p = 0; p < num_params; p++)
238239
{
239240
status = vxAddParameterToKernel(kernel, p,
@@ -297,7 +298,7 @@ VX_API_ENTRY vx_kernel VX_API_CALL vxImportKernelFromURL(vx_context context, con
297298
{
298299
vx_kernel kernel = nullptr;
299300
vx_int32 i = 0, j = 0;
300-
301+
(void)type;
301302
vx_char perror[MAXLEN] = "";
302303
vx_char kernel_name[MAXLEN] = "";
303304
static vx_int32 counter = 1;

0 commit comments

Comments
 (0)