cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rhc110again
Contributor
Contributor
388 Views
Registered: ‎08-18-2017

Compiler optimization for custom application

My Question:  Is there a way to turn on any compiler optimizations when building a custom PetaLinux application?

Background:  We are running PetaLinux 2018.2 on a ZCU102 board, and are trying to benchmark performance of a core performing some simple mathematical operations (see code snippet below, which gets run a few thousand times with a check of the RTC before and after).  I've created four custom applications (following template examples in UG1144) to test some different configurations:

  1. Custom c++ project (compiled in Linux), using floating-point math
  2. Custom c++ project (compiled in Linux), using integer math
  3. Pre-built SDK project, using floating-point math
  4. Pre-built SDK project, using integer math

Results of note are:

  • We see about a 30% increase in efficiency performing integer math operations over floating-point math.
  • There's no increase in floating-point efficiency from Linux-compiled to SDK-compiled applications.
  • There's a very small increase in integer math efficiency from Linux-compiled to SDK-compiled applications.
  • Adding a -O2 switch to the makefile for the custom c++ projects seems to make no difference at all in our benchmark test.

For the SDK projects, the Build Configuration is set to Release, and the C/C++ Build Settings | compiler Optimization is set to -O3 (Optimize most).

So, to summarize, are we already at the maximum optimization for both Linux and SDK compilation?  Or is there something else I can try in one toolset, or both?

 

//-------------------------------------------------------------------------------------------------
/// @brief Regular version of FIR filter.
/// @param data - data samples history; size: size
/// @param filter - filter coefficients; size: size
/// @param size - number of elements in data and filter
/// @return the sum of the product of each element
template <typename T>
T Fir(const T* RESTRICT data, const T* RESTRICT filter, const UInt32 size)
{
    T ret = T(0);
    for (UInt32 i = 0; i < size; ++i) ret += data[i] * filter[i];
    return ret;
} // end Fir

 

0 Kudos
0 Replies