Main Content

Use Hardware Acceleration to Speed Up Simulation for Object Detection

This example shows how to use hardware acceleration to speed up a Simulink® model simulation for object detection. You can use Performance Advisor to compare simulation speeds and select an appropriate level for hardware acceleration. Hardware acceleration is achieved by leveraging single instruction, multiple data (SIMD) in simulation targets. All processors that support Simulink simulation have SIMD instructions. For more information, see Hardware acceleration and SIMD Code Generation (DSP System Toolbox).

Open Model

Open the object detection model. This model is an aggregate channel feature-based object detection system, which puts bounding boxes upon the detected objects. To leverage hardware acceleration for the model, set the simulation mode to rapid accelerator. Simulate the model. Observe that the simulation time is 8 seconds. If you cannot find the video for Traffic Video Block when running the simulation, click Setup Input Video in the model.

Run Performance Advisor to Select Hardware Acceleration Level

To set hardware acceleration settings, in the Simulink Toolstrip, on the Debug tab, click Performance Advisor. In the pane on the left, expand Simulation Targets, then expand Check Hardware Acceleration Settings and select Select hardware acceleration settings. Click Run this check. The Result pane shows the simulation times for different hardware acceleration levels and the hardware information of your computer. In this example, the software detects an Intel-type CPU that supports SSE and AVX, where SSE2 is used for generic hardware acceleration and AVX2 is used for native hardware acceleration. Click Modify all to apply the recommended hardware acceleration level.

Alternatively, you can change the level of the hardware acceleration manually. Under the Modeling tab, click Model Settings. On the left pane, select Simulation Target. Expand Advanced parameters and set Hardware acceleration to

  • Off

  • Leverage generic hardware (Faster, no rebuild)

  • Leverage native hardware (Fastest, rebuild allowed)

Improve Performance with Hardware Acceleration

These images show the aggregate channel feature-based object detection system placing bounding boxes on the detected objects with no hardware acceleration and with hardware acceleration. The instantaneous frames per second (FPS) data is displayed in the top left of each image. With the same video input, the FPS with no hardware acceleration is 8.72 and the FPS with hardware acceleration is 11.90.

Performance improvement with hardware acceleration is based on execution time, which is measured using the sim command. Without hardware acceleration, simulation execution time is 34.50 seconds. With hardware acceleration, simulation execution time is 23.04 seconds, which is a 33.22% improvement. Note that simulation time improvement may vary on different hardware. These numbers and analysis were published on a Windows laptop with Intel® Core™ i7-8650U CPU @ 1.90GHz 4 Cores 8 Threads processor.

Related Topics