Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsps_dotprod_s16_ae32 benchmark on ESP32 (DSP-153) #97

Open
4 tasks done
boborjan2 opened this issue Nov 22, 2024 · 2 comments
Open
4 tasks done

dsps_dotprod_s16_ae32 benchmark on ESP32 (DSP-153) #97

boborjan2 opened this issue Nov 22, 2024 · 2 comments

Comments

@boborjan2
Copy link

Answers checklist.

  • I have read the ESP-DSP documentation and the issue is not addressed there.
  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my ESP-DSP branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

According to this page https://docs.espressif.com/projects/esp-dsp/en/latest/esp32/esp-dsp-benchmarks.html, dsps_dotprod_s16_ae32() for len=256 completes in 447 cpu cycles. That is - I guess - 1 cycle/mac + overhead.
However when I try to measure it using the ccount register, I measure over 950.
First I used xthal_get_ccount() and redid the measurement using inline asm (asm volatile("rsr %0,ccount":"=a" (ccount));) that yielded ~the same.
In my setup, the core that runs the test is empty besides this task. I run 16000 measurements and then evaluate the results.
What am I missing? How can I reproduce the stock results?

Thanks,
Viktor

@github-actions github-actions bot changed the title dsps_dotprod_s16_ae32 benchmark on ESP32 dsps_dotprod_s16_ae32 benchmark on ESP32 (DSP-153) Nov 22, 2024
@boborjan2
Copy link
Author

Hi, the reason for the slow performance is the misalignemnt of input(s). In real-world scenario (e.g. fir filter) it is common that one of the input vectors is only 2byte-aligned (new samples arrive and dotproduct is performed on history buffer). Optimized code expects inputs to be 4byte-aligned. The penalty is quite huge:
4byte-aligned input: ~440cycles @256 taps (as expected according to reference benchmark)
2byte-aligned input: ~1450 cycles! @256 taps.

In my scenario, every second call to dotprod() is with misaligned buffer, so the average yields ~950cycles as measured above.

This might be a good information to highlight in the docs or benchmark page. I have experienced strangely slow performance previously but it was not a showstopper at that time.

@boborjan2
Copy link
Author

boborjan2 commented Nov 26, 2024

Another question regarding dotproduct:
The round value is 0x7fff >> shift. For shift 0, this gives 7ffff. This gets shifted right by 15.
For shift=15, the right round value would be 0x4000. What do I miss?
Also, shift argument specifies a left shift in fact. so should't be the round value (0x4000 << shift)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants