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.

2d array of floats vs 1d array

Some code I was given to integrate used a 2d array of floats in a loop. This ran fine in simulation in CCS, moving it to the hardware upped the execution time of the loop from 400 us to 4000 us.

Changing the code to use a 1d array brought the performance back in line around 600us.

Is there any known reason why 2d array would perform worse in real hardware?

The 2d and 1d code performs the same in simulation.

  • My first guess is simulation does not consider the effect of cache misses.  And, somehow, the 2d implementation incurs more cache misses than the 1d implementation.  If this guess is right, then this is not a compiler issue, and we are not the best people to help you.  System issues like that are best addressed in the device specific forum.  Perhaps the C67x device forum is the best one.

    Thanks and regards,

    -George

  • I resolved the issue as follows:

    1st I changed the function prototype from:

    void myFunc(float (*arr)[4][50])

    to:

    void myFunc(float arr[restrict 4][50])

    As a side note, CCS does not like the restrict keyword, its code analysis highlights this as an error.