Skip to content
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
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ common --enable_bzlmod
build --compiler=g++ # Specify the compiler if needed, e.g., gcc, clang
build --cxxopt=-std=c++23 # Use C++23 standard (adjust if needed)
build --cxxopt=-DCL_TARGET_OPENCL_VERSION=300
# build --per_file_copt=.*,-tests/*.cpp@-Werror
build --per_file_copt=.*,-tests/*.cpp@-Werror,-Wall,-Wextra,-Wpedantic,-Wno-deprecated-declarations

# Test settings
test --test_output=errors # Show errors from tests
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
- name: Build the code
run: bazel build //...

# Run OpenVX Integration test
- name: OpenVX Integration Test
run: VX_CL_SOURCE_DIR=$GITHUB_WORKSPACE/kernels/opencl bazel run //tests:vx_test

# Test the project
# - name: Run Bazel tests
# run: |
Expand Down
2 changes: 1 addition & 1 deletion framework/include/vx_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Scalar : public Reference
/*! \brief Signed 64 bit */
vx_int64 s64;
/*! \brief Unsigned 64 bit */
vx_int64 u64;
vx_uint64 u64;
#if defined(EXPERIMENTAL_PLATFORM_SUPPORTS_16_FLOAT)
/*! \brief 16 bit float */
vx_float16 f16;
Expand Down
36 changes: 30 additions & 6 deletions framework/src/vx_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,28 @@ vx_status Context::loadTarget(const vx_char* targetName)

vx_status Context::unloadTarget(const vx_char* targetName)
{
return VX_ERROR_NOT_IMPLEMENTED;
vx_status status = VX_FAILURE;

for (vx_uint32 t = 0u; t < context->num_targets; t++)
{
if (context->targets[t] &&
strncmp(context->targets[t]->name, targetName, VX_MAX_TARGET_NAME) == 0)
{
memset(&context->targets[t]->funcs, 0xFE, sizeof(vx_target_funcs_t));
if (context->targets[t]->decrementReference(VX_INTERNAL) == 0)
{
/* The ReleaseReference() below errors out if the internal index is 0 */
context->targets[t]->incrementReference(VX_INTERNAL);
}
Osal::unloadModule(context->targets[t]->module.handle);
context->targets[t]->module.handle = VX_MODULE_INIT;

memset(context->targets[t]->module.name, 0, sizeof(context->targets[t]->module.name));
status = Reference::releaseReference((vx_reference*)&context->targets[t], VX_TYPE_TARGET, VX_INTERNAL, nullptr);
}
}

return status;
}

vx_status Context::unloadTarget(vx_uint32 index, vx_bool unload_module)
Expand Down Expand Up @@ -758,8 +779,8 @@ VX_API_ENTRY vx_context VX_API_CALL vxCreateContext(void)
if (context->num_targets == 0)
{
VX_PRINT(VX_ZONE_ERROR, "No targets loaded!\n");
// free(context);
Osal::semPost(&context_lock);
single_context.reset();
return nullptr;
}

