POV-Ray : Newsgroups : povray.off-topic : compiling huge C++ files : compiling huge C++ files Server Time
6 Sep 2024 19:18:05 EDT (-0400)
  compiling huge C++ files  
From: Kevin Wampler
Date: 3 Nov 2008 16:15:51
Message: <490f6a07$1@news.povray.org>
I'm attempting to compile some auto-generated code, and am running into 
problems with turning on optimization flags due to the large side of the 
files generated (.cpp file is currently 25MB, and could be as large as 
200MB later).  There is no natural way to break this code into smaller 
pieces and such large auto-generated files really are necessary, so I'm 
stuck with having to compile some really huge C++ files.

I'm using g++ for the compilation, and it seems that if I turn on 
optimization flags (even -O1) it will quickly eat through all 16 GB of 
ram when I attempt to compile it.

Since I'd like to have the resulting executable run as quickly as 
possible I am wonder if anyone has advice on either or all of the 
following options:

1) Is there any way to specify for g++ to only to use optimizations 
which do not require a significant amount of storage to compute?

2) Is there another compiler that works under linux (fedora 9) that 
might handle this better?  I should be able to find a version of the 
Intel compiler to use if someone has reason to think it'll perform better.

3) Can I change the format of the source code so that using g++ 
optimizations isn't as necessary?  Most of the execution time is spent 
in my auto-generated code, which looks something like this:

	...
	double t75 = t73 - t74;
	double t76 = t66 - t67;
	double t77 = t74 + t73;
	double t78 = t55 * t51;
	double t79 = t78 + t58;
	double t80 = t64 * -0.2;
	....

Only for hundreds of thousands of lines with the occasional division, 
sqrt, trigonometric function, etc thrown in.  Since I write the code 
generation functions, I can do some optimizations at the source-code level.

For example of such an optimization, I could implement a variable 
allocation optimizer that would, for instance, determine that t74 isn't 
used after the third line above, and then re-use that stack space to 
store the value in t77 instead of allocating a new double for it.

The problem is that I don't know what (if any) of this sort of thing g++ 
does already if I don't specify any optimization flags, or what 
source-level optimizations are likely to make the biggest improvement. 
Any suggestions?


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.