What is UCP?
The Unify Compute Platform(Unify Compute Platform, hereafter referred to UCP) defines a unified set of heterogeneous programming interfaces, and provides APIs(Application Programming Interface, hereafter referred to API) to enable calls to all resources on the SOC(System on Chip, hereafter referred to SOC). UCP abstracts and encapsulates the functional hardware on the SOC, and externally provides function-based APIs for creating corresponding UCP tasks (e.g., VP operator tasks), and supports the setting of a hardware backend to be submitted to the UCP scheduler, which can complete the unified scheduling of tasks on the Soc based on hardware resources.
Specifically, the following features are provided: Vision Process, Neural Network Inference, High Performance Library and Custom Operator Plugin Development(to be realized).
For details of the Backend, you can refer to the section Backend Instruction .
UCP scenarios:
Call single operator: vision operators and high performance processing operators in UCP can be used directly.
Operator plugin development and usage: custom operator development is available. Deep Learning Model Inference: deep learning model inference tasks can be accomplished, and model parsing and hardware deployment are completed within UCP.
UCP advantages:
Highly abstract: for the function of single operator, no need to be troubled by hardware differences, hardware that needs to be executed can be selected by specifying the backend, reducing the difficulty of hardware deployment.
Highly integrated: as Horizon's unified heterogeneous programming interface, all the requirements development can be completed by a set of interfaces.
This section is used to guide you on how to use the UCP for hardware deployment of the model. Knowledge, experience, and skills in basic embedded development can lead to a better understanding of the contents of this section.
There are three ways to execute UCP task structure calls: synchronous execution, asynchronous execution, and registered callback function execution. Here is an example of calling the VP interface hbVPRotate(hbVPRotate) to illustrate the three task execution modes.
When creating a task, pass the corresponding parameter of the taskHandle into the nullptr, which can be immediately synchronously executed, with the following reference code:
When creating a task, the taskHandle parameter needs to be initialized to nullptr in advance. After submitting a UCP task (hbUCPSubmitTask), executing the interface (hbUCPWaitTaskDone) at the specified location in the thread. Waiting for the task to complete, with the following reference code:
When creating a task, the taskHandle parameter needs to be initialized to nullptr in advance. The callback function needs to be registered before the task is submitted (hbUCPSubmitTask).
The reference code for setting the callback function is as follows:
The backend refers to the back-end computing hardware for UCP task execution. The current backends supported by UCP include BPU, DSP, GDC, STITCH, JPU, VPU, PYRAMID.
| Backend | Description |
|---|---|
| BPU | Brain Process Unit, the Horizon Neural Network computational unit. |
| DSP | Digital Signal Processor, a programmable hardware unit. |
| GDC | Geometric Distortion Correction, a hardware IP on ARM that can perform perspective transformation, distortion correction, and image affine transformation on input images. |
| STITCH | The stitch is an IP unit of J6, which can crop and stitch the input image, the stitching modes are: alpha fusion, alpha beta fusion, direct copy. |
| JPU | JPEG Processing Unit, mainly used to complete the JPEG encoding and decoding functions. |
| VPU | Video Processing Unit, a specialized visual processing unit. |
| PYRAMID | Fully known as Image Pyramid, a hardware processing module that reduces the entire original image. |
UCP is applicable for the Horizon J6 and higher architecture computing platforms, you need to have basic embedded development knowledge and skills to complete the cross-compilation and deployment, the usage of the environment and tool requirements refer to the following table:
| Environment/Tools | Supported Version |
|---|---|
| OS | Linux |
| Development board | J6 processor |
| Development language | C++11 |
| Cross compiler | Linaro 11.4.0 |
| Toolchain DSP | Cadence Vsion Q8 2021.7 |
In addition to the development board, UCP also provides the same development support in an x86 emulation environment as it does on the board.
Similar to the development board, UCP provides the same visual processing, model inference, and high-performance computing capabilities in an x86 architecture through emulation. All examples and interface code can be equivalently used in the emulation environment. You can develop and debug code in the x86 environment, gaining immediate feedback during the development process. This allows you to identify and resolve issues early, improving development efficiency and code quality, and ensuring seamless migration of the code to run on SoC hardware.
The emulation methods for each backend supported by UCP are as follows:
gdc_cmodel .Nieuport_JpgEnc and Nieuport_JpgDec, used for JPEG encoding and decoding, respectively.hevc_enc and hevc_dec, used for video encoding and decoding, respectively.The UCP emulation uses the compiler environment provided by the Docker image.
HB_DSP_CMODEL_IMAGE to ensure the application can locate the correct emulation image file.
The reference command is as follows:However, the performance of the x86 emulation environment is usually lower than that of the actual hardware due to the following reasons: As previously mentioned, the emulation methods used by the various backends supported by UCP include instruction-level emulation, CModel executable file emulation, and emulation libraries.
Although the performance of the emulation environment is typically lower than that of actual hardware, the emulation environment provides comprehensive API support and precise functional verification. This significantly enhances your development efficiency and code quality, helping you identify and resolve potential issues at an early stage.