FAQ
General Issues
What is the reason for returning HB_UCP_INVALID_ARGUMENT error code after task creation or submission?
Possible problems can be determined from the UCP error logs, which may exist as follows:
-
Operator Constraint Problem: Most acceleration operators should satisfy usage constraints when they are created, otherwise they will return error code.
-
If you encounter a log that prints
op $1 of task has no proper backend, user expect $2, indicating that there is no proper backend available for execution, where$1indicates the type of the task and$2is the backend parameter when the task is submitted in binary form, and the configuration needs to be done according to the number of cores that each J6 series backend can support.
How to understand the physical and virtual addresses of hbUCPSysMem?
In the J6 processor architecture, all hardware share the DDR memory, and a physically contiguous section of memory can be requested through the hbUCPMallocCached and hbUCPMalloc interfaczes.
The return values of these functions are wrapped in the hbUCPSysMem data structure,
and the phyAddr and virAddr fields correspond to the physical and virtual addresses of its memory space, respectively.
As this memory space is contiguous, both physical and virtual addresses can be represented, read, and written by the first address. However, in practice, it is recommended to use virtual addresses in preference in non-essential scenarios.
How to understand cacheable and non-cacheable hbmem?
UCP's memory management interface provides hbUCPMallocCached and hbUCPMalloc to allocate DDR read/write memory, which is physically contiguous and can be accessed and used by bpu/dsp and other ip accesses.
Where hbUCPMallocCached represents the allocation of memory for the cacheable attribute and is accompanied by the hbUCPMemFlush function to refresh the Cache.
The cache mechanism is determined by the memory architecture of the platform, as shown in the following figure. The cache between CPU and memory is used as a data cache, however, there is no cache between the BPU/DSP/JPU/VPU(Video Process Unit)/PYRAMID/STITCH/GDC backend hardware and main memory. Therefore, the misuse of the cache can cause problems in data reading/writing accuracy and efficiency.
-
When the CPU has finished writing data, it needs to actively flush the data in the cache to the memory, otherwise other hardware accessing the same memory space may read the old data from before.
-
The CPU also needs to actively INVALIDATE the data in the Cache before accessing it when the other backend hardware has finished writing the data, otherwise the CPU will preferentially read the old data previously cached.
-
In the continuous inference process of the model, those that need to be read by the cpu, such as the model output, it is recommended to apply for memory with cacheable to accelerate the efficiency of the CPU to read and write repeatedly, while those that don't need to be read, and are only written, such as the model input, can apply for non-cacheable memory.
Can exit be used in exception handling on the application side?
Due to the existence of a resource management singleton within UCP, calling exit/std::exit on the application side (including in overridden signal handlers) will trigger the singleton's destructor. If there are still threads accessing the singleton's resources at that time, it can easily lead to exceptions. Therefore, UCP recommends using _exit/std::quick_exit. If you must use exit/std::exit, please ensure that no threads are accessing any UCP resources when exiting.
How to ensure log integrity when application exits abnormally?
To ensure that critical log messages are not lost due to abnormal process termination, it is recommended that the application calls the hbUCPFlushLog interface before abnormal exit to flush the buffered logs and ensure that all log messages are written to disk. This is particularly important for debugging anomalies and tracing system failures.
Model Inference
What are the possible causes of the timeout on the hbUCPWaitTaskDone interface for model reasoning?
-
The model itself takes a long time to execute, and an insufficient timeout set by the asynchronous wait interface, or a long queuing time for the task due to a high load on the current computational resources, may trigger an interface timeout.
-
Memory leaks exist. Slow allocation of memory in case of insufficient system memory may lead to inference timeout.
-
CPU load is too high. The scheduling thread can't get CPU, at this time, even if the task is completed, it can't be synchronized to the user interface in time, which leads to the reasoning timeout situation.
Reasons why model inference gets stuck
Model problem: The underlying running error caused by the model command reason, the error is not reported, resulting in hang. At this point, the bpu task situation can be viewed by cat /sys/devices/system/bpu/bpu0/task_running, as shown below:
If s_time is not null, it means that the task has started normally, while p_time is null, it means that it has not returned normally, which can be assumed that the BPU task hangs, and can be solved by contacting sr or the compiler team.
What are the ROI input model constraints?
You can refer to the ROI Introduction and Constraints for the introduction of ROI constraints.
Troubleshooting model inference result consistency issues
-
Please ensure that the outputs used for consistency comparison have had padding removed.
-
If the model has dynamic-shaped outputs, please ensure that the
hbDNNGetTaskOutputTensorPropertiesAPI is called to obtain the actual output shape. -
Please ensure that Flush operations are correctly performed on both input and output memory.
-
If the consistency issue is resolved after disabling UCP ARM optimized operators, then the issue lies with the optimized operators. Method to disable:
Model inference performance optimization recommendations
-
Try to eliminate CPU operators in the model as much as possible.
-
It is recommended to allocate inference memory in a unified manner, use it in a distributed way, and enable memory reuse.
-
On the premise of implementing input/output memory reuse for the model, enable the Map LRU Cache strategy to mitigate BPU Map overhead. Method to enable:
- Adjust thread priorities. It is recommended to increase the priority of scheduling threads. If only model inference is used, it is recommended to disable unused backends such as DSP and ISP to reduce the number of threads. Reference example:
- Specify the BPU core ID during inference to reduce the number of Memory Map operations on multi-core hardware.
Custom OP Development
DSP Related
What are the DSP models selected for the J6?
The J6 uses Cadence's Tensilica Vision Q8 DSP IP (hereinafter referred to as Q8), a digital signal processor dedicated to vision/image processing, with the number of DSP IPs varying slightly depending on the development board model. More information can be found: DSP Development Documentation or Cadence Official Documentation。
How do to get the official Cadence documentation?
Installation steps can be referred to: DSP Development Documentation section; After installing the Cadence Development Kit, you can view some of the documentation within the development package. To obtain the complete documentation package, please contact Horizon technical support staff.
What computational accuracy does the DSP support?
Support int8/int16/int32 integer calculations, as well as float32 and double floating point calculations.
How to view the log output on the DSP side?
In the X86 simulation environment, you can view the log output by modifying the log printing level environment variable HB_DSP_VDSP_LOG_LEVEL when executing the sample script, and the method of setting the log level is the same as that of the UCP, and the modification method, please refer to the contents of the script;
In the development board, you can view the logs on the DSP side by monitoring the log file. The specific method is as follows:
- Add the environment variable export HB_DSP_WRITE_VDSP_LOG_TO_ARM=true to enable DSP log output.
-
Modify the DSP log printing level environment variable HB_DSP_VDSP_LOG_LEVEL.
-
Use the following command to enable file monitoring.
Can the DSP custom operator samples be run directly?
No. Using custom operators requires recompiling the DSP image before registering the operator implementation into the DSP calling framework. Therefore, the DSP image need to be compile first, then copy the image to the development board, and then run the example. For the compilation and running steps, please refer to: Custom Operator Samples section.
However, for code development or compiling new images, the DSP development software Xplorer and the corresponding License file are required, which can be obtained by contacting Horizon technical support.
What are the commonly used DSP debugging commands?
- Obtain the status of the vdsp core, which can be either "offline" or "online".
- Obtain the vdsp image name and version. The version contains information such as the compilation version, compilation date, hash_id, etc., which can be used for version tracing.
There is no name information for QNX operating system in J6E/M, please check according to the specific environment.
-
Use the dmesg command to view low-level software log information.
-
Check the latest vdsp logs written to disk.
- DSP start/stop commands.
How to Troubleshoot DSP Custom Operator Hangs?
-
Check DSP logs for any error messages.
-
Determine if the DSP is hung or has coredumped by using the dmesg command to view kernel logs.
-
Investigate ARM-side code for potential memory Map/Unmap or cache refresh issues.
-
Examine DSP-side code for cache refresh problems, using methods like global refresh or binary search to locate faults.
-
Check DSP-side code for logical or memory access errors, using dmesg to view kernel log messages.
What Issues Can DDR Cache Desynchronization Cause in DSP Custom Operators?
-
Data inconsistency between ARM and DSP read/write operations.
-
DSP freezes or becomes unresponsive, potentially due to using unrefreshed memory.
-
DSP coredumps with error logs in kernel messages (dmesg), which can help locate specific fault addresses.
