Commit 3021d1b8 authored by dmp's avatar dmp

Add the fibon benchmarks

There are a total of 34 benchmarks divided into four subgroups. The
DPH, Repa, and Shootout benchmarks are available elsewhere, but I
went ahead and added them since they are part of the fibon suite and
it might be nice to have a version of them easily available for use
by GHC developers.  As far as I know, the Hackage benchmarks are not
available (as benchmarks) anywhere else.
parent 49f49177

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

# Boring file regexps:
### compiler and interpreter intermediate files
# haskell (ghc) interfaces
*.hi
*.hi-boot
*.o-boot
# object files
*.o
*.o.cmd
# profiling haskell
*.p_hi
*.p_o
# haskell program coverage resp. profiling info
*.tix
*.prof
# fortran module files
*.mod
# linux kernel
*.ko.cmd
*.mod.c
# *.ko files aren't boring by default because they might
# be Korean translations rather than kernel modules
# \.ko$
# python, emacs, java byte code
*.pyc
*.pyo
*.elc
*.class
# objects and libraries; lo and la are libtool things
*.obj
*.a
*.exe
*.so
*.lo
*.la
# compiled zsh configuration files
*.zwc
# Common LISP output files for CLISP and CMUCL
*.fas
*.fasl
*.sparcf
*.x86f
### build and packaging systems
# cabal intermediates
*.installed-pkg-config*
*.setup-config*
# standard cabal build dir, might not be boring for everybody
# ^dist(/|$)
# autotools
autom4te.cache
config.log
config.status
# microsoft web expression, visual studio metadata directories
*_vti_cnf
*_vti_pvt
# gentoo tools
*.revdep-rebuild.*
# generated dependencies
.depend
### version control systems
# cvs
CVS/
.cvsignore
# cvs, emacs locks
.#
# rcs
RCS/
*,v
# subversion
*.svn
# mercurial
*.hg
# bzr
*.bzr
# sccs
SCCS/
# darcs
_darcs/
*.darcsrepo/
.darcs-temp-mail
*.swp
*.swo
### miscellaneous
# backup files
*~
*.bak
*.BAK
# patch originals and rejects
*.orig
*.rej
# X server
.serverauth.*
# image spam
Thumbs.db
# vi, emacs tags
tags/
TAGS/
#(^|/)\.[^/]
# core dumps
*.core
# partial broken files (KIO copy operations)
*.part
# mac os finder
*.DS_Store
# Erlang
*.dump
*.beam
#fibon-benchmarks
dist/
repa-bot/
repa-examples/
Name: Dotp
Version: 0.1
Stability: Experimental
Category: Benchmarking
Build-type: Simple
Cabal-version: >=1.2
Executable Dotp
Main-is: vect.hs
Hs-Source-Dirs: src ../_DphLib
Build-depends: base == 4.*,
dph-prim-par,
old-time,
dph-par,
random
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module Fibon.Benchmarks.Dph.Dotp.Fibon.Instance(
mkInstance
)
where
import Fibon.BenchmarkInstance
sharedConfig = BenchmarkInstance {
flagConfig = FlagConfig {
configureFlags = ["--ghc-option=-threaded"]
, buildFlags = []
, runFlags = []
}
, stdinInput = Nothing
, output = [(Stdout, Diff "Dotp.stdout.expected")]
, exeName = "Dotp"
}
flgCfg = flagConfig sharedConfig
mkInstance Test = sharedConfig {
flagConfig = flgCfg {runFlags = ["100"]}
}
mkInstance Ref = sharedConfig {
flagConfig = flgCfg {runFlags = ["50000000"]}
}
TOP = ../../..
include $(TOP)/mk/boilerplate.mk
SRCS = ../_DphLib/Bench/Time.hs \
../_DphLib/Bench/Options.hs \
../_DphLib/Bench/Benchmark.hs \
src/DotPVect.hs \
src/vect.hs
PROG_ARGS += 50000000
HC_OPTS += -threaded -isrc -i../_DphLib -package base -package dph-par -package dph-prim-par -package old-time -package random
include $(TOP)/mk/target.mk
Dot product
===========
DPH benchmarks
~~~~~~~~~~~~~~
DotPPrim.hs & prim.hs -- using primitives of package dph directly
DotPVect.hs & vect.hs -- vectorised DPH code
Both benchmarks are compiled against both the seq and par flavour of
package dph (with executables in the subdirectories seq/ and par/,
respectively).
Reference benchmarks
~~~~~~~~~~~~~~~~~~~~
DotP.hs -- multi-threaded reference implementation in Haskell
dot-c.c -- multi-threaded reference implementation in C
Legacy code
~~~~~~~~~~~
The legacy/ directory has an old, sequential Haskell implementation of dot
product timing a variety of Haskell arrays and a sequential C implementation.
\ No newline at end of file
</
{-# LANGUAGE MagicHash, UnboxedTuples, BangPatterns #-}
module Main
where
import GHC.Prim (
Double#, ByteArray#, MutableByteArray#, RealWorld,
newByteArray#, unsafeFreezeByteArray#,
readDoubleArray#, writeDoubleArray#, indexDoubleArray#)
import GHC.Base ( Int(..), (+#) )
import GHC.Float ( Double(..) )
import GHC.ST ( ST(..), runST )
import GHC.Conc ( forkOnIO, numCapabilities )
import Data.Array.Base (dOUBLE_SCALE)
import Control.Concurrent.MVar ( MVar, newEmptyMVar, takeMVar, putMVar )
import Control.Monad ( zipWithM_ )
import System.Environment ( getArgs )
import System.CPUTime
import System.Time
-- Arrays
-- ------
data Arr = Arr !Int !Int ByteArray#
data MArr s = MArr !Int (MutableByteArray# s)
lengthA :: Arr -> Int
lengthA (Arr _ n _) = n