Rate This Document
Findability
Accuracy
Completeness
Readability

Optimizing Compilation Options to Improve Program Performance

Principles

During C/C++ code compilation, the GCC compiler translates source code into an instruction sequence that can be identified by the CPU and writes the instruction sequence into the binary file of an executable program. When executing an instruction, the CPU usually executes the instruction in a pipeline manner, to improve performance. Therefore, orchestration of an instruction execution sequence greatly affects pipeline execution efficiency. Generally, factors such as a quantity of hardware resources for instruction computing, execution periods of different instructions, and data dependency between instructions need to be considered in an instruction pipeline. We can obtain better instruction sequence orchestration by notifying the compiler and the target platform (CPU) instruction set and pipeline where the program runs. GCC 9.1.0 supports the Armv8 instruction set and tsv110 pipeline that are compatible with Kunpeng processors.

Modification Method

  • To use the GCC compiler in Euler, add the following compilation options to CFLAGS and CPPFLAGS:
    1
    -mtune=tsv110 -march=armv8-a
    
  • In other operating systems, you can upgrade the GCC version to 9.1.0 and add compilation options to CFLAGS and CPPFLAGS.
    1
    -mtune=tsv110 -march=armv8-a