• 04/03/2020
  • Public Content

Adding User Kernels from a User Kernel Library

To enable some kinds of re-use of user kernels between applications, usually the kernels are grouped into dynamically-loaded libraries. Below is a subset of the related OpenVX APIs:
Loads the specified module with kernels into the OpenVX* context. The format of the loaded file might be a dynamically linked library, but it is implementation dependent.
Entry point that should be implemented in modules loaded by vxLoadKernels. Similarly, the vxUnpublishKernels is called when kernels library is unloaded.
Obtains a reference to the kernel using the enumeration.
Obtains a reference to the kernel using by the name.
Gets information about number of parameters, enum values, etc.
Creates a reference to a node object for a given kernel.
Sets parameters to complete a node.
The function
loads the module into the given context and calls the
to publish the list of added kernels and their parameter information.
Upon kernel publication, you can use
to query kernels and then create a generic node for a kernel object. Finally,
has to be used to set the arguments, while the argument list also can be queried for each kernel:
//Loads the “libmy_ovx” library with user-kernel for division vx_status s = vxLoadKernels(ctx, “libmy_ovx”) ; //Get the kernel, by name vx_kernel kernel = vxGetKernelByName(ctx, “my_div”); //query the kernel parameters vxQueryKernel(kernel,VX_KERNEL_PARAMETERS, &np, sizeof(np)); printf(“Number of Kernel parameters is: %d\n”,np); for(size_t j = 0; j < np; ++j) { vx_parameter p = vxGetKernelParameterByIndex(kernel, j); vx_type_e t; vxQueryParameter(p,VX_PARAMETER_TYPE, &t, sizeof(t)); assert(VX_TYPE_DF_IMAGE==t); //the kernel accepts just images } vx_node div_node = vxCreateGenericNode(graph, kernel); //Set the arguments to the node, connecting the node to the graph vx_image img_in0 = vxCreateImage(ctx, 640, 480,VX_DF_IMAGE_U8); vx_image img_in1 = vxCreateImage(ctx, 640, 480,VX_DF_IMAGE_U8); vx_image img_out = vxCreateImage(ctx, 640, 480,VX_DF_IMAGE_U8); vxSetParameterByIndex(div_node, 0, (vx_reference)img_in0); vxSetParameterByIndex(div_node, 1, (vx_reference)img_in1); vxSetParameterByIndex(div_node, 2, (vx_reference)img_out);
Alternatively, when the user library header file is available, you can create nodes using regular function declaration:
//in my_div.h: vx_node vxDivNode(vx_graph g,vx_image i0,vx_image i1,vx_image out); //in main.cpp: #include “my_div.h” ... vxDivNode(graph, in0, in1, out);

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804