Board index » cppbuilder » Re: Dismaying simple math performance: Answer found

Re: Dismaying simple math performance: Answer found


2004-09-14 10:16:25 PM
cppbuilder28
I just found the answer to the problem, and it is not pleasant.
In Borland C++ 5 you can choose between 'Borland optimizing compiler'
and 'Intel optimizing compiler'. When using the former one, I get
exactly the same execution time for the simple routine pasted below in
executables compiled with either BCB 6 or with Borland C++. However,
when using Intel optimizing compiler, the execution is almost two times
faster. Both BCB 6 and Borland C++ 5 with Borland compiler produce the
same assembler code, but Intel compiler produces different code.
Thus, the problem seems to be intrinsic and unsolvable. With the
(negative) performance hit this big BCB 6 does not appear to be suitable
for scientific calculations with extensive number crunching. I am going
to have a look at Microsoft Visual C++.
Andrew
Summary:
Compiled with: Execution time
BCB 6
dynamically linked 57 sec
disabled RTL and
run time packages 81 sec (1'21'' !!!)
Borland C++ 5
using Borland compiler 57 sec
using Intel compiler 31 sec
Quote
int i, n;
double a, rx, ry, x;
x=0;
for (i=0; i<1000000000; i++)
{
n=i/6.283;
a=i-6.283*n;
rx=a*a; ry=a*n;
x += rx*rx+ry*ry;
}

 
 

Re:Re: Dismaying simple math performance: Answer found

Andrew,
Could you tell me where the Intel option is in C++5 as I cannot find it.
Thanks
Gary
"Andrew Ozarowski" < XXXX@XXXXX.COM >wrote in message
Quote
I just found the answer to the problem, and it is not pleasant.

In Borland C++ 5 you can choose between 'Borland optimizing compiler'
and 'Intel optimizing compiler'. When using the former one, I get
exactly the same execution time for the simple routine pasted below in
executables compiled with either BCB 6 or with Borland C++. However,
when using Intel optimizing compiler, the execution is almost two times
faster. Both BCB 6 and Borland C++ 5 with Borland compiler produce the
same assembler code, but Intel compiler produces different code.
Thus, the problem seems to be intrinsic and unsolvable. With the
(negative) performance hit this big BCB 6 does not appear to be suitable
for scientific calculations with extensive number crunching. I am going
to have a look at Microsoft Visual C++.

Andrew

Summary:

Compiled with: Execution time

BCB 6
dynamically linked 57 sec

disabled RTL and
run time packages 81 sec (1'21'' !!!)

Borland C++ 5
using Borland compiler 57 sec
using Intel compiler 31 sec


>int i, n;
>double a, rx, ry, x;
>x=0;
>for (i=0; i<1000000000; i++)
>{
>n=i/6.283;
>a=i-6.283*n;
>rx=a*a; ry=a*n;
>x += rx*rx+ry*ry;
>}
>

 

Re:Re: Dismaying simple math performance: Answer found

Gary,
Starting from the main menu in Borland C++ 5.0 IDE go to
Options->Project->32 bit Compiler and you will see the options "Borland
optimizing compiler" and "Intel (c) optimizing compiler". Please note
that I am not talking about Borland Builder 5, but rather about Borland
C++ 5.0, designed in 1996, aimed at Windows 95. It used to work very
well for me under Windows 95 and 98. Under XP, the IDE has some
problems, particularly the de{*word*81}, but it is still possible to
compile programs that seem to run faster than those compiled with BCB 6.
Andrew
Gary C wrote:
Quote
Andrew,

Could you tell me where the Intel option is in C++5 as I cannot find it.

Thanks

 

{smallsort}

Re:Re: Dismaying simple math performance: Answer found

Andrew
I am using 5.02 and this option is not there, the copy write date is 1997, I
Borland left this out. I never tested the speed but I always thought that
the code ran faster in 5, so I always make a dll with the code I want to run
fast and use builder for the interface.
Gary
 

Re:Re: Dismaying simple math performance: Answer found

"Andrew Ozarowski" < XXXX@XXXXX.COM >wrote in message
Quote
I just found the answer to the problem, and it is not pleasant.

In Borland C++ 5 you can choose between 'Borland optimizing compiler'
and 'Intel optimizing compiler'. When using the former one, I get
exactly the same execution time for the simple routine pasted below in
executables compiled with either BCB 6 or with Borland C++. However,
when using Intel optimizing compiler, the execution is almost two times
faster. Both BCB 6 and Borland C++ 5 with Borland compiler produce the
same assembler code, but Intel compiler produces different code.
Thus, the problem seems to be intrinsic and unsolvable. With the
(negative) performance hit this big BCB 6 does not appear to be suitable
for scientific calculations with extensive number crunching. I am going
to have a look at Microsoft Visual C++.

Andrew

Summary:

Compiled with: Execution time

BCB 6
dynamically linked 57 sec

disabled RTL and
run time packages 81 sec (1'21'' !!!)

Borland C++ 5
using Borland compiler 57 sec
using Intel compiler 31 sec


>int i, n;
>double a, rx, ry, x;
>x=0;
>for (i=0; i<1000000000; i++)
>{
>n=i/6.283;
>a=i-6.283*n;
>rx=a*a; ry=a*n;
>x += rx*rx+ry*ry;
>}
>

Hmm..did you try by any chance to put the loop variable in CPU register when
compiling with BCB6 ?
int n;
double a, rx, ry, x;
x=0;
for (register int i=0; i<1000000000; i++)
{
n=i/6.283;
a=i-6.283*n;
rx=a*a; ry=a*n;
x += rx*rx+ry*ry;
}
Try this and share the results with us.