Built-in "filter" function works drastically faster in Matlab than in generated C code

3 Ansichten (letzte 30 Tage)
Hello everyone.
I have an algorithm using "filter" function. We are testing generated to C version of it and the main bottleneck (around 50% of whole time) spent is C code related to processing of this "filter" call, and function inside which this call located take like 66%. But profile of this function in Matlab tells completely different story, even line in which "filter" called is not the most time consuming inside function calling it but like top 3. And function calling "filter" is just like top 10 in profiling only (like 4-5% instead of 66%). Unfortunately "filter" is built-in function of Matlab so I can't profile it "more" in Matlab to really understand the issue. What can cause such behavior?
I was trying to run matlab in single-thread mode and played with optimizations for code generation and compiler flags but it doesn't change overall picture of "bottleneck".

Antworten (1)

Jan
Jan am 24 Sep. 2021
Bearbeitet: Jan am 24 Sep. 2021
That filter becomes the bottleneck can have two reasons:
  1. filter is processed less efficiently in the generated C code.
  2. The efficiency of filter does not change, but the rest of the code is processed much faster.
  2 Kommentare
Jakub Jon
Jakub Jon am 24 Sep. 2021
I am curious, if it is possible to get fast implementation of filter in C instead of what Matlab generates normally.
Jan
Jan am 26 Sep. 2021
You find a slightly faster C implementation of FILTER here: https://www.mathworks.com/matlabcentral/fileexchange/32261-filterm . Currently Matlab is still faster if multithreading is used.
I've improved the code to consider cheaper computations of FIR filters. The multi-threading is not working yet, so it will take some time until I publish it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by