Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

CMSIS-DSP

> 编程语言
Open source

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A

1.1K stars0 likes1 views
WebsiteGitHub

About

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A

CMSIS-DSP

About

CMSIS-DSP is an optimized compute library for embedded systems (DSP is in the name for legacy reasons).

It provides optimized compute kernels for Cortex-M and for Cortex-A.

Different variants are available according to the core and most of the functions are using a vectorized version when the Helium or Neon extension is available.

This repository contains the CMSIS-DSP library and several other projects:

  • Test framework for bare metal Cortex-M or Cortex-A
  • Examples for bare metal Cortex-M
  • PythonWrapper

You don't need any of the other projects to build and use CMSIS-DSP library. Building the other projects may require installation of other libraries (CMSIS), other tools (Arm Virtual Hardware) or CMSIS build tools.

CMSIS-DSP Kernels

Kernels provided by CMSIS-DSP (list not exhaustive):

  • Basic mathematics (real, complex, quaternion, linear algebra, fast math functions)
  • DSP (filtering)
  • Transforms (FFT, MFCC, DCT)
  • Statistics
  • Classical ML (Support Vector Machine, Distance functions for clustering ...)

Kernels are provided with several datatypes : f64, f32, f16, q31, q15, q7.

C++ API (DSP++)

DSP++ provides a higher-level C++ API for combining existing CMSIS-DSP kernels into new algorithms while keeping good performance. Its loop fusion feature can combine several operations into a single loop, avoiding temporary arrays and repeated passes over the data.

DSP++ is entirely optional and header-only: it requires no separate library build. Applications using only the C API are unaffected: no code or build changes are needed, and the extension adds no code size, memory or runtime overhead.

DSP++ is currently unsupported in builds with ARM_MATH_NEON enabled. On Cortex-A, enabling this macro to benefit from Neon in the C API also affects DSP++: its incomplete Neon implementation can cause compilation errors, with no automatic scalar fallback. Applications using only the C API can continue to use Neon normally.

The C++ API headers are in dsppp/Include and are included in the CMSIS-DSP pack starting with version 1.18.0. See the DSP++ introduction for an example.

Experimental autodiff extension

Built on DSP++, the automatic differentiation (autodiff) extension is experimental and is not a new ML framework. Its focus is on-device fine-tuning using a subset of existing CMSIS-DSP kernels. See the autodiff introduction to learn more.

Python wrapper

A PythonWrapper is also available and can be installed with:

pip install cmsisdsp

With this wrapper you can design your algorithm in Python using an API as close as possible to the C API. The wrapper is compatible with NumPy. The wrapper is supporting fixed point arithmetic. This wrapper works in google colab.

The goal is to make it easier to move from a design to a final implementation in C.

Support / Contact

For any questions or to reach the CMSIS-DSP team, please create a new issue in https://github.com/ARM-software/CMSIS-DSP/issues

Table of content

  • Building for speed
    • Options to use
    • Options to avoid
  • Half float support
  • How to build
    • How to build with MDK or Open CMSIS-Pack
    • How to build with Make
    • How to build with cmake
    • How to install as a cmake package
    • How to build with Zephyr
    • How to build with any other build system
    • How to build for Neon and aarch64
  • Code size
  • Folders and files
    • Folders
    • Files

Building for speed

CMSIS-DSP is used when you need performance. As consequence CMSIS-DSP should be compiled with the options giving the best performance:

Options to use

  • -O3 -ffast-math must be used for best performances.
  • When using Helium it is strongly advised to use -O3 -ffast-math
  • GCC is currently not giving good performances when targeting Helium. You should use the Arm compiler

When float are used, then the fpu should be selected to ensure that the compiler is not using a software float emulation.

When building with Helium support, it will be automatically detected by CMSIS-DSP. For Neon, it is not the case and you must enable the option -DARM_MATH_NEON for the C compilation. With cmake this option is controlled with -DNEON=ON.

  • -DLOOPUNROLL=ON can also be used when compiling with cmake
  • It corresponds to the C options -DARM_MATH_LOOPUNROLL

Compilers are doing unrolling. So this option may not be needed but it is highly dependent on the compiler. With some compilers, this option is needed to get better performances.

Speed of memory is important. If you can map the data and the constant tables used by CMSIS-DSP in DTCM memory then it is better. If you have a cache, enable it.

Options to avoid

  • -fno-builtin
  • -ffreestanding because it enables previous options

The library is doing some type punning to process word 32 from memory as a pair of q15 or a quadruple of q7. Those type manipulations are done through memcpy functions. Most compilers should be able to optimize out those function calls when the length to copy is small (4 bytes).

This optimization will not occur when -fno-builtin is used and it will have a very bad impact on the performances.

Some compiler may also require the use of option -munaligned-access to specify that unaligned accesses are used.

Half float support

f16 data type (half float) has been added to the library. It is useful only if your Cortex has some half float hardware acceleration (for instance with Helium extension). If you don't need f16, you should disable it since it may cause compilation problems. Just define -DDISABLEFLOAT16 when building.

How to build

You can build CMSIS-DSP with the open CMSIS-Pack, or cmake, or Makefile and it is also easy to build if you use any other build tool.

How to build with MDK or Open CMSIS-Pack

