J
Jim West
The execution speed of the following code is dramatically faster if I
declare some arrays globally rather than locally. That is
FOO a[10], b[10], c[10];
void bar() {
...
}
runs much faster (up to 33%) than
void bar() {
FOO a[10], b[10], c[10];
...
}
There is considerable work being performed in the ... section.
This is on a Linux Itanium II system, compiled both with the Intel C++
compiler (V9.1) with interprocedural optimization enabled, and with the
GNU C V 3.3.5 compiler with -O3 optimization. (The performance change is
more dramatic with the Intel Compiler.) I tried declaring the local
FOO arrays static with
static FOO a[10], b[10], c[10];
which helped with the GNU compiler but was actually worse with the Intel
compiler. I also tried
FOO d[30];
FOO *a = d, *b = d+10, *c = d+20;
with a local d array, but that had no effect.
Is this just a compiler issue, or am I missing something? I want to avoid
the external arrays, obviously, but that code compiled by the Intel
compiler gives the fastest execution speed by far. I'd like to get the
equivalent performance with something less dangerous than global arrays.
declare some arrays globally rather than locally. That is
FOO a[10], b[10], c[10];
void bar() {
...
}
runs much faster (up to 33%) than
void bar() {
FOO a[10], b[10], c[10];
...
}
There is considerable work being performed in the ... section.
This is on a Linux Itanium II system, compiled both with the Intel C++
compiler (V9.1) with interprocedural optimization enabled, and with the
GNU C V 3.3.5 compiler with -O3 optimization. (The performance change is
more dramatic with the Intel Compiler.) I tried declaring the local
FOO arrays static with
static FOO a[10], b[10], c[10];
which helped with the GNU compiler but was actually worse with the Intel
compiler. I also tried
FOO d[30];
FOO *a = d, *b = d+10, *c = d+20;
with a local d array, but that had no effect.
Is this just a compiler issue, or am I missing something? I want to avoid
the external arrays, obviously, but that code compiled by the Intel
compiler gives the fastest execution speed by far. I'd like to get the
equivalent performance with something less dangerous than global arrays.