On 3/30/19 4:06 PM, Bradley Lucier wrote:
On 3/30/19 1:27 PM, Bradley Lucier wrote:
On 3/29/19 11:58 PM, Marc Feeley wrote:
Were you thinking of using glibc for better performance?
Generally, I have tried not to rewrite code from glibc in the Gambit runtime,
After looking at this data, I recommend adding primitives
(flhypot x y) (##flhypot x y)
to _num.scm, adding
FLHYPOT
to gambit.h and changing the compiler to inline flhypot and ##flhypot in the right circumstances.
We could use the existing implementation of ##cabs as the implementation for backends without hypot.
Brad
I ran the simple code at the end of this message, and got the following times:
(time (do ((i 0 (fx+ i 1))) ((fx= i 10000000)) (##cabs arg1) (##cabs arg2))) 0.755936 secs real time 0.755946 secs cpu time (0.755289 user, 0.000657 system) 528 collections accounting for 0.028905 secs real time (0.028845 user, 0.000110 system) 2560000000 bytes allocated 1152 minor faults no major faults (time (do ((i 0 (fx+ i 1))) ((fx= i 10000000)) (hypot arg1-x arg1-y) (hypot arg2-x arg2-y))) 1.173139 secs real time 1.173110 secs cpu time (1.169110 user, 0.004000 system) 190 collections accounting for 0.372126 secs real time (0.372004 user, 0.000017 system) 1556944 bytes allocated 2053 minor faults no major faults
I don't generally use c-lambda, but this seems pretty heavy duty, when the same number C calls to hypot takes roughly 0.167994 seconds.
Brad
(declare (standard-bindings) (extended-bindings) (block) (not safe))
(define hypot (c-lambda (double double) double "hypot"))
(define arg1 (make-rectangular 1.2345678 (fl- 1.2345678 0.1))) (define arg2 (make-rectangular 1.2345678 0.1))
(time (do ((i 0 (fx+ i 1))) ((fx= i 10000000)) (##cabs arg1) (##cabs arg2)))
(define arg1-x (real-part arg1)) (define arg1-y (imag-part arg1)) (define arg2-x (real-part arg2)) (define arg2-y (imag-part arg2))
(time (do ((i 0 (fx+ i 1))) ((fx= i 10000000)) (hypot arg1-x arg1-y) (hypot arg2-x arg2-y) ))