Skip to content

Instantly share code, notes, and snippets.

View rrnewton's full-sized avatar

Ryan Newton rrnewton

View GitHub Profile
@rrnewton
rrnewton / results0.1
Created February 24, 2012 15:51
Current performance (latency) of different network-transport backends
This is the average latency as measured by a single trial run of 100K ping/pongs with several different transports.
PingTCP: 7.34s >80%CPU
PingTCPTransport: 19s ~60%CPU
PingPipes: 6.36s >=100%CPU
The machine is a 3.1 ghz Intel Westmere (Dell workstation) running RHEL 6.2.
The PingTCP is a baseline that uses the raw Network.Socket interface rather than the Network.Transport abstraction.
@rrnewton
rrnewton / forksplit_sketch.hs
Created April 2, 2012 18:36
A sketch of what types for an ST + Par + MVector combination
{-# LANGUAGE RankNTypes, GeneralizedNewtypeDeriving, CPP #-}
import Data.Vector.Mutable as MV
import qualified Data.Vector as V -- ((!), freeze)
import Control.Monad.ST
import Control.Monad.Primitive
import Prelude hiding (read)
type Splitter a = a -> (a,a)
@rrnewton
rrnewton / meta-par-accelerate_blog_post.lhs
Created May 4, 2012 19:19
meta-par-accelerate blog post
> module Main where
How to write hybrid CPU/GPU programs with Haskell
-------------------------------------------------
What's better than programming a GPU with a high-level,
Haskell-embedded DSL (domain-specific-language)? Well, perhaps
writing portable CPU/GPU programs that utilize both pieces of
@rrnewton
rrnewton / magnitude.hs
Created May 14, 2012 05:09
Better Haskell magnitude
import Data.Complex
-- This should be the biggest representable double:
big :: Double
big = 1.7976931348623157e308
-- This uses OCaml's approach at overflow-avoidance:
mag :: Complex Double -> Double
mag (x:+y) =
@rrnewton
rrnewton / cuda_backend_bug
Created June 18, 2012 16:00
Accelerate cuda backend bug reproducer
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE CPP #-}
-- Naive translation of shen_anova1_batch.m into Accelerate.
module Main (main) where
@rrnewton
rrnewton / double_read_WRONG.hs
Created April 2, 2013 17:39
An example of a concurrency bug that is upstream from the point of the concurrentMerge.
import qualified System.IO.Streams as S
import System.IO.Streams.Concurrent
import Control.Concurrent
import Data.IORef
import Data.ByteString.Char8 as B
main = do
cnt <- newIORef 0
s1 <- S.makeInputStream $ do
@rrnewton
rrnewton / example_output.txt
Last active December 17, 2015 20:29
Example output from a very simple hsbencher run.
$ cat > minimal.hs
import HSBencher
main = defaultMainWithBechmarks
[ mkBenchmark "bench1/bench1.cabal" ["1000"] $
Or [ Set NoMeaning (RuntimeParam "+RTS -qa -RTS")
, Set NoMeaning (RuntimeEnv "HELLO" "yes") ] ]
$ runghc minimal.hs
* Executing: hostname -s --> 1 line(s)
* Executing: git name-rev --name-only HEAD --> 1 line(s)
@rrnewton
rrnewton / Make_output
Last active December 19, 2015 05:09
Example output when compiling and running a GHC bug reproducer relating to getNumCapabilities.
rm -f *.o *.hi bugged.exe unbugged.exe
rm -rf ./bugged_dumps ./unbugged_dumps/
ghc -DACTIVATE_BUG -keep-tmp-files -dsuppress-module-prefixes -ddump-to-file -ddump-core-stats -ddump-simpl-stats -dcore-lint -dcmm-lint -ddump-ds -ddump-simpl -ddump-stg -ddump-asm -ddump-bcos -ddump-cmm -ddump-opt-cmm -ddump-inlinings -rtsopts -fforce-recomp -O2 -threaded PBBS.hs -main-is Util.PBBS.t4 -o bugged.exe
[1 of 1] Compiling Util.PBBS ( PBBS.hs, PBBS.o )
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
@rrnewton
rrnewton / MapTest.ddump-simple
Last active December 19, 2015 06:39
GHC Core generated when using foldrWithKey to build up a monadic action to consume a large Map.
Result size of Tidy Core = {terms: 423, types: 423, coercions: 39}
lvl_r2uH :: [GHC.Types.Char]
[GblId, Str=DmdType]
lvl_r2uH = GHC.CString.unpackCString# "Got it!"
Rec {
Main.$sinsert_$s$sgo6 [Occ=LoopBreaker]
:: forall a1_X12s.
GHC.Prim.Int#
@rrnewton
rrnewton / MapTest2.hs
Last active December 19, 2015 06:39
MapTest extended with Shachaf's suggestion
import Control.Applicative
import Control.Monad
import Control.DeepSeq
import Control.Exception
import GHC.Stats
import qualified Data.Map.Strict as M
import Data.Time.Clock
import Data.Monoid
import System.Mem