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.

Compiler: Will clock cycles change based on function arguments count?

Tool/software: TI C/C++ Compiler

Hi,

In Kernel-C programming, is there any effect in clock cycles if we increase the function arguments?

For example,

func(int, int, int, int) -> executed in x cycles

func(int, int, int, int, int, int) -> will this be executed in x or x+y or x-y cycles?

There is no change in the function body.

Thanks,

Vasanth

  • Vasantha,

    With the Thanksgiving holidays this week it will be Monday before an expert can give you a proper reply on this.

    Regards,
    John
  • vasantha kumar raju angappan said:
    is there any effect in clock cycles if we increase the function arguments?

    The short answer is: Yes, but not much.

    I presume you execute on a C6000 core CPU.  But, if you execute on an ARM core CPU, the answer is nearly the same.

    Separate the issue into two pieces.  How does the cycle count change at the point where the function is called?  How does the cycle count change in the called function?  

    Where the function is called ... Expect a small increase in cycles because two more argument values are computed (probably loaded) into registers.  If the register allocation works out well, and the values are the right registers anyway, it might even be free.  

    In the called function ...  Because of ...

    vasantha kumar raju angappan said:
    There is no change in the function body.

    ... expect no change in the cycle count.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for the reply. We execute the Kernel-C code in EVE processor.

    1. The extra variables are not a calculation like x*y. They are numbers.

    2. There is no change in the function body.

    We tried to optimise the code in Kernel-C. There are some calculations in Kernel-C program of known values as image_width * image_height.
    Since those values are not changed in the Kernel-C code, we try to pass this data as a single value as an extra argument.

    We thought 'we reduced a multiplication operation inside the code. So the clock cycles count should be reduced.'
    But surprisingly, it got increased.

    One more point: Optimization level of CCS is OFF.

    Thanks,
    Vasanth
  • vasantha kumar raju angappan said:
    1. The extra variables are not a calculation like x*y. They are numbers.

    Then you should just see the instructions which load those constants into memory locations on the local stack frame.  That should only be a few cycles.

    vasantha kumar raju angappan said:
    One more point: Optimization level of CCS is OFF.

    We are not concerned about the performance of code built with no optimization.  It is all but certain that using optimization will solve your problem.

    Thanks and regards,

    -George

  • HI George,

    Ok, I didn't check the clock cycles under optimization.
    I will execute 'less arguments + O3 optimization' and 'more arguments + O3 optimization'.
    And will find any changes in clock cycles.

    Thank You.
    Vasanth