This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/OMAP-L138: Loop disqualification due to std::exp call

Part Number: OMAP-L138
Other Parts Discussed in Thread: MATHLIB

Tool/software: Code Composer Studio

As I understand it software pipe-lining is critical to high performing loops.  If I have a simple loop that computes the std::expf(float) of an array of floats I am met with advice from the advisor:

advice #30000: Loop at line 10 cannot be scheduled efficiently,
as it contains a function call ("expf").
Try to inline call or consider rewriting loop.

...how can standard library calls, such as std::exp, be inlined?

Some research pointed me toward possibly using Mathlib, but the documentation on how to link and use it with Code Composer plus use the inline version is very lacking.

  • The function expf is, from a practical viewpoint, too big to inline.  Unfortunately, that means this loop cannot be software pipelined.

    Thanks and regards,

    -George

  • Hi!

    There is a very simple rule: function call makes no pipelining, except inlined function. As you use standard library, that means no inlining, and yes, no pipelining. Thus optimized libraries, like mathlib are option of choice in such a case, unless you willing to implement you own optimized solution.

    As to integration process, you'll have to get used to it anyway, as other products, e.g. dsplib, intergates same way. That consists of few basic steps:

    1. Install mathlib product if not done so before.
    2. In project properties, General, Products tick desired mathlib version.
    3. In project properties, linker, file search path, Include library file - add there mathlib.(proper extension), which you may find somewhere in TI\mathlib_c67x_version\lib\
    4. Just below in 'Add lib search sir' add location of the folder mentioned above. You may want to use variable ${TI_MATHLIB_C67X_INSTALL_DIR}
    5. Locate TI\mathlib_c67x_vaersion\packages\ti\mathlib\src\expsp\expsp_d.c for demonstration, how to use expsp() function.

    Note, through TI libraries they provide those *_d.c files with demos. In those demos you'll find straightforward C implementation, implementation with processor intrinsics (*_i) and optimized version. Include latter in you code, like

    for ( i = 0; ... )
        y[i] = expsp( x[i] );

    That's it.

  • Of course, you'll have to add appropriate include and add include search path.

    And if you job is just to get vector of exponents on vector argument, you may want to see expsp_v( float *  a,   float *  output,   int  size ) . This would save overhead of repeated function call. That might quite efficient comparing to inlined function, as loop inside vectored function may pipeline.

    Finally, depending on your inputs range and precision required one may implement their own fast approximation, because multiplication is cheap on DSP.