Brent Fulgham wrote:
> ... I have  
> updated the shootout build machine with parrot (0.3.1) and can start  
> running tests if any exist.

A few weeks ago I wrote Brent's "Ackermann" benchmark in Amber for
Parrot. Ackermann is a heavily recursive benchmark.

Brent reports benchmarks for Ack(3, 7), Ack(3, 8) and Ack(3, 9).
Unfortunately I could only get to Ack(3, 6) before parrot aborted with
"maximum recursion depth exceeded", at recursion depth 1000.

The recursion limit of 1000 is assigned in inter_create.c and seems
somewhat arbitrary. Is it likely to be raised in the future?

Regards,
Roger Browne

PS: I have appended the source code in case anyone is interested:


-- Computes the value of Ack(3,n), which is 2^(n+3)-3
-- Specify 'n' on the command line (defaults to 1).

-- As used in the "Computer Language Shootout" benchmarks:
--
http://shootout.alioth.debian.org/sandbox/benchmark.php?test=ackermann
-- See also: http://en.wikipedia.org/wiki/Ackermann_function (Wikipedia)

-- Performance results, 2005-11-22 using Amber 0.3.1, Fedora Core 4
Linux
-- on a 3.2GHz Pentium:
-- Ack(3,0): 5    -- in 0.156s
-- Ack(3,1): 13   -- in 0.156s
-- Ack(3,2): 29   -- in 0.168s
-- Ack(3,3): 61   -- in 0.200s
-- Ack(3,4): 125  -- in 0.348s
-- Ack(3,5): 253  -- in 0.876s
-- Ack(3,6): 509  -- in 3.040s
-- Ack(3,7) and above failed: "maximum recursion depth exceeded"
-- Above times include Amber-to-PIR compilation of about 0.1 second.

args := ARGUMENTS
if args.count = 1 then
   num := args.item(1)  -- Take 'n' from the command line
else
   num := 1             -- or use default of 1 for 'n'.
end

print("Ack(3,")
print(num)
print("): ")
print_line(ack(3, num))

private

   args  -- Command-line arguments

   num  -- : INTEGER  -- Ackermann number

   ack(m, n)  -- m: INTEGER; n: INTEGER; returns INTEGER
      do
         result := if m = 0 then
                      n + 1
                   elseif n = 0 then
                      ack(m - 1, 1)
                   else
                      ack(m - 1, ack(m, (n - 1)))
                   end
      end

end


Reply via email to