DSP Performance: PlatformIO Build 6X Slower vs. Arduino IDE Build

Question/Issue:
Using the Edge Impulse example for keyword detection, I see a very large performance difference between a PlatformIO build and the same code built using the Arduino IDE.

For the Arduino Nano 33 BLE, the DSP processing block is almost 6X slower when the application is built using PlatformIO versus the Arduino IDE. However, for an ESP32 DevKitC (env:esp-wrover-kit) target, the two builds are comparable in performance. Here is a summary of the DSP times:

PlatformIO
Arduino Nano 33 BLE: DSP 857 ms, inference 8 ms, anomaly 0 ms
ESP32 DevKitC: DSP 298 ms, inference 5 ms, anomaly 0 ms

Arduino IDE
Arduino Nano 33 BLE: DSP 128 ms, inference 6 ms, anomaly 0 ms
ESP32 DevKitC: DSP 285 ms, inference 3 ms, anomaly 0 ms

Project ID:
542383

Context/Use case:
The application code is the same. It classifies a static frame of audio data. I chose the Arduino library deployment option in Edge Impulse. The resulting source is then added as a library to my build.

Any ideas why the performance is much faster with the Arduino IDE build? Again, it’s just for the Arduino Nano 33 BLE target. The ESP32 builds are roughly the same.

I run PlatformIO and the Arduino IDE in an Ubuntu WSL instance.

Steps Taken:

I have done verbose builds on each platform to compare the compiler options and defines but I don’t see anything obvious, but I am new to this domain. :slightly_smiling_face: Please see the links below for the build logs and complete compiler command lines for a sample DSP file for each IDE.

I have reviewed the Slow DSP Operations

It looks like both the Arduino IDE and PlatformIO use the same version of mbed (6.17.0) per mbed_version.h.

Adding the defines to my source per the article did not make a difference in the DSP processing times. PlatformIO is still significantly slower (~850ms vs 130ms).

#define EIDSP_USE_CMSIS_DSP 1
#define EIDSP_LOAD_CMSIS_DSP_SOURCES 1

Environment:

  • Platform: [Arduino Nano 33 BLE]

  • Arduino IDE Environment Details:
    Arduino IDE
    Version: 2.3.4
    Date: 2024-12-03T10:51:12.539Z
    CLI Version: 1.1.1

  • PlatformIO Environment Details:
    Core: 6.1.16

I run PlatformIO and the Arduino IDE in an Ubuntu WSL instance.

  • Edge Impulse Version

#define EI_STUDIO_VERSION_MAJOR 1
#define EI_STUDIO_VERSION_MINOR 65
#define EI_STUDIO_VERSION_PATCH 3

  • Project Version:
    542383

I also opened an issue on the PlatformIO community forum:
Edge Impulse DSP Block (Arduino Nano 33 BLE): Arduino IDE Build 6X Faster

Thanks in advance for your help.

As a new forum user I was limited to 2 links in my post. So, here is more information about my issue.

Logs/Attachments:

Full Arduino IDE Build Log
Full PlatformIO Build Log

Here is an example of the command line for kiss_fft.cpp, one of the Edge Impulse DSP library files. In the Arduino log, it also includes the expansion of defines.txt and cxxflags.txt.

Example DSP File

Arduino Command Line
PlatformIO Command Line

From those profiling numbers CMSIS-DSP and CMSIS-NN seem not to be loaded on PlatformIO (kissfft should f.e. not be loaded in favor of the CMSIS-DSP RFFT functions). You can set

-DEIDSP_USE_CMSIS_DSP=1
-DEIDSP_LOAD_CMSIS_DSP_SOURCES=1
-DEI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=1

To enable those manually.

I added the EI defines to my platform.ini and rebuilt but there is no difference. The DSP processing time is the same.

Here is my PlatformIO configuration:

[platformio]
default_envs = nano33ble

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
lib_deps =
SNMArduino
build_flags =
-DEIDSP_USE_CMSIS_DSP=1
-DEIDSP_LOAD_CMSIS_DSP_SOURCES=1
-DEI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=1

You mentioned CMSIS-DSP RFFT. In the build log I see the compilation of files such as

edge-impulse-sdk/CMSIS/DSP/Source/TransformFunctions/arm_rfft_f32.c

but it looks like the kiss_fft.cpp source is still being compiled as it is still in the build log.

edge-impulse-sdk/dsp/kissfft/kiss_fft.cpp

What is the correct way to post a link to a large file such as the build log? I see an error about “cannot post to that host”. The link is a link to a read-only file in a OneDrive folder. My previous links to files in the same folder did go through.

Thank you very much for your help!

As Max identified in the PlatformIO forum, the issue does seem to be that both

-mfloat-abi=soft
-mfloat-abi=softfp

are set in the PlatformIO build which is a conflict. Adding this line to the platform.ini resolves the issue.

build_unflags = -mfloat-abi=soft

Now the DSP processing step is comparable between the PlatformIO and Arduino CLI builds.

1 Like