Best possible code optimization for speed

doglike
Posts: 63
Joined: Fri Aug 18, 2017 4:21 pm

Best possible code optimization for speed

Postby doglike » Fri Aug 07, 2020 2:19 pm

Hi,

I am running a quite complex math. interpolation routine within a cyclic 1ms Freertos task.
I want to run that piece of code as fast as it is possible, because of the high-frequent 1ms calls
What I did until now is to put the ipol_routine() to IRAM.
Are there any other suggestions or possibilities to speed it up?
(No, I cannot write assembler :D)
Thanks!

Code: Select all

xTaskCreatePinnedToCore (tasks_1ms,  "tasks_1ms", 4096, NULL, 2,  NULL, 1);

void IRAM_ATTR ipol_routine(void);

void Tasks_1ms(void *arg)
{
  while (1)
  {
     delay(1);
     ipol_routine();
  }
}	

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: Best possible code optimization for speed

Postby ESP_Sprite » Sat Aug 08, 2020 1:05 pm

...Why have a delay when you want to run a task as fast as possible? What's the thing you're trying to achieve here?

doglike
Posts: 63
Joined: Fri Aug 18, 2017 4:21 pm

Re: Best possible code optimization for speed

Postby doglike » Mon Aug 10, 2020 12:56 pm

Hi,
Task_1ms() is running with highest prio and there are also some other tasks on that core.
So with the delay I free up cpu recource for the other tasks.
I want speed up the calc time of Task_1ms(), so that the other tasks have as much cpu time as possible within this 1ms steps.

The ipol_routine() code is optimized as good as possible.

In this thread is want to know, if there are more options like IRAM_ATTR to optimize compiler & CO

Thanks

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Best possible code optimization for speed

Postby ESP_igrr » Mon Aug 10, 2020 3:47 pm

Aside from placing the code into IRAM and enabling -O2 optimization level in sdkconfig (CONFIG_COMPILER_OPTIMIZATION_PERF option), there is probably not much more you can do for generic code. You may also check https://github.com/espressif/esp-dsp in case it implements some of the mathematical functions you need.

doglike
Posts: 63
Joined: Fri Aug 18, 2017 4:21 pm

Re: Best possible code optimization for speed

Postby doglike » Tue Aug 11, 2020 8:05 am

O2 optimization level is also set. Then I've done almost everything that is possible... :)
Thanks!

Who is online

Users browsing this forum: Google Adsense [Bot] and 146 guests