The standard way to build is by using the CMSIS pack technology. CMSIS-DSP is available as a pack.

You can use CMSIS-Toolbox or any of the Arm Keil IDEs

If you want to build the FFT example for the Corstone-300 virtual hardware platform, you could just do:

cbuild -O cprj examples_ac6.csolution.yml --update-rte -r --toolchain AC6 -c fftbin.Release+VHT-Corstone-300"

from the Examples/cmsis_build folder and assuming the command line tools and the needed packs have been installed.

How to build with Make

There is an example Makefile in Source.

In each source folder (like BasicMathFunctions), you'll see files with no _datatype suffix (like BasicMathFunctions.c and BasicMathFunctionsF16.c).

Those files are all you need in your makefile. They are including all other C files from the source folders.

Then, for the includes you'll need to add the paths: Include, PrivateInclude and, since there is a dependency to CMSIS Core, Core/Include from CMSIS_5/CMSIS.

If you are building for Cortex-A and want to use Neon, you'll also need to include ComputeLibrary/Include and the source file in ComputeLibrary/Source.

How to build with cmake

Create a CMakeLists.txt and inside add a project.

Add CMSIS-DSP as a subdirectory. The variable CMSISDSP is the path to the CMSIS-DSP repository in below example.

cmake
cmake_minimum_required (VERSION 3.14)

# Define the project
project (testcmsisdsp VERSION 0.1)

add_subdirectory(${CMSISDSP}/Source bin_dsp)

CMSIS-DSP is dependent on the CMSIS Core includes. So, you should define CMSISCORE on the cmake command line. The path used by CMSIS-DSP will be ${CMSISCORE}/Include.

You should also set the compilation options to use to build the library.

If you build for Helium, you should use any of the option MVEF, MVEI or HELIUM.

If you build for Neon, use NEON and/or NEONEXPERIMENTAL.

Launching the build

Once cmake has generated the makefiles, you can use a GNU Make to build.

make VERBOSE=1

How to install as a cmake package

CMSIS-DSP can be installed as a cmake package for host builds on Windows, macOS, or Linux. Set CMAKE_INSTALL_PREFIX to the folder where the package must be installed. The installed package exports the target CMSISDSP::CMSISDSP. Headers are installed below include/CMSIS-DSP to avoid conflicts with other packages, but applications still include CMSIS-DSP headers with #include "arm_math.h" when linking with CMSISDSP::CMSISDSP. Package installation is disabled when CMSISCORE is set, since CMSISCORE is used for Cortex-M builds normally handled by CMSIS Toolbox or Zephyr.

For maximum performance on an Arm host with Neon, build in Release, enable HOST and NEON, and use -O3 -ffast-math:

bash
cmake -S . -B build-cmsisdsp-neon \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/path/to/cmsis-dsp-install \
  -DHOST=ON \
  -DNEON=ON \
  -DCMAKE_C_FLAGS_RELEASE="-O3 -ffast-math"

cmake --build build-cmsisdsp-neon
cmake --install build-cmsisdsp-neon

For Windows or x86 host builds, do not enable NEON. HOST=ON removes the dependency on CMSIS Core intrinsics for host compilers. If float16 support is not needed, DISABLEFLOAT16=ON can avoid compiler support issues.

On Linux or macOS x86:

bash
cmake -S . -B build-cmsisdsp-host \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/path/to/cmsis-dsp-install \
  -DHOST=ON \
  -DDISABLEFLOAT16=ON \
  -DCMAKE_C_FLAGS_RELEASE="-O3 -ffast-math"

cmake --build build-cmsisdsp-host
cmake --install build-cmsisdsp-host

On Windows with Visual Studio:

powershell
cmake -S . -B build-cmsisdsp-host `
  -G "Visual Studio 17 2022" -A x64 `
  -DCMAKE_INSTALL_PREFIX=C:\cmsis-dsp-install `
  -DHOST=ON `
  -DDISABLEFLOAT16=ON `
  -DCMAKE_C_FLAGS_RELEASE="/O2 /fp:fast"

cmake --build build-cmsisdsp-host --config Release
cmake --install build-cmsisdsp-host --config Release

For MSVC, /O2 /fp:fast is the equivalent high-performance setting to -O3 -ffast-math.

An application can then use the installed package with:

cmake
find_package(CMSISDSP CONFIG REQUIRED)
target_link_libraries(my_application PRIVATE CMSISDSP::CMSISDSP)

The package also installs the DSP++ headers. Linking to CMSISDSP::CMSISDSP makes headers such as dsppp/algorithms.hpp available through the same include path. When using add_subdirectory, the target also exposes dsppp/Include from the source tree.

To request a particular version, use, for example, find_package(CMSISDSP 1.18.0 CONFIG REQUIRED). The package accepts requests with the same major and minor version and a patch version no newer than the installed package (SameMinorVersion). Add EXACT to require an exact version.

CMake detects the version from the latest reachable release tag matching v.. using git describe --tags --abbrev=0. Prerelease tags are excluded. This follows the checked-out commit's history, so a tag on an unrelated branch does not change the package version. If Git or suitable tags are unavailable (including source archives and shallow clones without release tags), it uses the release fallback in `cmake/CMSI

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ccortex-acortex-mdspembedded

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言