Ticket #7462: 0001-Add-new-imaginary-nofib-benchmark-kahan.patch

File 0001-Add-new-imaginary-nofib-benchmark-kahan.patch, 10.2 KB (added by tibbe, 17 months ago)
  • .gitignore

    From 14bccff2c547c0e06fe8f98607b9cf18890ef051 Mon Sep 17 00:00:00 2001
    From: Johan Tibell <johan.tibell@gmail.com>
    Date: Thu, 29 Nov 2012 19:29:09 -0800
    Subject: [PATCH 1/1] Add new imaginary nofib benchmark kahan
    
    The benchmark implements the Kahan summation algorithm and tests unboxed
    arrays and floating point arithmetic in tight loops.
    ---
     .gitignore                       |    1 +
     imaginary/Makefile               |    2 +-
     imaginary/kahan/Main.hs          |   53 ++++++++++++++++++++++++++++++++++++++
     imaginary/kahan/Makefile         |    7 +++++
     imaginary/kahan/kahan.faststdout |    1 +
     imaginary/kahan/kahan.slowstdout |    1 +
     imaginary/kahan/kahan.stdout     |    1 +
     7 files changed, 65 insertions(+), 1 deletion(-)
     create mode 100644 imaginary/kahan/Main.hs
     create mode 100644 imaginary/kahan/Makefile
     create mode 100644 imaginary/kahan/kahan.faststdout
     create mode 100644 imaginary/kahan/kahan.slowstdout
     create mode 100644 imaginary/kahan/kahan.stdout
    
    diff --git a/.gitignore b/.gitignore
    index 694c606..0e3bf34 100644
    a b imaginary/tak/tak 
    2222imaginary/wheel-sieve1/wheel-sieve1 
    2323imaginary/wheel-sieve2/wheel-sieve2 
    2424imaginary/x2n1/x2n1 
     25imaginary/kahan/kahan 
    2526 
    2627real/anna/anna 
    2728real/bspt/bspt 
  • imaginary/Makefile

    diff --git a/imaginary/Makefile b/imaginary/Makefile
    index 7f5d766..7c2fcfa 100644
    a b TOP = .. 
    22include $(TOP)/mk/boilerplate.mk 
    33 
    44SUBDIRS = bernouilli exp3_8 gen_regexps integrate paraffins primes queens \ 
    5           rfib tak wheel-sieve1 wheel-sieve2 x2n1 
     5          rfib tak wheel-sieve1 wheel-sieve2 x2n1 kahan 
    66 
    77OTHER_SUBDIRS = digits-of-e1 digits-of-e2 
    88 
  • new file imaginary/kahan/Main.hs

    diff --git a/imaginary/kahan/Main.hs b/imaginary/kahan/Main.hs
    new file mode 100644
    index 0000000..6b3f76b
    - +  
     1-- | Implementation of Kahan summation algorithm that tests 
     2-- performance of tight loops involving unboxed arrays and floating 
     3-- point arithmetic. 
     4module Main (main) where 
     5 
     6import Control.Monad.ST 
     7import Data.Array.Base 
     8import Data.Array.ST 
     9import Data.Bits 
     10import Data.Word 
     11import System.Environment 
     12 
     13vdim :: Int 
     14vdim = 100 
     15 
     16prng :: Word -> Word 
     17prng w = w' 
     18  where 
     19    w1 = w `xor` (w `shiftL` 13) 
     20    w2 = w1 `xor` (w1 `shiftR` 7) 
     21    w' = w2 `xor` (w2 `shiftL` 17) 
     22 
     23type Vec s = STUArray s Int Double 
     24 
     25kahan :: Int -> Vec s -> Vec s -> ST s () 
     26kahan vnum s c = do 
     27    let inner w j 
     28            | j < vdim  = do 
     29                cj <- unsafeRead c j 
     30                sj <- unsafeRead s j 
     31                let y = fromIntegral w - cj 
     32                    t = sj + y 
     33                    w' = prng w 
     34                unsafeWrite c j ((t-sj)-y) 
     35                unsafeWrite s j t 
     36                inner w' (j+1) 
     37            | otherwise = return () 
     38 
     39        outer i | i <= vnum = inner (fromIntegral i) 0 >> outer (i+1) 
     40                | otherwise = return () 
     41    outer 1 
     42 
     43calc :: Int -> ST s (Vec s) 
     44calc vnum = do 
     45    s <- newArray (0,vdim-1) 0 
     46    c <- newArray (0,vdim-1) 0 
     47    kahan vnum s c 
     48    return s 
     49 
     50main :: IO () 
     51main = do 
     52    [arg] <- getArgs 
     53    print . elems $ runSTUArray $ calc $ read arg 
  • new file imaginary/kahan/Makefile

    diff --git a/imaginary/kahan/Makefile b/imaginary/kahan/Makefile
    new file mode 100644
    index 0000000..993f91a
    - +  
     1TOP = ../.. 
     2include $(TOP)/mk/boilerplate.mk 
     3include $(TOP)/mk/target.mk 
     4 
     5FAST_OPTS = 100000 
     6NORM_OPTS = 250000 
     7SLOW_OPTS = 1000000 
  • new file imaginary/kahan/kahan.faststdout

    diff --git a/imaginary/kahan/kahan.faststdout b/imaginary/kahan/kahan.faststdout
    new file mode 100644
    index 0000000..ded0873
    - +  
     1[5.00005e9,5.369053728444508e18,9.214677691986113e23,9.223553566339113e23,9.223473121419097e23,9.223522888580203e23,9.22345028973753e23,9.22352694515731e23,9.223403157027551e23,9.223388712289489e23,9.223476068054167e23,9.223461961881501e23,9.223401926687466e23,9.223376472383135e23,9.22345081357139e23,9.223453845728315e23,9.223396563410987e23,9.223383117079436e23,9.223395313430683e23,9.22343543610148e23,9.223431742062487e23,9.22343250174996e23,9.223404068908828e23,9.223439988092301e23,9.223431827723414e23,9.22337877267487e23,9.223406744761715e23,9.223480685849196e23,9.223392039072254e23,9.223534624641228e23,9.223372323220912e23,9.223485736372013e23,9.223426130283526e23,9.223378198590093e23,9.223379732278979e23,9.223519689103922e23,9.223473975914453e23,9.223401852354178e23,9.223374327124569e23,9.22339612286643e23,9.223743543515362e23,9.223527960867165e23,9.223555111133335e23,9.224972422595842e23,9.223441487427482e23,9.223418992343974e23,9.223470809898052e23,9.223227892456406e23,9.223380890143267e23,9.223395760227289e23,9.223411263978941e23,9.223478191324164e23,9.223402620247754e23,9.223423375671725e23,9.223546575548065e23,9.223471999523339e23,9.22349184845788e23,9.224487737890373e23,9.223427258937847e23,9.223374776439152e23,9.223410761316966e23,9.223441177807029e23,9.223448378869826e23,9.223389982172174e23,9.22542986216929e23,9.223496001425682e23,9.223441079827457e23,9.223384294009877e23,9.223535624614157e23,9.223506835450945e23,9.221991114110127e23,9.223452819775695e23,9.223424752451719e23,9.223492799053233e23,9.223511842792394e23,9.224090945694945e23,9.22342401622693e23,9.223912017833732e23,9.223375434848048e23,9.223475117244164e23,9.223430720277822e23,9.22312083019894e23,9.223545495951234e23,9.223397515570589e23,9.223433021037729e23,9.226068726592681e23,9.223338627013277e23,9.223382774083482e23,9.2234456578768e23,9.223488736824107e23,9.223531026603122e23,9.22361389553728e23,9.223441013228565e23,9.2213012566604e23,9.223478964280287e23,9.223545584461168e23,9.223475700738439e23,9.223500541702215e23,9.223428970099608e23,9.223436203125118e23] 
  • new file imaginary/kahan/kahan.slowstdout

    diff --git a/imaginary/kahan/kahan.slowstdout b/imaginary/kahan/kahan.slowstdout
    new file mode 100644
    index 0000000..2301c7d
    - +  
     1[5.000005e11,5.368766857178604e20,9.223067570285616e24,9.22338883080564e24,9.223380768829679e24,9.223378683951021e24,9.223372664975118e24,9.223388373861524e24,9.223387388131326e24,9.223382983926056e24,9.223380337373113e24,9.223378757931471e24,9.223372839726629e24,9.223390473904541e24,9.223384510580706e24,9.223381160400094e24,9.223375029072376e24,9.223379850691114e24,9.22338385607677e24,9.223375074357109e24,9.223381129396461e24,9.223377071110692e24,9.223387273118111e24,9.223386934998848e24,9.223385684734823e24,9.223382155776532e24,9.223376903355014e24,9.223381235615058e24,9.223378650856907e24,9.223383210101539e24,9.223376829958465e24,9.223381230976227e24,9.223385610074199e24,9.223386053383902e24,9.22338595221165e24,9.22337752562235e24,9.223381365879641e24,9.223378695870899e24,9.223379117500128e24,9.223386384862194e24,9.223392690579609e24,9.223381784365119e24,9.223375586873528e24,9.223671042953942e24,9.223378013702216e24,9.223380916314924e24,9.223380187878842e24,9.223408180631046e24,9.223382207353135e24,9.223387629849102e24,9.223381681597433e24,9.223378718222795e24,9.223373284668782e24,9.223385453254669e24,9.22338649275048e24,9.223380941856317e24,9.223384042223621e24,9.223456456000237e24,9.223378532684256e24,9.22337807011817e24,9.223388721097533e24,9.223372421684683e24,9.22338101272189e24,9.223383063302194e24,9.223635163871123e24,9.223373577005083e24,9.223381113741683e24,9.223380693613724e24,9.223387266290436e24,9.223381543734795e24,9.223374642200454e24,9.22337865393873e24,9.223386318923521e24,9.223388604966524e24,9.223374722873389e24,9.223425009691746e24,9.2233729244542e24,9.223311592255642e24,9.223374833392797e24,9.223389724320632e24,9.223386146043392e24,9.223387938401066e24,9.223389170734195e24,9.223388318481718e24,9.22337515467525e24,9.224049314505136e24,9.22339904702302e24,9.223388619827324e24,9.223389572407945e24,9.223387469878792e24,9.223390439537161e24,9.223393414951401e24,9.223387238453402e24,9.223382669800188e24,9.22337428260938e24,9.223379086568177e24,9.22338984838185e24,9.223384456031997e24,9.223389606398038e24,9.223372662864926e24] 
  • new file imaginary/kahan/kahan.stdout

    diff --git a/imaginary/kahan/kahan.stdout b/imaginary/kahan/kahan.stdout
    new file mode 100644
    index 0000000..bedf875
    - +  
     1[3.1250125e10,3.355499554634193e19,2.3040489940690484e24,2.3058611154149145e24,2.3058472999120837e24,2.305844366659836e24,2.3058511330925993e24,2.3058473237338455e24,2.3058491660124912e24,2.3058481802173244e24,2.3058592583884928e24,2.3058507171309392e24,2.305846357572962e24,2.3058600032611294e24,2.3058387331300874e24,2.3058544370965998e24,2.305854548059399e24,2.3058722997954022e24,2.3058473047014348e24,2.3058691015804897e24,2.305852394265984e24,2.3058510159514873e24,2.305851409289983e24,2.305847204233281e24,2.3058493506776458e24,2.305843472410917e24,2.3058537432776209e24,2.305857760083343e24,2.3058560332176753e24,2.305855227996405e24,2.3058510774016447e24,2.3058543202414107e24,2.3058524412598444e24,2.305843375327811e24,2.3058553394757447e24,2.3058441168348288e24,2.3058578577038755e24,2.3058460429503122e24,2.3058447805295862e24,2.3058581160339405e24,2.3058793268512367e24,2.3058541939481701e24,2.305853099818761e24,2.305776647028963e24,2.3058564304971686e24,2.305848270690023e24,2.3058591076257776e24,2.3058633843993345e24,2.3058514500671367e24,2.3058593681438864e24,2.3058566605396014e24,2.3058418820446876e24,2.3058478539769282e24,2.305861203230318e24,2.3058465203390488e24,2.3058605775300721e24,2.3058521690184257e24,2.3059793055137656e24,2.305840551244023e24,2.3058613673864072e24,2.3058691465592115e24,2.305856476432445e24,2.305849891690243e24,2.3057830586913604e24,2.305934172151329e24,2.305861654605338e24,2.3058597146683053e24,2.3058519833483365e24,2.305852846859808e24,2.305846350414648e24,2.305778094950151e24,2.3058450194826424e24,2.3058448499656401e24,2.3058454039512149e24,2.3058221698005298e24,2.3059247644029773e24,2.3058554427875403e24,2.3058297108614905e24,2.3058516267875768e24,2.305857364380186e24,2.3058467373824481e24,2.3058308488853875e24,2.3058502421923537e24,2.3058608737162822e24,2.3058599080925392e24,2.3056098809237103e24,2.305838541092883e24,2.3058591359437855e24,2.3058599172516066e24,2.3058610717389376e24,2.3058452431025416e24,2.305842957398577e24,2.3058481366100907e24,2.3057325810298929e24,2.3058567218200272e24,2.305852670226271e24,2.3058428389941982e24,2.305860407812593e24,2.3059245607640613e24,2.3058485117216828e24]