Hello!
The GPC run time library contains a function `_p_sin' which does nothing else than to call the `sin' function from the C library.
As a try, I told GPC to forget about `_p_sin' and to call `sin' directly. Here are the results for a test program (compiled with -O3 on Linux):
Calling `_p_sin':
9.93user 0.01system 0:10.11elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (72major+14minor)pagefaults 0swaps
Calling `sin' directly:
9.11user 0.01system 0:09.12elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (72major+14minor)pagefaults 0swaps
This means a gain of speed of about 9%.
If there is no special reason for having an extra `_p_sin' I would vote for dropping it in favour of calling `sin' directly, and similar for other mathematical functions.
Comments?
Yours,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]
HI everyone, I agree Forget about the p_sin func, but make anlias, ie #define p_sin(x) sin(x) -Neal
--------------------------------------------------- Neal Walfield - Brin@star.net Contentio Litterae v1.00 - Out August 97 USA: http://www.geocities.com/Eureka/Park/5319 England: http://www.fortunecity.com/skyscrapper/Millenit/76
On Sat, 9 Aug 1997, Peter Gerwinski wrote:
Hello!
The GPC run time library contains a function `_p_sin' which does nothing else than to call the `sin' function from the C library.
As a try, I told GPC to forget about `_p_sin' and to call `sin' directly. Here are the results for a test program (compiled with -O3 on Linux):
Calling `_p_sin':
9.93user 0.01system 0:10.11elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (72major+14minor)pagefaults 0swaps
Calling `sin' directly:
9.11user 0.01system 0:09.12elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (72major+14minor)pagefaults 0swaps
This means a gain of speed of about 9%.
If there is no special reason for having an extra `_p_sin' I would vote for dropping it in favour of calling `sin' directly, and similar for other mathematical functions.
Comments?
Yours,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]
On Sat, 9 Aug 1997, Peter Gerwinski wrote:
Hello!
The GPC run time library contains a function `_p_sin' which does nothing else than to call the `sin' function from the C library.
[..]
This means a gain of speed of about 9%.
If there is no special reason for having an extra `_p_sin' I would vote for dropping it in favour of calling `sin' directly, and similar for other mathematical functions.
Comments?
`sin()' is not doing any checking, so you could replace it right away. But there are other functions that do some checking before calling the underlying OS function (like `ln')
GCC knows an optimzation switch -ffast-math, described as:
This option allows GCC to violate some ANSI or IEEE rules/specifications in the interest of optimizing code for speed. For example, it allows the compil- er to assume arguments to the sqrt function are non-negative numbers.
This option should never be turned on by any `-O' option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ANSI rules/specifications for math func- tions.
This option is not enabled by any of the -Ox optimization switches, probably because it may violate some spec.
How about adding either a simular switch to GPC, or add extra GPC functionality to -ffast-math to emit a direct _sin() and friends instead of _p_sin() when this switch is on? That way, both the speed freaks and the checking lovers are satisfied.
JanJaap --- With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC1925.