Optimization in MCUXpresso

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Optimization in MCUXpresso

2,295件の閲覧回数
Dhaya
Contributor III

Hi ,

   Here we using LPC55s16 for the project. After completion of 80% memory, tried to optimize the project with optimize most (-O3) and by optimize for size (-Os). After the optimization of the project, while executing the code half of the project get collapsed and not works well as like before. 

    We observed that some global variables, which are works well without optimization and after optimization those variable not get updated in case using in multiple files. But if we use the variable with the declaration of volatile its words well.

   Mainly while optimization, project size get reduced by the 20-25%. So we have reduce the size. What actually happens, while optimization of the project. Kindly resolve this issue.

0 件の賞賛
返信
5 返答(返信)

2,265件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @Dhaya 

This table shows the optimization strategies corresponding to different optimization levels.

Optimization level Strategy Explanation

-O0

No optimization is performed (if no optimization level is specified, it is set by default).
-O1 On the premise of not affecting compilation speed, try to use some optimization algorithms to reduce code size and improve the running speed of executable code.
-This level has executed 45 strategy sub items.
-O2 Sacrifice some compilation speed and adopt optimization algorithms supported by almost all target configurations to improve the running speed of the target code.
-This level adds 48 strategy sub items above all optimization strategy sub items in - O1.
-O3 Adopting many vectorization algorithms to improve the parallel execution level of code, such as utilizing pipelines, cache, etc. in modern CPUs, the goal is to increase the size of the target code rather than desperately improve the running speed.
-This level adds 16 strategy sub items above all optimization strategy sub items in - O2.
-Os There is a similarity between - O3 and - O3, but their goals are different. This level is to minimize the size of the target code, which is very important for devices with small storage capacity.
-This level subtracted 6 strategy sub items from all optimization strategy sub items of - O2, and then enabled the - inline functions strategy.
-Og

Provide reasonable optimization levels while maintaining fast compilation and a good debugging experience.

 

BR

Hang

0 件の賞賛
返信

2,261件の閲覧回数
Dhaya
Contributor III

Hi @Harry_Zhang 

     Thanks for the detailed info. Is any changes in the functionality in the program during different optimizations.

 

Note : This doubt raised because of that volatile and non-volatile  variables functioning differently during non-optimized and optimized projects

0 件の賞賛
返信

2,234件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @Dhaya 

In theory, functionality will not be affected by optimization. As you said, the functionality has been affected due to the possibility of variables in the function being optimized.

BR

Hang

2,173件の閲覧回数
Dhaya
Contributor III
Thanks. During optimization which variable is recommended for global and extern. Is normal or volatile variable
0 件の賞賛
返信

2,170件の閲覧回数
ErichStyger
Specialist I

I think you have a bigger problem, called 'reentrancy'. See https://en.wikipedia.org/wiki/Reentrancy_(computing) or other articles. The concepts around reentrancy are well understood and should be part of any software engineering curriculum.

'Volatile' is intended to tell the compiler that read/write accesses have side effects, e.g. because they are hardware registers. If you have to use 'volatile' as a workaround as it seems here, the problem is that your code is wrong and not reentrant (or not thread-safe or not interrupt-safe).

I hope this helps.