performance measurements

Each table row shows performance measurements for this F# Mono program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
2,000Failed  903   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read pidigits benchmark to see what this program should do.

 notes

F# Compiler for F# 3.1 (Open Source Edition)

Mono JIT compiler version 4.1.0 (master/435cc01 Wed May 20 21:03:41 PDT 2015)
LLVM: yes(3.6.0svn-mono-master/ce4fcec)
GC: sgen

 pidigits F# Mono #3 program source code

(**
 * The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * Port to F# by Jomo Fisher of the C# port that uses native GMP:
 * 	contributed by Mike Pall
 * 	java port by Stefan Krause
 *  C# port by Miguel de Icaza
*)
module PiDigits
open System
open System.Runtime.InteropServices

[<StructLayout (LayoutKind.Sequential)>]
[<Struct>]
type mpz_t =
   val _mp_alloc:int
   val _mp_size:int
   val ptr:IntPtr

[<DllImport ("gmp", EntryPoint="__gmpz_init")>]
let mpz_init(value : mpz_t byref) : unit = failwith ""

[<DllImport ("gmp", EntryPoint="__gmpz_mul_si")>]
let mpz_mul_si(dest : mpz_t byref, src : mpz_t byref, value : int) : unit = failwith ""

[<DllImport ("gmp", EntryPoint="__gmpz_add")>]
let mpz_add(dest : mpz_t byref, src : mpz_t byref, src2 : mpz_t byref) : unit = failwith ""

[<DllImport ("gmp", EntryPoint="__gmpz_tdiv_q")>]
let mpz_tdiv_q(dest : mpz_t byref, src : mpz_t byref, src2 : mpz_t byref) : unit = failwith ""

[<DllImport ("gmp", EntryPoint="__gmpz_set_si")>]
let mpz_set_si(src : mpz_t byref, value : int) : unit = failwith ""

[<DllImport ("gmp", EntryPoint="__gmpz_get_si")>] 
let mpz_get_si(src : mpz_t byref) : int = 0

let init() = 
    let mutable result = mpz_t()
    mpz_init(&result)
    result

let mutable q,r,s,t,u,v,w = init(),init(),init(),init(),init(),init(),init()

let mutable i = 0
let mutable c = 0
let ch = Array.zeroCreate 10
let args = System.Environment.GetCommandLineArgs()
let n = Int32.Parse args.[1]
let intZero = int '0'

let inline compose_r(bq, br, bs, bt) = 
    mpz_mul_si(&u, &r, bs)
    mpz_mul_si(&r, &r, bq)
    mpz_mul_si(&v, &t, br)
    mpz_add(&r, &r, &v)
    mpz_mul_si(&t, &t, bt)
    mpz_add(&t, &t, &u)
    mpz_mul_si(&s, &s, bt)
    mpz_mul_si(&u, &q, bs)
    mpz_add(&s, &s, &u)
    mpz_mul_si(&q, &q, bq)

// Compose matrix with numbers on the left.
let inline compose_l(bq, br, bs, bt) =
    mpz_mul_si(&r, &r, bt)
    mpz_mul_si(&u, &q, br)
    mpz_add(&r, &r, &u)
    mpz_mul_si(&u, &t, bs)
    mpz_mul_si(&t, &t, bt)
    mpz_mul_si(&v, &s, br)
    mpz_add(&t, &t, &v)
    mpz_mul_si(&s, &s, bq)
    mpz_add(&s, &s, &u)
    mpz_mul_si(&q, &q, bq)

// Extract one digit.
let inline extract(j) = 
    mpz_mul_si(&u, &q, j)
    mpz_add(&u, &u, &r)
    mpz_mul_si(&v, &s, j)
    mpz_add(&v, &v, &t)
    mpz_tdiv_q(&w, &u, &v)
    mpz_get_si(&w)


// Print one digit. Returns 1 for the last digit. 
let inline prdigit(y:int) = 
    ch.[c] <- char (intZero + y)
    c <- c + 1
    i <- i + 1
    if (i%10=0 || i = n) then
        while c<>ch.Length do
            ch.[c] <- ' '
            c<-c+1
        c <- 0
        Console.Write(ch)
        Console.Write("\t:")
        Console.WriteLine(i)
    i = n

// Generate successive digits of PI. 
let mutable k = 1
i <- 0
mpz_set_si(&q, 1)
mpz_set_si(&r, 0)
mpz_set_si(&s, 0)
mpz_set_si(&t, 1)
let mutable more = true
while more do
    let y = extract 3
    if y = extract 4 then
        if prdigit y then more<-false
        else compose_r(10, -10*y, 0, 1)
    else
        compose_l(k, 4*k+2, 0, 2*k+1);
        k<-k+1


 make, command-line, and program output logs

Thu, 21 May 2015 17:14:41 GMT

MAKE:
mv pidigits.fsharp-3.fsharp pidigits.fsharp-3.fs
/usr/local/bin/fsharpc --target:exe --platform:x86 -O  -o pidigits.fsharp-3.fsharp_run.exe pidigits.fsharp-3.fs
F# Compiler for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

/home/dunham/benchmarksgame_onecore/pidigits/tmp/pidigits.fsharp-3.fs(16,6): warning FS0009: Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'.
rm pidigits.fsharp-3.fs
8.42s to complete and log all make actions

COMMAND LINE:
/usr/local/bin/mono --llvm --gc=sgen pidigits.fsharp-3.fsharp_run.exe 2000

PROGRAM FAILED 


PROGRAM OUTPUT:

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) PiDigits.mpz_tdiv_q (PiDigits/mpz_t&,PiDigits/mpz_t&,PiDigits/mpz_t&) <0xffffffff>
  at <StartupCode$pidigits-fsharp-3-fsharp_run>.$PiDigits.main@ () <0x004f2>

Native stacktrace:

	/usr/local/bin/mono() [0x8271690]
	/usr/local/bin/mono() [0x81ed1f0]
	[0xb7771bc8]
	/usr/lib/i386-linux-gnu/libgmp.so(__gmp_exception+0x27) [0xb4c2c477]
	/usr/lib/i386-linux-gnu/libgmp.so(+0xa4c6) [0xb4c2c4c6]
	/usr/lib/i386-linux-gnu/libgmp.so(__gmpz_tdiv_q+0x1f5) [0xb4c43905]
	[0xb713e1f8]
	[0xb713bec3]

Debug info from gdb:


=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Revised BSD license

  Home   Conclusions   License   Play