I have some test programs under the CCS3.3 and DSPC6713B and find that the time consumption is significantly different for the "for " loops.
The first test program is as follows:
#define NUM 128
float dis[NUM];
#pragma MUST_ITERATE(10,,)
for(i = 0; i < NUM; i++)
dis[i] = dis[i] + val1 * val2;
The second program is like:
typdef struct tag_OBJ
{
float *dis;
}OBJ;
typdef struct tag_PARAM
{
int num;
}PARAM;
OBJ obj;
PARAM param;
param.num = NUM;
obj.dis = (float *)malloc(sizeof(float) * param.num);
#pragma MUST_ITERATE(10,,)
for(i = 0; i < param.num; i++)
obj.dis[i] = obj.dis[i] + val1 * val2;
The complie options for both cases is set to:-o3, -pm
It is surprised that time consumption for the first case is about 2-cycle for every loop and 20-cycle for each iteration for the second case?
What causes the dramatic difference on time consuption for these two cases?