Commit bcd47c37 authored by Nikolaos S. Papaspyrou's avatar Nikolaos S. Papaspyrou

Minor refactoring

parent 8dc12860
...@@ -2,5 +2,7 @@ ...@@ -2,5 +2,7 @@
*~ *~
*.o *.o
*.hi *.hi
*.dyn_o
*.dyn_hi
orbit orbit
OrbitTests OrbitTests
module Bench( -- sequential benchmarks module Bench( -- sequential benchmarks
seq seq
-- parallel benchmarks -- parallel benchmarks
, par, par_seq , par
-- distributed benhcmarks -- distributed benhcmarks
, dist, dist_seq , dist
, main , main
) where ) where
...@@ -17,6 +17,13 @@ import System.Environment ...@@ -17,6 +17,13 @@ import System.Environment
import MasterWorker import MasterWorker
import Utils import Utils
type Result = ([Vertex], [MasterStats])
--type Result = String
result :: ([Vertex], [MasterStats]) -> Result
result = id
--result = sz . snd
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- benchmarks, parametrised by -- benchmarks, parametrised by
-- * list of Generators -- * list of Generators
...@@ -24,36 +31,24 @@ import Utils ...@@ -24,36 +31,24 @@ import Utils
-- * number of processors P > 0 (per node) -- * number of processors P > 0 (per node)
-- * list of Workers (in short node name format 'name@host') -- * list of Workers (in short node name format 'name@host')
-- sequential orbit computation -- sequential orbit computation
seq :: (Vertex -> GenClos) -> Vertex -> Process String seq :: (Vertex -> GenClos) -> Vertex -> Process Result
seq generators n = seq generators n =
orbit (generators n) [0] (Seq (2 * n)) >>= return . sz . snd orbit (generators n) [0] (Seq (2 * n))
>>= return . result
-- parallel orbit computation (par_seq/3 does not spawn image computation)
par :: (Vertex -> GenClos) -> Vertex -> Int -> Process String
par generators n p =
orbit (generators n) [0]
(Par (JustOne (p, ((2 * n) `div` p) + 1, 0, True)))
>>= return . sz . snd
par_seq :: (Vertex -> GenClos) -> Vertex -> Int -> Process String -- parallel orbit computation (w/ False does not spawn image computation)
par_seq generators n p = par :: Bool -> (Vertex -> GenClos) -> Vertex -> Int -> Process Result
par iwp generators n p =
orbit (generators n) [0] orbit (generators n) [0]
(Par (JustOne (p, ((2 * n) `div` p) + 1, 0, False))) (Par (JustOne (p, ((2 * n) `div` p) + 1, 0, iwp)))
>>= return . sz . snd >>= return . result
-- distributed orbit computation (dist_seq/4 does not spawn image computation)
dist :: (Vertex -> GenClos) -> Vertex -> Int -> [NodeId] -> Process String
dist generators n p workers =
orbit (generators n) [0]
(Par (Many [(h, p, (2 * n) `div` (w * p) + 1, 0, True) | h <- workers]))
>>= return . sz . snd
where w = length workers
dist_seq :: (Vertex -> GenClos) -> Vertex -> Int -> [NodeId] -> Process String -- distributed orbit computation (w/ False does not spawn image computation)
dist_seq generators n p workers = dist :: Bool -> (Vertex -> GenClos) -> Vertex -> Int -> [NodeId] -> Process Result
dist iwp generators n p workers =
orbit (generators n) [0] orbit (generators n) [0]
(Par (Many [(h, p, (2 * n) `div` (w * p) + 1, 0, False) | h <- workers])) (Par (Many [(h, p, (2 * n) `div` (w * p) + 1, 0, iwp) | h <- workers]))
>>= return . sz . snd >>= return . result
where w = length workers where w = length workers
sz :: [MasterStats] -> String sz :: [MasterStats] -> String
...@@ -63,14 +58,14 @@ sz (mainStats : _) = ...@@ -63,14 +58,14 @@ sz (mainStats : _) =
Nothing -> "false" Nothing -> "false"
Just s -> "{size," ++ s ++ "}" Just s -> "{size," ++ s ++ "}"
select_par_bench :: String -> (Vertex -> GenClos) -> Vertex -> Int -> Process String select_par_bench :: String -> (Vertex -> GenClos) -> Vertex -> Int -> Process Result
select_par_bench "True" = par select_par_bench "True" = par True
select_par_bench "False" = par_seq select_par_bench "False" = par False
select_par_bench _ = error "Invalid IWP Flag" select_par_bench _ = error "Invalid IWP Flag"
select_dist_bench :: String -> (Vertex -> GenClos) -> Vertex -> Int -> [NodeId] -> Process String select_dist_bench :: String -> (Vertex -> GenClos) -> Vertex -> Int -> [NodeId] -> Process Result
select_dist_bench "True" = dist select_dist_bench "True" = dist True
select_dist_bench "False" = dist_seq select_dist_bench "False" = dist False
select_dist_bench _ = error "Invalid IWP Flag" select_dist_bench _ = error "Invalid IWP Flag"
bench_args :: String -> (Vertex -> GenClos, Int) bench_args :: String -> (Vertex -> GenClos, Int)
......
...@@ -9,7 +9,7 @@ tests: ...@@ -9,7 +9,7 @@ tests:
ghc $(COMPILE_OPTS) Tests.hs -o OrbitTests ghc $(COMPILE_OPTS) Tests.hs -o OrbitTests
clean: clean:
$(RM) *.swp *~ *.hi *.o $(RM) *.swp *~ *.hi *.o *.dyn_hi *.dyn_o
distclean: clean distclean: clean
$(RM) orbit OrbitTests $(RM) orbit OrbitTests
...@@ -179,7 +179,7 @@ vertex_server staticMachConf crdt table statData = do ...@@ -179,7 +179,7 @@ vertex_server staticMachConf crdt table statData = do
else newStatData0 {max_idle = max maxIdle (nowTime - lastEvent)} else newStatData0 {max_idle = max maxIdle (nowTime - lastEvent)}
newStatData = newStatData1 {last_event = now} newStatData = newStatData1 {last_event = now}
vertex_server staticMachConf newCredit newTable newStatData vertex_server staticMachConf newCredit newTable newStatData
, match $ \"dump" -> do , match $ \("dump") -> do
let nowTime = now let nowTime = now
lastEvent = last_event statData lastEvent = last_event statData
newStatData = statData {tail_idle = nowTime - lastEvent, newStatData = statData {tail_idle = nowTime - lastEvent,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment