esp-dsp
esp-dsp copied to clipboard
Add support for compiling on other architectures (DSP-172)
Is your feature request related to a problem?
Currently the library can used for testing on Linux with x86_64 due to the code at https://github.com/espressif/esp-dsp/blob/3c12d059f96ec95ed00769fb32d41ca23e20cdf1/modules/common/include/dsp_common.h#L86-L88.
Describe the solution you'd like.
However, this could be easily adjusted to support other architectures by using some of the following:
- If the compiler is clang, it always has
__builtin_readcyclecounter()which works on any architecture that supports it (x86, ARM, etc). On x86_64 it is equivalent to__rdtsc(). - Using
PMCCNTRon most ARM architectures (but only under certain circumstances). - Falling back to the vDSO
clock_gettime(CLOCK_MONOTONIC)which is slightly slower than__rdtsc()due to conversion to nanoseconds.
A very complete system is outlined at https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h but that is likely overkill.
Another solution would be to disable all timing codes if necessary.
Describe alternatives you've considered.
I modified the dsp_common.h header myself to use __builtin_readcyclecounter() in my environment and to not include the intrinsics file (which is the real problem on other architectures).
Additional context.
No response