Performance optimization (allocation inside a for loop)
r
nbs.public at gmail.com
Sat Apr 4 06:28:31 CDT 2009
On Sat, Apr 4, 2009 at 7:47 AM, Jaroslav Hajek <highegg at gmail.com> wrote:
>
> I gave the idea a second thought - maybe it has some merits. Sometimes
> you really want to use an array as a stack in Octave to avoid going
> through a loop twice, so Octave can try to optimize such usage.
Thank you for this work. BTW, I've checked that Matlab 2008 doesn't
indeed optimize such scenario. I'm sorry for the unfair judgement.
> Since the existing shallow slicing mechanism is reused, no extra data
> is introduced.
[...]
> a final question: maybe the maximum over-allocation size should be configurable?
If I understand correctly that this optimization doesn't take any
additional memory comparing to the current version, I wouldn't bother
adding more configuration options.
I tried to give it a try but then I encountered an error when building Octave:
make[3]: Entering directory
`/home/r/Installation/octave/hg_20090404/octave/libcruft/misc'
gcc -c -I/usr/include/freetype2 -fPIC -I. -I../.. -I../../liboctave
-I../../src -I../../libcruft/misc -DHAVE_CONFIG_H -mieee-fp -Wall -W
-Wshadow -g -DDP machar.c -o pic/machar.o
machar.c:2:20: error: config.h: No such file or directory
In file included from f77-fcn.h:27,
from machar.c:8:
quit.h:63: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:65: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:73: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:94: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:101: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:103: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:105: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:107: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:111: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:113: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
quit.h:115: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
In file included from machar.c:8:
f77-fcn.h:79: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘extern’
f77-fcn.h:222: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘int’
machar.c:380: error: ‘F77_FUNC’ declared as function returning a function
machar.c: In function ‘F77_FUNC’:
machar.c:380: warning: type of ‘machar’ defaults to ‘int’
machar.c:380: warning: type of ‘MACHAR’ defaults to ‘int’
machar.c:398: error: ‘eps’ undeclared (first use in this function)
machar.c:398: error: (Each undeclared identifier is reported only once
machar.c:398: error: for each function it appears in.)
machar.c:398: error: ‘epsneg’ undeclared (first use in this function)
machar.c:398: error: ‘xmin’ undeclared (first use in this function)
machar.c:398: error: ‘xmax’ undeclared (first use in this function)
machar.c:401: error: ‘log10_ibeta’ undeclared (first use in this function)
machar.c: At top level:
machar.c:380: warning: unused parameter ‘machar’
machar.c:380: warning: unused parameter ‘MACHAR’
make[3]: *** [pic/machar.o] Error 1
I guess, this must be some kind of a configuration problem, but where?
$ hg clone http://www.octave.org/hg/octave
$ patch -p1 << ../stack.diff
$ autoconf
$ configure
$ make
Regards,
-r.
More information about the Help-octave
mailing list