Hi Doug,

On Tue, 21 May 2024 21:35:33 +0000 (UTC) "T.D. Telford" <d...@dougtelford.com> 
wrote:

> Thanks for the reply.  The elapsed timings for the program rho3rec are:
>
> chicken 5.3.0:  33.6 seconds
> Racket v8.2 [cs]  : 18.1 seconds
> Dr Racket : 20.6 seconds  (10000 MB memory)
>
> The program uses the Pollard rho algorithm to find a factor of 2^257 -1.  The 
> program is highly recursive, but I have a
> non recursive version that has the same timing as the above.  I am using an 
> AMD Ryzen 5600 cpu and 32 GB of main memory.
>
> I tried all of the csc options that appeared related to speed, and the 
> maximum improvement was 0.1 seconds. 
>
> The one option I did not get to work was
>     -heap-size 1000M
> where I varied the size from 1000M to 10000M.  In all cases I would get the 
> run time message
>     [panic] out of memory - heap full - execution terminated
>
> I have include the program listing below and also as an attachment.
>
> Regards,
> Doug
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;#lang racket        ;; uncomment for racket
>
> (define (rho n u v c iter prod)
>   (let* ( [u1 (modulo (+ (* u u) c) n)]
>           [v1 (modulo (+ (* v v) c) n)]
>           [v2 (modulo (+ (* v1 v1) c) n)]
>           [done #f]
>           [max_iter 30000000]
>           [iter2 (+ iter 1)]
>           [prod2 (modulo (* prod (- u1 v2)) n)] )
>
>     (if (= (modulo iter2 150) 0)
>       (begin    ; modulo true
>         (let ( [g (gcd prod2 n) ] )
>           (if (and (> g 1) (< g n))
>             (begin ; factor
>               (display "factor = ") (display g) (newline)
>               (display "iterations = ") (display iter2) (newline)
>               (set! done #t)
>             )
>             (set! prod2 1) ; no factor
>           ) ; end if factor
>         ) ; end let 
>       ) ; end begin for modulo true
>       #f ;action for modulo false
>     ) ; end major if
>
>     (if (and (< iter2 max_iter) (not done)) 
>       (rho n u1 v2 c iter2 prod2)
>       (if done ; either found factor or max iterations
>         (display "normal termination \n")
>         #f
>       ) ; if done
>     ) ; if and 
>   ) ; end let*
> )
>
> (let ( [n (- (expt 2 257) 1)] [u 2] [v 11] [c 7] [iter 1] [prod 1] )
>     (display "factor n = ") (display n) (newline)
>     (time (rho n u v c iter prod))
> )
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Thanks for providing the program.

Would it be ok to add it as a benchmark program to
https://github.com/mario-goulart/chicken-benchmarks?

All the best.
Mario
-- 
http://parenteses.org/mario

Reply via email to