How Fast Is the DSP Algorithm Library?

1. Introduction

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

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 mathematical library?

Below, I will compare the speed of square root calculations and sine trigonometric functions, which will help in selecting different mathematical libraries for different scenarios in the future.

How Fast Is the DSP Algorithm Library?

2. Testing Method

The testing hardware platform is the STM32F103 microcontroller produced yesterday, which is an ARM microcontroller with an M3 core. This microcontroller is quite simple and popular. Let’s take a look at its mathematical computation speed by using a port to output high and low levels to indicate the time required for calculations.

How Fast Is the DSP Algorithm Library?

To use the DSP database, you need to select the CMSIS DSP in the connection library settings under the General options of the IAR development environment. Simply add the arm math header file in the program. In the main loop of the test program, I execute the regular sine trigonometric function calculation and set the LED output pin high and low before and after, so the width of the high pulse indicates the calculation time of the sine function. After a 1ms interval, I execute the sine function from the DSP library, also using the LED pin to indicate execution time. Finally, through an oscilloscope, I can visually compare the differences in execution speed between the two functions.

How Fast Is the DSP Algorithm Library?

How Fast Is the DSP Algorithm Library?

3. Test Results

Using the oscilloscope to measure the waveform of the LED pin, we can see two pulse signals before and after. The first signal is from the sine function in the regular mathematical library, which takes a longer time, while the second signal is from the DSP library sine function, which is clearly shorter. This indicates that for microcontrollers with the M3 core, the efficiency of using the DSP mathematical library is indeed very high.

It should be noted that the microcontroller system clock is currently set to 64MHz. To make a more precise comparison of the execution times of the two mathematical libraries, I expand the waveform. Using the cursor measurement function of the oscilloscope, I measure the time width of the pulses. The regular sine function takes 41.7 microseconds, while the DSP sine function executes in only 10 microseconds. This comparison shows that for the calculation of the sine trigonometric function, the DSP algorithm library is about four times faster than the regular mathematical function.

How Fast Is the DSP Algorithm Library?

  ● Comparison of sine operations:    math:41.7us   DSP:10us

How Fast Is the DSP Algorithm Library?

<span>▲Comparison of the execution speed of the sine function between the regular mathematical library and the DSP library</span>

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

  ● Comparison of square root operations:    math:12.52us   DSP:4.9us

How Fast Is the DSP Algorithm Library?

<span>▲Comparison of the speed differences in the square root operation algorithm functions</span>

Finally, let’s compare the regular integer bit shift operation. The left bit shift of integers among 128 numbers is compared with the time required for regular C language shifting and the time required for the DSP library shift function. The C language shift consumes about 24 microseconds, while the DSP library function consumes 16.65 microseconds, which is about one-third faster.
How Fast Is the DSP Algorithm Library?

How Fast Is the DSP Algorithm Library?

<span>▲Bit shift operation</span>

  ● Comparison of two-bit shifts:    C:24us   DSP:16.65us

4. Conclusion
This article compares the speed of some functions in the CMSIS DSP mathematical library, all of which are faster than the functions in the regular C language and math library, with trigonometric functions improving by about four times and regular bit shift operations improving by about one-third.
That concludes today’s sharing. If you have any original technical articles related to electronic design or other topics, feel free to submit them to us. We will select the best ones for publication, and you will receive a reward for your article!
How Fast Is the DSP Algorithm Library?
Note:

Due to recent changes in WeChat public platform push rules, many readers have reported not seeing the updated articles in a timely manner. According to the latest rules, it is recommended to frequently click on “Recommended Reading, Share, Collect”, etc., to become a regular user.

Recommended Reading:

  • Foreign Media: ASML Will Move Out of the Netherlands

  • Regrettably! Another Old PCB Company in Guangdong Goes Bankrupt

  • The Era of Incomplete Chip Storage 12-inch Wafer Plant Finally Has a Buyer!!

Please click 【View】 to give the editor a thumbs up

How Fast Is the DSP Algorithm Library?

Leave a Comment