The Computer Language
Benchmarks Game

fannkuch-redux F# .NET Core #2 program

source code

(* The Computer Language Benchmarks Game
   http://benchmarksgame.alioth.debian.org/

   from Scala version by Otto Bommer, August 2010
   Modified by Faisal Waris by remvoing ref's and using mutable variables, April 25, 2011
*)

let fannkuch n =
  begin
  let perm1 = Array.create n 0 in for i = 0 to (n-1) do perm1.[i] <- i done;
  let perm = Array.create n 0
  let count = Array.create n 0
  let mutable flips = 0 
  let mutable maxflips = 0 
  let mutable checksum = 0 
  let mutable nperm = 0
  let mutable r = n
  while r > 0 do 
    for i = 0 to n-1 do perm.[i] <- perm1.[i] done;

    while r <> 1 do count.[r-1] <- r; r <- r - 1; done;

    flips <- 0;
    let mutable k = perm.[0] in
    while k <> 0 do
      let mutable t = 0 in
      for i = 0 to k / 2 do
        t <- perm.[i];
        perm.[i] <- perm.[k - i];
        perm.[k - i] <- t;
        done;
        
      k <- perm.[0];
      flips <- flips + 1;
      done;

    maxflips <- max maxflips flips;
    if nperm &&& 1 = 0 then checksum <- checksum + flips else checksum <- checksum - flips
    
    let mutable go = true in
    let mutable t = 0 in
    while go do
      if r = n then begin go <- false; r <- 0; end
      else
        begin
        t <- perm1.[0];
        for i = 0 to r - 1 do perm1.[i] <- perm1.[i+1] done;
        perm1.[r] <- t;

        count.[r] <- count.[r] - 1;
        if count.[r] > 0 then go <- false
        else r <- r + 1;
        end
      done;

    nperm <- nperm + 1;
    done;

  (maxflips, checksum);
  end

let _ =
  let n = try int((System.Environment.GetCommandLineArgs()).[1]) with _ -> 7
  let (maxflips, checksum) = fannkuch n
  Printf.printf "%d\nPfannkuchen(%d) = %d\n" checksum n maxflips
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
2.0.0-preview1-005977
"System.GC.Server": true


Thu, 08 Jun 2017 21:58:11 GMT

MAKE:
cp fannkuchredux.fsharpcore-2.fsharpcore Program.fs
cp Include/fsharpcore/tmp.fsproj .
cp Include/fsharpcore/runtimeconfig.template.json .
mkdir obj
cp Include/fsharpcore/project.assets.json ./obj
cp Include/fsharpcore/tmp.fsproj.nuget.g.props ./obj
cp Include/fsharpcore/tmp.fsproj.nuget.g.targets ./obj
/usr/bin/dotnet build -c Release
Microsoft (R) Build Engine version 15.3.117.23532
Copyright (C) Microsoft Corporation. All rights reserved.

/home/dunham/.nuget/packages/fsharp.net.sdk/1.0.5/build/FSharp.NET.Core.Sdk.targets(170,9): error MSB6006: "dotnet" exited with code 131. [/home/dunham/benchmarksgame_quadcore/fannkuchredux/tmp/tmp.fsproj]

Build FAILED.

/home/dunham/.nuget/packages/fsharp.net.sdk/1.0.5/build/FSharp.NET.Core.Sdk.targets(170,9): error MSB6006: "dotnet" exited with code 131. [/home/dunham/benchmarksgame_quadcore/fannkuchredux/tmp/tmp.fsproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.82
/home/dunham/benchmarksgame/nanobench/makefiles/u64q.programs.Makefile:189: recipe for target 'fannkuchredux.fsharpcore-2.fsharpcore_run' failed
make: [fannkuchredux.fsharpcore-2.fsharpcore_run] Error 1 (ignored)

3.33s to complete and log all make actions

COMMAND LINE:
/usr/bin/dotnet ./bin/Release/netcoreapp2.0/tmp.dll 10

PROGRAM FAILED 


PROGRAM OUTPUT:

No executable found matching command "dotnet-./bin/Release/netcoreapp2.0/tmp.dll"