I am trying to optimize this sort of things in a heavy computing application:
say I have a
double d[500][500][500][500];
and the following is quite costly at least from compiler perspective
double d[x][y][j][k]
I want to tell compiler is that it's contiguous memory, to facilitate computing the offset.
In my example,
I have something like this:
double n=0;
for (int i=0; i < someNumber; i++)
{
n+=d[x][i][j][k] /*(some other math calculations)*/;
}
So I tried to optimize it by putting it in a separate function
void func( double*** const restrict dMatrix )
{
/* and do some calculations herel*/
}
didn't help much :(
Any suggestions on optimizing it?
}
Edit
I cannot rewrite the code to make the array one-dimensional. I have to work with this multidimensional beast :(