How Fast Is the DSP Algorithm Library? A Performance Comparison

In ARM microcontroller development, there is a DSP function library provided by CMSIS. This library includes basic data functions, fast mathematical operations, complex operations, filters, matrices, transforms, click control, statistics, support functions, and interpolation functions, covering most algorithms used in engineering applications.

Now, I have a question: how much speed improvement can be achieved by using the DSP functions in CMSIS compared to the functions in a regular math library? Let’s compare the speed of square root operations and sine trigonometric functions. This will help in choosing different mathematical libraries for various scenarios in the future.

How Fast Is the DSP Algorithm Library? A Performance Comparison

The test hardware platform is the STM32F103 microcontroller that I built yesterday. This is an ARM microcontroller with an M3 core, which is relatively simple and popular, so let’s check its mathematical computation speed. A port is used to output high and low levels to indicate the time required for the calculations.

How Fast Is the DSP Algorithm Library? A Performance Comparison

To use the DSP database, you need to select CMSIS DSP in the library settings of the General options in the IAR development environment. Just include the arm math header file in your program. In the main loop of the test program, the normal sine trigonometric function is calculated, and the LED output pin is set high and low to indicate the calculation time. After a 1ms interval, the sine function from the DSP library is executed, also using the LED pin to indicate execution time. The differences in execution speeds of the two functions can be intuitively compared using an oscilloscope.

How Fast Is the DSP Algorithm Library? A Performance Comparison

How Fast Is the DSP Algorithm Library? A Performance Comparison

Using the oscilloscope to measure the waveform of the LED pin, we can see the two pulse signals. The first signal corresponds to the sine function from the regular math library, which takes longer, while the second signal corresponds to the sine function from the DSP library, which is noticeably shorter. This indicates that the efficiency of using the DSP math library is very high for microcontrollers with the M3 core. It should be noted that the microcontroller’s system clock is at 64MHz. To compare the execution times of the two math libraries more accurately, we expand the waveform. Using the cursor measurement function of the oscilloscope, we measure the pulse width. The normal sine function takes 41.7 microseconds, while the DSP sine function takes only 10 microseconds, indicating that the DSP algorithm library is about four times faster than the regular math function for sine calculations.

How Fast Is the DSP Algorithm Library? A Performance Comparison

  ● Sine Operation Comparison:    math: 41.7us   DSP: 10us

How Fast Is the DSP Algorithm Library? A Performance Comparison

▲ Figure 1.3.1 Comparison of Sine Function Execution Speed Between Regular Math Library and DSP Library

Next, let’s compare floating-point square root operations.The method used is the same.We measure the difference between the regular math library function and the DSP math library function using an oscilloscope.The regular math library takes 12.52 microseconds to calculate the square root of a floating-point number, while the square root operation in the DSP math library only takes 4.9 microseconds.This is less than three times faster than the regular math library.This indicates that the speedup of the DSP library varies for different mathematical operations.
How Fast Is the DSP Algorithm Library? A Performance Comparison

  ● Square Root Operation Comparison:    math: 12.52us   DSP: 4.9us

How Fast Is the DSP Algorithm Library? A Performance Comparison

▲ Figure 1.3.2 Difference in Execution Speed of Square Root Algorithm Functions

Finally, let’s compare regular integer bit-shifting operations.We will compare the time it takes to shift an integer left among 128 numbers using both regular C language shifting and DSP library shifting functions.The C language shifting takes about 24 microseconds, while the DSP library function takes 16.65 microseconds, which is about one-third faster.
How Fast Is the DSP Algorithm Library? A Performance Comparison

How Fast Is the DSP Algorithm Library? A Performance Comparison

▲ Figure 1.3.3 Bit-Shifting Operation

  ● Bit Shift Comparison:    C: 24us   DSP: 16.65us

Conclusion

This article compared the execution speeds of some functions in the CMSIS DSP math library, all of which showed improvements over the speeds of functions in the regular C language and math library. The trigonometric functions improved by about four times, while the regular bit-shifting operations improved by about one-third.

END
How Fast Is the DSP Algorithm Library? A Performance Comparison
More Practical Project Recommendations:

<<< STM32 Project Collection >>>

<<< Raspberry Pi Project Collection >>>

<<< ESP32 Project Collection >>>

<<< ESP8266 Project Collection >>>

<<< Arduino Project Collection >>>

<<< Darwin Project Sharing Series >>>

Recommended Reading:
Project Sharing | Electric Competition Series | Artificial Intelligence | Postgraduate Entrance Examination
Essential Knowledge Points | Graduation Design | Switching Power Supply | Job Search
We are Nimo, the founder of Darwin, who only talks about technology and not romance. The Darwin online education platform aims to serve professionals in the electronics industry, providing skill training videos covering popular topics in various subfields, such as embedded systems, FPGA, artificial intelligence, etc. We customize layered learning content for different groups of people, such as common knowledge points, disassembly assessments, electric competitions/intelligent vehicles/postgraduate entrance examinations, etc. Welcome to follow us.
Official Website: www.darwinlearns.com
Bilibili: Darwin
How Fast Is the DSP Algorithm Library? A Performance Comparison

Leave a Comment