Expand All @@ -774,8 +795,11 @@ VX_API_ENTRY vx_context VX_API_CALL vxCreateContext(void)
{
VX_PRINT(VX_ZONE_WARNING, "Target %s failed to initialize!\n", context->targets[t]->name);
/* unload this module */
context->unloadTarget(t, vx_true_e);
break;
/* @TODO: unload target now or on context release? */
/*
* context->unloadTarget(t, vx_true_e);
* break;
*/
}
else
{
Expand Down Expand Up @@ -922,7 +946,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxReleaseContext(vx_context* c)
/* de-initialize and unload each target */
for (t = 0u; t < context->num_targets; t++)
{
if (context->targets[t]->enabled == vx_true_e)
/* if (context->targets[t]->enabled == vx_true_e) */
{
context->targets[t]->funcs.deinit(context->targets[t]);
context->targets[t]->enabled = vx_false_e;
Expand Down Expand Up @@ -1118,7 +1142,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxQueryContext(vx_context context, vx_enum at
case VX_CONTEXT_EXTENSIONS:
if (size <= sizeof(extensions) && ptr)
{
strncpy(reinterpret_cast<char*>(ptr), extensions, sizeof(extensions));
strncpy(reinterpret_cast<char*>(ptr), extensions, size);
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion framework/src/vx_dot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxExportGraphToDot(vx_graph graph, vx_char do
{
vx_pyramid pyr = (vx_pyramid)data[d];
fprintf(fp, "\tD%u [shape=triangle label=\"Pyramid\\n%lfx" VX_FMT_REF "\\nLevels: %zu\"];\n",
d, pyr->scale, pyr->levels, pyr->numLevels);
d, pyr->scale, (void*)pyr->levels, pyr->numLevels);
break;
}
case VX_TYPE_SCALAR:
Expand Down Expand Up @@ -155,6 +155,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxExportGraphToDot(vx_graph graph, vx_char do
{
fprintf(fp, "\tD%u [shape=box label=\"Distribution\"];\n", d);
}
break;
}
case VX_TYPE_LUT:
{
Expand Down
3 changes: 2 additions & 1 deletion framework/src/vx_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ status(VX_SUCCESS)
Error::~Error()
{
vx_error ref = this;
releaseError(&ref);
if (internal_count)
releaseError(&ref);
}

void Error::releaseError(vx_error* error)
Expand Down
2 changes: 1 addition & 1 deletion framework/src/vx_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ vx_node vxCreateNodeByStructure(vx_graph graph,
vx_node node = 0;
vx_context context = vxGetContext((vx_reference)graph);
vx_kernel kernel = vxGetKernelByEnum(context, kernelenum);
if (kernel)
if (VX_SUCCESS == vxGetStatus((vx_reference)kernel))
{
node = vxCreateGenericNode(graph, kernel);
if (vxGetStatus((vx_reference)node) == VX_SUCCESS)
Expand Down
1 change: 1 addition & 0 deletions framework/src/vx_ix_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ static void calculateUses(VXBinExport *xport)
break; /* Already assigned, do nothing */
case VX_OUTPUT: /* Part processed by putInTable, is a net output */
xport->ref_table[i].use = VX_IX_USE_NO_EXPORT_VALUES;
break;
default: /* All other cases, assume we need to export values unless virtual */
xport->ref_table[i].use = xport->ref_table[i].ref->is_virtual ?
VX_IX_USE_NO_EXPORT_VALUES :
Expand Down
4 changes: 2 additions & 2 deletions framework/src/vx_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Kernel::Kernel(vx_context context,
vx_char name[VX_MAX_KERNEL_NAME],
vx_param_description_t *parameters,
vx_uint32 numParams,
vx_reference scope) : Reference(context, VX_TYPE_KERNEL, context)
vx_reference scope) : Reference(context, VX_TYPE_KERNEL, scope)
{
/* setup the kernel meta-data */
strncpy(this->name, name, VX_MAX_KERNEL_NAME - 1);
Expand Down Expand Up @@ -556,7 +556,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxReleaseKernel(vx_kernel *kernel)
if (nullptr != kernel)
{
vx_kernel ref = *kernel;
if (vx_true_e == Reference::isValidReference(ref, VX_TYPE_KERNEL) == vx_true_e)
if (vx_true_e == Reference::isValidReference(ref, VX_TYPE_KERNEL))
{
VX_PRINT(VX_ZONE_KERNEL, "Releasing kernel " VX_FMT_REF "\n", (void *)ref);

Expand Down
15 changes: 8 additions & 7 deletions framework/src/vx_khr_import_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ static inline void copy_dims(const vx_int32 *dims, vx_int32 num_dims, vx_size *d
static vx_status VX_CALLBACK vxNNEFInitializer(vx_node node, const vx_reference parameters[], vx_uint32 num)
{
vx_char perror[MAXLEN] = "";

vx_status status = VX_SUCCESS;
(void)parameters;
(void)num;

// copy NNEF graph to node
node->attributes.localDataPtr = nnef_graph_copy(node->kernel->attributes.localDataPtr);
Expand All @@ -90,8 +91,8 @@ static vx_status VX_CALLBACK vxNNEFInitializer(vx_node node, const vx_reference
static vx_status VX_CALLBACK vxNNEFDeinitializer(vx_node node, const vx_reference parameters[], vx_uint32 num)
{
vx_status status = VX_SUCCESS;
vx_int32 i = 0;

vx_uint32 i = 0;
(void)parameters;
vx_meta_format *meta = node->kernel->signature.meta_formats;;

for (i = 0; i < num; i++)
Expand Down Expand Up @@ -124,8 +125,8 @@ static vx_status VX_CALLBACK vxNNEFKernelDeinitializer(vx_kernel nn_kernel)
static vx_status VX_CALLBACK vxNNEFValidator(vx_node node, const vx_reference parameters[], vx_uint32 num, vx_meta_format meta[])
{
vx_status status = VX_SUCCESS;
vx_int32 i = 0;

vx_uint32 i = 0;
(void)node;
for (i = 0; i < num; i++)
{
status = vxSetMetaFormatFromReference(meta[i], parameters[i]);
Expand Down Expand Up @@ -233,7 +234,7 @@ static vx_kernel CreateNNEFKernel(vx_context context, vx_int32 input_num, vx_int

if (kernel)
{
vx_uint32 p = 0;
vx_int32 p = 0;
for (p = 0; p < num_params; p++)
{
status = vxAddParameterToKernel(kernel, p,
Expand Down Expand Up @@ -297,7 +298,7 @@ VX_API_ENTRY vx_kernel VX_API_CALL vxImportKernelFromURL(vx_context context, con
{
vx_kernel kernel = nullptr;
vx_int32 i = 0, j = 0;

(void)type;
vx_char perror[MAXLEN] = "";
vx_char kernel_name[MAXLEN] = "";
static vx_int32 counter = 1;
Expand Down
1 change: 1 addition & 0 deletions framework/src/vx_node_nn_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ VX_API_ENTRY vx_node VX_API_CALL vxLocalResponseNormalizationLayer(vx_graph grap
vx_float32 bias,
vx_tensor outputs)
{
(void)bias;
vx_context context = vxGetContext((vx_reference)graph);
vx_scalar type_scalar = vxCreateScalar(context, VX_TYPE_ENUM, &type);
vx_scalar norm_size_scalar = vxCreateScalar(context, VX_TYPE_SIZE, &normalization_size);
Expand Down
9 changes: 7 additions & 2 deletions framework/src/vx_osal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ vx_bool Osal::waitEventInternal(vx_internal_event_t *e, vx_uint32 ms)
gettimeofday(&now, nullptr);
time_spec.tv_sec = now.tv_sec + (ms / 1000);
time_spec.tv_nsec = (now.tv_usec * 1000) + ((ms%1000) * 1000000);
if (time_spec.tv_nsec > BILLION) {
if (static_cast<unsigned long long>(time_spec.tv_nsec) > BILLION) {
time_spec.tv_sec += 1;
time_spec.tv_nsec -= BILLION;
}
Expand Down Expand Up @@ -313,14 +313,19 @@ void Osal::sleepThread(vx_uint32 milliseconds)
nanosleep(&rtsp, nullptr);
#elif defined(_WIN32) || defined(UNDER_CE)
Sleep(milliseconds);
#else
(void)milliseconds;
#endif
}

vx_thread_t Osal::createThread(vx_thread_f func, void *arg)
{
vx_thread_t thread = 0;
#if defined(__linux__) || defined(__ANDROID__) || defined(__QNX__) || defined(__CYGWIN__) || defined(__APPLE__)
pthread_create(&thread, nullptr, (pthread_f)func, arg);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
pthread_create(&thread, nullptr, reinterpret_cast<pthread_f>(func), arg);
#pragma GCC diagnostic pop
#elif defined(_WIN32) || defined(UNDER_CE)
thread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, arg, CREATE_SUSPENDED, nullptr);
if (thread)
Expand Down
Loading
Loading