espressif / esp-dsp

DSP library for ESP-IDF
Apache License 2.0
465 stars 87 forks source link

Zero overhead loops in esp-dsp #36

Closed boborjan2 closed 2 years ago

boborjan2 commented 2 years ago

Problem Description

This part of esp-idf suggests that there is a sporadic? (or just rare?) issue with zero overhead loops: https://github.com/espressif/esp-idf/blob/master/components/xtensa/esp32/include/xtensa/config/core.h#L1405 That's why it's usage is turned off in gcc.

Now esp-dsp does use these loops (seemingly without issues). Can you provide us with some details in the topic? I found no further info on this erratum 572.

Thanks Viktor

igrr commented 2 years ago

Hi @boborjan2, in ESP-IDF the zero-overhead loops are enabled, it is just the zero-overhead loop buffer is disabled.

The erratum itself says that supposedly in some cases the CPU may get an invalid instruction word from the zero-overhead loop buffer. Since we have disabled the buffer, the code can use zero-overhead loop instructions without any restrictions. Disabling the zero-overhead loop buffer has no effect on the ESP32 (or ESP32-S3) in terms of performance.