expanded stuff, included more dependencies, got accelerate to run

This commit is contained in:
Nicole Dresselhaus 2013-11-15 13:19:25 +01:00
parent 63499d0f0e
commit 717cfd7b34
11 changed files with 50 additions and 15 deletions

View File

@ -14,6 +14,13 @@
(major1) == 0 && (major2) < 4 || \ (major1) == 0 && (major2) < 4 || \
(major1) == 0 && (major2) == 4 && (minor) <= 6) (major1) == 0 && (major2) == 4 && (minor) <= 6)
/* package accelerate-0.13.0.5 */
#define VERSION_accelerate "0.13.0.5"
#define MIN_VERSION_accelerate(major1,major2,minor) (\
(major1) < 0 || \
(major1) == 0 && (major2) < 13 || \
(major1) == 0 && (major2) == 13 && (minor) <= 0)
/* package base-4.6.0.1 */ /* package base-4.6.0.1 */
#define VERSION_base "4.6.0.1" #define VERSION_base "4.6.0.1"
#define MIN_VERSION_base(major1,major2,minor) (\ #define MIN_VERSION_base(major1,major2,minor) (\
@ -28,6 +35,13 @@
(major1) == 0 && (major2) < 10 || \ (major1) == 0 && (major2) < 10 || \
(major1) == 0 && (major2) == 10 && (minor) <= 0) (major1) == 0 && (major2) == 10 && (minor) <= 0)
/* package deepseq-1.3.0.1 */
#define VERSION_deepseq "1.3.0.1"
#define MIN_VERSION_deepseq(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 3 || \
(major1) == 1 && (major2) == 3 && (minor) <= 0)
/* package ghc-7.6.3 */ /* package ghc-7.6.3 */
#define VERSION_ghc "7.6.3" #define VERSION_ghc "7.6.3"
#define MIN_VERSION_ghc(major1,major2,minor) (\ #define MIN_VERSION_ghc(major1,major2,minor) (\

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

4
dist/setup-config vendored

File diff suppressed because one or more lines are too long

View File

@ -8,16 +8,18 @@ description:
data-dir: "" data-dir: ""
executable hgraph executable hgraph
build-depends: QuickCheck -any, Stream -any, base -any, build-depends: QuickCheck -any, Stream -any, accelerate -any,
bytestring -any, ghc -any, monad-par -any, parallel -any base -any, bytestring -any, deepseq -any, ghc -any, monad-par -any,
parallel -any
main-is: Main.hs main-is: Main.hs
buildable: True buildable: True
hs-source-dirs: src hs-source-dirs: src
ghc-options: -threaded -rtsopts -eventlog ghc-options: -threaded -rtsopts -eventlog
test-suite test-hgraph test-suite test-hgraph
build-depends: QuickCheck -any, Stream -any, base -any, build-depends: QuickCheck -any, Stream -any, accelerate -any,
bytestring -any, ghc -any, monad-par -any, parallel -any base -any, bytestring -any, deepseq -any, ghc -any, monad-par -any,
parallel -any
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: Main.hs main-is: Main.hs
buildable: True buildable: True

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -19,6 +19,7 @@ module Main (
import Control.Monad (unless) import Control.Monad (unless)
import Control.Parallel.Strategies import Control.Parallel.Strategies
import Control.DeepSeq
import Data.List import Data.List
import System.Exit (exitFailure) import System.Exit (exitFailure)
import System.Environment import System.Environment
@ -28,16 +29,20 @@ import Data.ByteString.Lazy.Char8 (ByteString)
import Control.Monad.Par.Scheds.Trace import Control.Monad.Par.Scheds.Trace
import qualified Data.Stream as S import qualified Data.Stream as S
import Data.Either (lefts, rights) import Data.Either (lefts, rights)
import Debug.Trace
import qualified Data.Array.Accelerate as A
-- change to Data.Array.Accelerate.CUDA as I and link accelerate-cuda to use GPU instead of CPU
import Data.Array.Accelerate.Interpreter as I
import Stream hiding (map) import Stream hiding (map)
type Matrix e = A.Array A.DIM2 e
-- TODO: implement parser!
createGraph :: String -> Either [Int] String createGraph :: String -> Either [Int] String
createGraph input = createGraph' input (Left []) createGraph input = traceEvent "creating graph" createGraph' input (Left [])
where where
createGraph' :: String -> Either [Int] String -> Either [Int] String createGraph' :: String -> Either [Int] String -> Either [Int] String
createGraph' [] r = r createGraph' [] r = traceEvent "recursion done." r
createGraph' (a:as) r = createGraph' (a:as) r =
let next = (createGraph' as r) in let next = (createGraph' as r) in
case next of case next of
@ -87,8 +92,10 @@ emptyLog [] = True
emptyLog a = emptyLine $ foldl1 (++) a emptyLog a = emptyLine $ foldl1 (++) a
-- TODO: implement calculation -- TODO: implement calculation
doCalculation :: [[Int]] -> ByteString doCalculation :: Matrix Int -> ByteString
doCalculation a = B.pack $ (show a) ++ "\n" doCalculation a = B.pack $ "" --(show a) ++ "\n"
exeMain = do exeMain = do
args <- getArgs args <- getArgs
@ -103,10 +110,22 @@ exeMain = do
-- split at \n, convert to String -- split at \n, convert to String
(map B.unpack (B.split '\n' input))) (map B.unpack (B.split '\n' input)))
--egraph <- return $ graphFolder unrefined_graph --egraph <- return $ graphFolder unrefined_graph
(graph, log) <- return (lefts unrefined_graph, rights unrefined_graph) (graph, log, lines) <- return $ ((foldl1 (++) (lefts unrefined_graph), -- concatenated graph
output <- return $ case emptyLog log of foldl (concatWith "\n") "" (rights unrefined_graph), -- concat error-log
True -> doCalculation graph length unrefined_graph) -- number of elements in graph
_ -> B.pack $ "Error detected:\n" ++ (foldl (concatWith "\n") "" log) ++ "\n\n" -- in parallel
`using` parTuple3 rdeepseq rdeepseq rdeepseq)
-- validate graph
log <- return $ let l = length graph in
if l /= lines*lines then
log ++ "Lines dont match up. Read " ++ (show l) ++ " lines. Expected "
++ (show (lines*lines)) ++ " lines.\n"
else
log
output <- return $ case emptyLine log of
True -> doCalculation $ A.fromList (A.Z A.:. lines A.:. lines) graph
_ -> B.pack $ "Error detected:\n" ++ log ++ "\n\n"
B.putStr output B.putStr output