Hi all,
I have some complex vector and matrix operations that I need to optimize, when I did measuring of cycles it is consumed when the code is implemented as a function, it takes four times when running this code in the main function!. I don't think saving the stack and restoring it when the function is called makes this difference. Can some one explain, why this happens?. Here is the code:
main()
{
....
for (int i = 0; i < 40; i++)
for (int j = 0; j < 40; j++)
{
r[i * 40 + j].re = ( ((_int64) (x[i].re)) * coeff[j].re - (( _int64 ) (x[i].im)) * coeff[j].im) >> 29;
r[i * 40 + j].im = ( ((_int64) (x[i].re)) * coeff[j].im + (( _int64 ) (x[i].im)) * coeff[j].re) >> 29;
}
...
}
When it is a function:
void mult_vect_vectt(t_vect a, t_vect b, t_matr r)
{
int index=0;
for (int y = 0; y < 40; y++)
for (int x = 0; x < 40; x++)
{
r[y * 40 + x].re = ( ((_int64) (a[y].re)) * b[x].re - (( _int64 ) (a[y].im)) * b[x].im) >>29;
r[y * 40 + x].im = ( ((_int64) (a[y].re)) * b[x].im + (( _int64 ) (a[y].im)) * b[x].re) >>29;
}
}
Thanks,
Sarah