/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® quad-core |
Each table row shows performance measurements for this ATS program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 10 | 0.33 | 0.33 | 284 | 1571 | 0% 0% 9% 100% |
| 11 | 4.11 | 4.12 | 288 | 1571 | 0% 0% 100% 0% |
| 12 | 57.80 | 57.82 | 288 | 1571 | 0% 1% 100% 0% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read fannkuch-redux benchmark to see what this program should do.
ATS/Anairiats version 0.2.8
(* ** The Computer Language Benchmarks Game ** http://benchmarksgame.alioth.debian.org/ ** ** based on code by Hongwei Xi, Miroslav Rubanets, and Oleg Mazurov ** contributed by Julian Beaumont ** ** compilation command: ** atscc -fomit-frame-pointer -O3 fannkuchredux.dats -o fannkuchredux *) (* ****** ****** *) staload _ = "prelude/DATS/pointer.dats" (* ****** ****** *) %{^ // // HX: this is the best choice on my machine // typedef ats_uint_type ats_ussi_type ; %} abst@ype ussiLt (n: int) = $extype "ats_ussi_type" extern castfn ussiLt_of {n : nat | n <= 256} (x : sizeLt n) :<> ussiLt n extern castfn sizeLt_of {n : nat | n <= 256} (x : ussiLt n) :<> sizeLt n (* ****** ****** *) viewtypedef iarray (n : int, l : addr) = [0 < n && n <= 256] @( array_v (ussiLt n, n, l) | ptr l ) fn array_get {n : nat} {l : addr} {i : nat | i < n} (xs : ! iarray (n, l), i : size_t i) :<> sizeLt n = let prval pf = xs.0 val p = xs.1 val result = p->[i] prval () = xs.0 := pf in sizeLt_of {n} (result) end fn array_set {n : nat} {l : addr} {i : nat | i < n} (xs : ! iarray (n, l), i : size_t i, x : sizeLt n) :<> void = let prval pf = xs.0 val p = xs.1 val () = p->[i] := (ussiLt_of)x prval () = xs.0 := pf in () end overload [] with array_get overload [] with array_set (* ****** ****** *) %{^ ATSinline() ats_void_type array_copy (ats_ptr_type src, ats_ptr_type dst, ats_size_type n) { memcpy (dst, src, n*sizeof(ats_ussi_type)); } %} extern fun array_copy {n : nat} {s, d : addr} ( src : ! iarray (n, s), dst : ! iarray (n, d), n : size_t n ) :<> void = "array_copy" (* ****** ****** *) fn array_fprint {n : nat} {l : addr} ( out : FILEref, xs : ! iarray (n, l), n : size_t n ) : void = let var i : sizeLte n = size1_of_int1 0 val () = while (i < n) (fprint_size (out, xs[i]); i := i + 1) val () = fprint_char (out, '\n') in end fn array_print {n : nat} {l : addr} ( xs : ! iarray (n, l), n : size_t n ) : void = begin array_fprint (stdout_ref, xs, n) end (* ****** ****** *) fun array_init {n : nat} {l : addr} {i : nat | i <= n} .< n - i >. (xs : ! iarray (n, l), n : size_t n, i : size_t i) :<> void = if i < n then (xs[i] := i ; array_init (xs, n, i + 1)) fun array_shift {n, i, j : nat | i <= j ; j < n} {l : addr} .< j - i >. (xs : ! iarray (n, l), i : size_t i, j : size_t j) :<> void = if i < j then (xs[i] := xs[i + 1] ; array_shift (xs, i + 1, j)) fn array_rotate {n : nat} {l : addr} (xs : ! iarray (n, l), i : sizeLt n) :<> void = let val x0 = xs[size1_of_int1 0] val () = array_shift (xs, 0, i) val () = xs[i] := x0 in () end fun array_reverse {n : nat} {x : addr} {l, u : nat | l - 1 <= u ; u < n} .< u - l + 1 >. (xs : ! iarray (n, x), l : size_t l, u : size_t u) :<> void = begin if l < u then let val xl = xs[l] val () = xs[l] := xs[u] val () = xs[u] := xl val () = array_reverse (xs, l + 1, u - 1) in () end end fun array_next_permutation {n : nat} {c, p : addr} {i : nat | i < n} .< n - i >. ( cs : ! iarray (n, c), ps : ! iarray (n, p) , n : size_t n, i : size_t i ) :<> sizeLte n = let val () = array_rotate (ps, i) val ci = cs[i] in if ci > 0 then (cs[i] := ci - 1 ; i) else let val () = cs[i] := i in if i + 1 >= n then i + 1 else array_next_permutation (cs, ps, n, i + 1) end end (* ****** ****** *) typedef result = @{ maxFlips = int , checksum = int } fun fannkuch {n : nat | n >= 2} {c, p, s : addr} ( cs : ! iarray (n, c), ps : ! iarray (n, p), ss : ! iarray (n, s) , n : size_t n, count : int, result : &result ) : void = let val () = if array_get (ps, 0) = 0 then () else let var flips : int = 0 val () = array_copy (ps, ss, n) var s0 : sizeLt n = ss[size1_of_int1 0] val () = while (s0 > 0) let val () = flips := flips + 1 val () = array_reverse (ss, 0, s0) val () = s0 := ss[size1_of_int1 0] in () end val () = result.maxFlips := (if result.maxFlips < flips then flips else result.maxFlips) val () = result.checksum := result.checksum + (if count mod 2 = 0 then flips else ~flips) in () end val i = array_next_permutation (cs, ps, n, 1) in if i < n then fannkuch (cs, ps, ss, n, count + 1, result) end (* ****** ****** *) implement main (argc, argv) = let val () = assert (argc >= 2) val [n : int] n = int1_of argv.[1] val () = assert (1 < n && n <= 256) val n = size1_of_int1 n val z = ussiLt_of (size1_of_int1 (0)) var !cs with pcs = @[ussiLt n][n](z) var !ps with pps = @[ussiLt n][n](z) var !ss with pss = @[ussiLt n][n](z) val acs = @(pcs | cs) val aps = @(pps | ps) val ass = @(pss | ss) val () = array_init (acs, n, 0) val () = array_init (aps, n, 0) var ans : result = @{ maxFlips = 0, checksum = 0 } val () = fannkuch (acs, aps, ass, n, 0, ans) prval () = pcs := acs.0 prval () = pps := aps.0 prval () = pss := ass.0 in printf ("%i\n", @(ans.checksum)); printf ("Pfannkuchen(%i) = %i\n", @(int1_of_size1 (n), ans.maxFlips)) end (* ****** ****** *)
Wed, 23 Jan 2013 04:49:58 GMT MAKE: /usr/local/src/ats-lang-anairiats-0.2.9/bin/atscc -pipe -Wall -O3 -fomit-frame-pointer -march=native fannkuchredux.dats -o fannkuchredux.ats-2.ats_run /usr/local/src/ats-lang-anairiats-0.2.9/bin/atsopt --output fannkuchredux_dats.c --dynamic fannkuchredux.dats In file included from fannkuchredux_dats.c:19:0: /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/basics.cats: In function ‘atspre_fprint_newline’: /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/basics.cats:271:11: warning: variable ‘n2’ set but not used [-Wunused-but-set-variable] /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/basics.cats:271:7: warning: variable ‘n1’ set but not used [-Wunused-but-set-variable] fannkuchredux_dats.c: In function ‘array_get_0’: fannkuchredux_dats.c:134:1: warning: label ‘__ats_lab_array_get_0’ defined but not used [-Wunused-label] fannkuchredux_dats.c: In function ‘array_set_1’: fannkuchredux_dats.c:151:1: warning: label ‘__ats_lab_array_set_1’ defined but not used [-Wunused-label] fannkuchredux_dats.c: In function ‘array_fprint_2’: fannkuchredux_dats.c:183:1: warning: label ‘__ats_lab_1’ defined but not used [-Wunused-label] fannkuchredux_dats.c:171:1: warning: label ‘__ats_lab_array_fprint_2’ defined but not used [-Wunused-label] fannkuchredux_dats.c: In function ‘array_print_3’: fannkuchredux_dats.c:197:1: warning: label ‘__ats_lab_array_print_3’ defined but not used [-Wunused-label] fannkuchredux_dats.c: In function ‘array_rotate_6’: fannkuchredux_dats.c:272:1: warning: label ‘__ats_lab_array_rotate_6’ defined but not used [-Wunused-label] fannkuchredux_dats.c: In function ‘fannkuch_9’: fannkuchredux_dats.c:413:1: warning: label ‘__ats_lab_3’ defined but not used [-Wunused-label] fannkuchredux_dats.c: In function ‘mainats’: fannkuchredux_dats.c:486:1: warning: label ‘__ats_lab_mainats’ defined but not used [-Wunused-label] In file included from fannkuchredux_dats.c:29:0: fannkuchredux_dats.c: At top level: /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/pointer.cats:52:14: warning: ‘atspre_null_ptr’ defined but not used [-Wunused-variable] In file included from fannkuchredux_dats.c:30:0: /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/printf.cats:57:1: warning: ‘atspre_fprintf_err’ defined but not used [-Wunused-function] /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/printf.cats:69:1: warning: ‘atspre_fprintf_exn’ defined but not used [-Wunused-function] /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/printf.cats:105:1: warning: ‘atspre_prerrf_exn’ defined but not used [-Wunused-function] In file included from fannkuchredux_dats.c:33:0: /usr/local/src/ats-lang-anairiats-0.2.9/prelude/CATS/string.cats:351:14: warning: ‘atspre_stropt_none’ defined but not used [-Wunused-variable] fannkuchredux_dats.c:193:1: warning: ‘array_print_3’ defined but not used [-Wunused-function] gcc -I/usr/local/src/ats-lang-anairiats-0.2.9/ -I/usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/ -L/usr/local/src/ats-lang-anairiats-0.2.9/ccomp/lib/ /usr/local/src/ats-lang-anairiats-0.2.9/ccomp/runtime/ats_prelude.c -pipe -Wall -O3 -fomit-frame-pointer -march=native fannkuchredux_dats.c -o fannkuchredux.ats-2.ats_run -lats 0.37s to complete and log all make actions COMMAND LINE: ./fannkuchredux.ats-2.ats_run 12 PROGRAM OUTPUT: 3968050 Pfannkuchen(12) = 65