Board index » cppbuilder » Compiler switches

Compiler switches


2005-06-27 07:19:58 PM
cppbuilder83
I made a test program that just has 2 'for' loops (one nested inside the
other) and a counter inside the 2 loops to do some time tests. In my case,
in debug mode Borland and Microsoft were about the same time, but in release
mode, Microsoft was 25 time faster (I found virutually no speed improvement
in Borland between release and debug mode). I used the following compiler
switches to try to optimize the time, -ff -O2 -O -Oc -Oi -Ov -OS. I thought
that -Ov should optimize the loops but the time is the same with our without
it. Any help would be appreciated. Thanks, Alex
 
 

Re:Compiler switches

Alex wrote:
Quote
I made a test program that just has 2 'for' loops (one nested inside the
other) and a counter inside the 2 loops to do some time tests. In my case,
in debug mode Borland and Microsoft were about the same time, but in release
mode, Microsoft was 25 time faster (I found virutually no speed improvement
in Borland between release and debug mode). I used the following compiler
switches to try to optimize the time, -ff -O2 -O -Oc -Oi -Ov -OS. I thought
that -Ov should optimize the loops but the time is the same with our without
it. Any help would be appreciated. Thanks, Alex
What gets optimized depends entirely on the code.
Different compilers optimize code differently.
Without seeing your code, it's very difficult to speculate on those
differences.
See my last response to your previouse enquiry, as to my interpretaion
of what MS is doing.
It also has some pointers on what you can do to address your real
concern.
 

Re:Compiler switches

Thanks for your response. I did look at your other response and I do
understand how the code can be optimized. But this is the problem. We have
hundreds of thousands of lines of code that have been written over many
years. Our old product used Microsoft products (compiler, linker, etc). We
went with Borland for the new product because we preferred it for the GUI
development and other reasons. When our same code was compiled in MS, it was
much faster. We know we can optimize the code by hand but the MS compiler
did that for us where we chose not to for readability, exportability,etc.
Many times the most efficient code is not the most maintainable or readable.
I guess my question should be, is there anything we can do, without changing
the code, to make the Borland compiler more efficient. Thanks, I appreciate
your input. Alex
"Bob Gonder" < XXXX@XXXXX.COM >wrote in message
Quote
Alex wrote:

>I made a test program that just has 2 'for' loops (one nested inside the
>other) and a counter inside the 2 loops to do some time tests. In my case,
>in debug mode Borland and Microsoft were about the same time, but in
>release
>mode, Microsoft was 25 time faster (I found virutually no speed
>improvement
>in Borland between release and debug mode). I used the following compiler
>switches to try to optimize the time, -ff -O2 -O -Oc -Oi -Ov -OS. I
>thought
>that -Ov should optimize the loops but the time is the same with our
>without
>it. Any help would be appreciated. Thanks, Alex

What gets optimized depends entirely on the code.
Different compilers optimize code differently.
Without seeing your code, it's very difficult to speculate on those
differences.
See my last response to your previouse enquiry, as to my interpretaion
of what MS is doing.
It also has some pointers on what you can do to address your real
concern.


 

{smallsort}

Re:Compiler switches

Alex wrote:
Quote
Thanks for your response. I did look at your other response and I do
understand how the code can be optimized. But this is the problem. We have
hundreds of thousands of lines of code that have been written over many
years. Our old product used Microsoft products (compiler, linker, etc). We
went with Borland for the new product because we preferred it for the GUI
development and other reasons. When our same code was compiled in MS, it was
much faster. We know we can optimize the code by hand but the MS compiler
did that for us where we chose not to for readability, exportability,etc.
Many times the most efficient code is not the most maintainable or readable.
I guess my question should be, is there anything we can do, without changing
the code, to make the Borland compiler more efficient. Thanks, I appreciate
your input. Alex
You could try to add these options
-k- -vi -6
though I do not think they will do much good. I recommend you to move
all your math stuff to some dll and compile it with MSVC compiler. Take
MS Free VC toolkit and produce dll with it. Export the functions with
stdcall convention and just call the functions from your app.
Here you can get the compiler
msdn.microsoft.com/visualc/vctoolkit2003/
Darko
 

Re:Compiler switches

Alex wrote:
Quote
Thanks for your response. I did look at your other response and I do
understand how the code can be optimized. But this is the problem. We have
hundreds of thousands of lines of code that have been written over many
years.
And a simplistic double-for-loop isn't going to properly test _any_
compiler's optimization of all those different calculations.
If you use loops, make the target a variable, and bring it in from
outside:
typedef double(_stdcall CALCPROC)(void);
double _stdcall Calc_1(void)
{ whole bunch of calculations here
let's not do something simple like last time.
return result;
}
double _stdcall TestCalc( int counter, CALCPROC*Calc )
{ double result;
for( int i=0; i<counter1; ++i )
result = Calc();
return result;
}
starttime = ();
TestCalc( 10000, Calc_1 );
endtime = ();
That should eliminate what appears to be the false optimization in
your prior example. It would also be able to test what would happen if
you placed the calcs in an MS.DLL
The only way to properly figure it out, has been posted in the old
thread: Profile.
Find one or more "slow" calculations, bring it outside, and bang on it
with different settings/compilers/hand-optimizers.
Do this with several different calculations, even a few "fast" ones,
to make sure they don't slow down when you speed up the others.
Quote
Our old product used Microsoft products (compiler, linker, etc).
Not too much wrong with Darko's suggestion either:
Move the calculations that MS does faster, into an MS.DLL, and leave
those that Borland does fast enough, in the main.