Hello! Welcome to Embedic!
This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > Embedded Events > Practical Tips for MCU Software Benchmarking: Guidelines for Compiler Optimization Capability Reviews

Practical Tips for MCU Software Benchmarking: Guidelines for Compiler Optimization Capability Reviews

Date: 16-12-2021 ClickCount: 642

In MCU development and application, engineers need to test the capability of MCU, and the common practice is to use Benchmark program to test. However, when benchmarking, the compiler's optimization capability also has a significant impact on the test results. The same hardware platform with different compilers and different optimization options may yield significantly different results.

In order to maximize the performance of the MCU and achieve the best results in benchmark tests, engineers need to understand not only their own hardware, but also the optimization principles of the compiler and apply them flexibly in order to bring out the full performance of the MCU in benchmark tests. IAR's compilers are often able to produce good benchmarking results for MCUs.

This article takes the IAR Embedded Workbench development tool suite, which has been widely used in the MCU field, as an example to share the items and the following tips that should be noted for MCU software benchmarking to help readers generate the most efficient and complete code in the industry. With the following items and settings, engineers can precisely adjust optimization levels to maximize testing and performance of the developed and applied code.

maximize testing

Choose code size or execution speed

With development tool suites such as IAR Embedded Workbench, engineers can set optimization levels and types for the entire project scope or for individual files. This can even be done in the source code using the #pragma optimize command for individual functions.

The goal of optimization is to reduce code size and increase execution speed. If only one of these goals can be met, the compiler will prioritize based on the settings specified by the user. Therefore, in real-world software benchmarking, engineers can try various settings to get the best results. For example, since function inlining is more focused on execution speed optimization, using function inlining with generic code execution speed optimization settings will result in smaller program code compared to using generic code size optimization settings.

generic code size optimization

Choosing a small memory model

In order to fully exploit the performance of MCU devices and reduce problems in applications, software development must take into account the memory and other resource constraints of MCU devices, so it is necessary to choose the smallest possible memory model for the target device and project. The advantages of a small memory model include.

  • -Smaller size addresses
  • -Smaller instruction size
  • -Smaller pointer size
  • -More efficient
  • -Less code

Sophisticated development tool suites such as IAR Embedded Workbench also have integrated evaluation capabilities that can evaluate multiple aspects of the memory model, helping engineers to size and optimize their software designs.

Choosing the Right Runtime Library

By default, runtime libraries are compiled with the highest code size optimization level. If you want to optimize for speed, consider recompiling to generate these libraries. Configuration options are available to set the most appropriate level for certain standard library features such as language environment, file descriptors, and multi-byte.

features

features

Select the format of scanf input and printf in the library options, depending on the specific requirements. The default option is not the minimum format.

Use the right data type

Data types are closely related to code size or execution speed, so you need to use development tools to observe and analyze data types in order to find the right type for your hardware resources. In the IAR Embedded Workbench development tool suite, developers can start testing and optimizing in the following ways.

  • -Select the most suitable data type size for your application
  • -Use unsigned character types as much as possible, so that bit operations can be performed instead of arithmetic operations  

operations

Check target-specific options

  • -Efficient addressing modes - Enables efficient memory access
  • -Use of specific registers for constants/variables - code can be manipulated more efficiently in registers than in memory
  • -Even-aligned function entries -Even-aligned instructions can increase speed
  • -Byte-aligned objects - smaller storage requirements, but may generate larger code sizes

Use benchmarking related code

All MCU development tools should provide benchmarking-related code, but the code base of established general-purpose development tools is a distillation of these providers' experience in the relevant areas and is therefore more comprehensive and efficient. Some of the key lessons learned include.

  • -Benchmarking of embedded systems should be designed for the characteristics of embedded programs.
  • -Actual applications are often suitable for benchmarking as well, but need to ensure that the code is executable. Linkers will remove unreferenced code and variables, but not all linkers have this capability.
  • -Ensure that the test code is not affected by the test tool (test-related functions). The following example actually benchmarks printf() (the test-related function).
  • Compare the generated code after linking. One compiler may use inline code, while another may call libraries.
  • -Fully understand the application code used to perform the benchmark!

Summary

By using a proven suite of development tools such as IAR Embedded Workbench and leveraging the knowledge gathered and iterated over decades of global applications, MCU design and application development engineers can quickly complete these essential performance tests and further target the performance of the MCU to achieve optimized, hardware-software integration of the target device.

  • When MCU goes to high performance, MCU or MPU no longer need to tangle
  • Silicon Labs' Z-Wave 800 SoC and Module Family Available Now

Hot Products

  • TMS320C6472EZTZ7

    Manufacturer: Texas Instruments

    IC DSP FIXED-POINT 737FCBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320C6743BZKB3

    Manufacturer: Texas Instruments

    IC DSP FIXED/FLOATING PNT 256BGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320DM335CZCE135

    Manufacturer: Texas Instruments

    IC DIGITAL MEDIA SOC 337-NFBGA

    Product Categories: SOC

    Lifecycle:

    RoHS:

  • ADSP21262SKBCZ200R

    Manufacturer: Analog Devices

    IC DSP CTLR 32BIT 136CSBGA

    Product Categories: 32bit DSP

    Lifecycle:

    RoHS:

Customer Comments

  • Looking forward to your comment

  • Comment

    Verification Code * 

Compare products

Compare Empty