Commit 421e000b authored by Yiannis Tsiouris's avatar Yiannis Tsiouris

Force 4-space indentation and line-wrap

parent 163ed855
...@@ -93,12 +93,14 @@ type ParConf = ([Sq.Generator], ProcessId, [ProcessId], Int, Int, Bool) ...@@ -93,12 +93,14 @@ type ParConf = ([Sq.Generator], ProcessId, [ProcessId], Int, Int, Bool)
-- The function returns a pair consisting of the computed orbit and -- The function returns a pair consisting of the computed orbit and
-- a list of statistics, the first element of which reports overall statistics, -- a list of statistics, the first element of which reports overall statistics,
-- and all remaining elements report statistics of some worker. -- and all remaining elements report statistics of some worker.
orbit :: [Vertex -> Vertex] -> [Vertex] -> MaybeHosts -> ([Vertex], [MasterStats]) orbit :: [Vertex -> Vertex] -> [Vertex] -> MaybeHosts
-> ([Vertex], [MasterStats])
orbit gs xs (Seq tablesize) = Sq.orbit gs xs tablesize orbit gs xs (Seq tablesize) = Sq.orbit gs xs tablesize
orbit gs xs (Par hostInfo) = par_orbit gs xs hostInfo orbit gs xs (Par hostInfo) = par_orbit gs xs hostInfo
-- FIXME Write the proper par_orbit -- FIXME Write the proper par_orbit
par_orbit :: [Vertex -> Vertex] -> [Vertex] -> HostInfo -> ([Vertex], [MasterStats]) par_orbit :: [Vertex -> Vertex] -> [Vertex] -> HostInfo
-> ([Vertex], [MasterStats])
par_orbit gs xs hosts = ([42], [[("xxx", "xxx")]]) par_orbit gs xs hosts = ([42], [[("xxx", "xxx")]])
-- collect_credit collects leftover credit from idle workers until -- collect_credit collects leftover credit from idle workers until
...@@ -118,7 +120,8 @@ collect_orbit elapsedTime n = do ...@@ -118,7 +120,8 @@ collect_orbit elapsedTime n = do
(orbit, stats) <- do_collect_orbit n [] [] (orbit, stats) <- do_collect_orbit n [] []
return (concat orbit, master_stats elapsedTime stats : stats) return (concat orbit, master_stats elapsedTime stats : stats)
do_collect_orbit :: Int -> [[Vertex]] -> [WorkerStats] -> Process ([[Vertex]], [WorkerStats]) do_collect_orbit :: Int -> [[Vertex]] -> [WorkerStats]
-> Process ([[Vertex]], [WorkerStats])
do_collect_orbit 0 partOrbits workerStats = return (partOrbits, workerStats) do_collect_orbit 0 partOrbits workerStats = return (partOrbits, workerStats)
do_collect_orbit n partOrbits workerStats = do do_collect_orbit n partOrbits workerStats = do
receiveWait [ receiveWait [
...@@ -130,8 +133,10 @@ do_collect_orbit n partOrbits workerStats = do ...@@ -130,8 +133,10 @@ do_collect_orbit n partOrbits workerStats = do
-- auxiliary functions -- auxiliary functions
-- functions operating on the StaticMachConf -- functions operating on the StaticMachConf
mk_static_mach_conf :: [Sq.Generator] -> ProcessId -> [ProcessId] -> Int -> ParConf mk_static_mach_conf :: [Sq.Generator] -> ProcessId -> [ProcessId] -> Int
mk_static_mach_conf gs master workers globalTableSize = (gs, master, workers, globalTableSize, 0, True) -> ParConf
mk_static_mach_conf gs master workers globalTableSize =
(gs, master, workers, globalTableSize, 0, True)
get_gens :: ParConf -> [Sq.Generator] get_gens :: ParConf -> [Sq.Generator]
get_gens (gs, _, _, _, _, _) = gs get_gens (gs, _, _, _, _, _) = gs
...@@ -153,10 +158,12 @@ get_spawn_img_comp (_, _, _, _, _, spawmImgComp) = spawmImgComp ...@@ -153,10 +158,12 @@ get_spawn_img_comp (_, _, _, _, _, spawmImgComp) = spawmImgComp
set_idle_timeout :: ParConf -> Int -> ParConf set_idle_timeout :: ParConf -> Int -> ParConf
set_idle_timeout (gs, mst, wks, gts, timeout, spic) x = (gs, mst, wks, gts, x, spic) set_idle_timeout (gs, mst, wks, gts, timeout, spic) x =
(gs, mst, wks, gts, x, spic)
clear_spawn_img_comp :: ParConf -> ParConf clear_spawn_img_comp :: ParConf -> ParConf
clear_spawn_img_comp (gs, mst, wks, gts, tmt, spawmImgComp) = (gs, mst, wks, gts, tmt, False) clear_spawn_img_comp (gs, mst, wks, gts, tmt, spawmImgComp) =
(gs, mst, wks, gts, tmt, False)
-- produce readable statistics -- produce readable statistics
master_stats :: Int -> [WorkerStats] -> MasterStats master_stats :: Int -> [WorkerStats] -> MasterStats
......
...@@ -54,34 +54,37 @@ orbit gs xs tableSize = (orbit, [stat]) ...@@ -54,34 +54,37 @@ orbit gs xs tableSize = (orbit, [stat])
-- Table -- hash table holding vertices -- Table -- hash table holding vertices
-- Queue -- work queue -- Queue -- work queue
-- VertsRecvd -- number of vertices removed from the Queue so far -- VertsRecvd -- number of vertices removed from the Queue so far
vertex_server :: SeqConf -> VTable -> BankersDequeue Vertex -> Int -> (VTable, Int) vertex_server :: SeqConf -> VTable -> BankersDequeue Vertex -> Int
-> (VTable, Int)
vertex_server staticMachConf table queue vertsRecvd = vertex_server staticMachConf table queue vertsRecvd =
case popFront queue of case popFront queue of
(Nothing, _) -> (table, vertsRecvd) (Nothing, _) -> (table, vertsRecvd)
(Just x, queue1) -> vertex_server staticMachConf newTable newQueue (vertsRecvd + 1) (Just x, queue1) ->
where (newTable, newQueue) = handle_vertex staticMachConf x table queue1 let (newTable, newQueue) = handle_vertex staticMachConf x table queue1
in vertex_server staticMachConf newTable newQueue (vertsRecvd + 1)
-- handle_vertex checks whether vertex X is stored in Table; -- handle_vertex checks whether vertex X is stored in Table;
-- if not, it is in inserted and the images of the generators -- if not, it is in inserted and the images of the generators
-- are pushed into the work queue. -- are pushed into the work queue.
handle_vertex :: SeqConf -> Vertex -> VTable -> BankersDequeue Vertex -> (VTable, BankersDequeue Vertex) handle_vertex :: SeqConf -> Vertex -> VTable -> BankersDequeue Vertex
-> (VTable, BankersDequeue Vertex)
handle_vertex staticMachConf x table queue = handle_vertex staticMachConf x table queue =
case is_member x slot table of -- check whether X is already in Table case is_member x slot table of -- check whether X is already in Table
-- X already in table; do nothing -- X already in table; do nothing
True -> (table, queue) True -> (table, queue)
-- X not in table -- X not in table
False -> (newTable, newQueue) -- return updated table and queue False ->
where newTable = insert x slot table -- insert X at Slot let -- insert X at Slot
xs = [g x | g <- gs] -- compute images of X under generators Gs newTable = insert x slot table
newQueue = foldl pushBack queue xs -- enquene Xs -- compute images of X under generators Gs and enqueue
where gs = get_gens staticMachConf xs = [g x | g <- get_gens staticMachConf]
slot = hash_vertex staticMachConf x -- compute Slot newQueue = foldl pushBack queue xs
in (newTable, newQueue) -- return updated table and queue
where slot = hash_vertex staticMachConf x -- compute Slot
-- hash_vertex computes the hash table slot of vertex X -- hash_vertex computes the hash table slot of vertex X
hash_vertex :: SeqConf -> Vertex -> Int hash_vertex :: SeqConf -> Vertex -> Int
hash_vertex staticMachConf x = hash_vertex staticMachConf x = hsh `rem` tableSize
hsh `rem` tableSize
where tableSize = get_table_size staticMachConf where tableSize = get_table_size staticMachConf
hsh = abs $ hash x hsh = abs $ hash x
...@@ -104,4 +107,3 @@ seq_stats elapsedTime frequency vertsRecvd = ...@@ -104,4 +107,3 @@ seq_stats elapsedTime frequency vertsRecvd =
("wall_time", show elapsedTime) ("wall_time", show elapsedTime)
: ("vertices_recvd", show vertsRecvd) : ("vertices_recvd", show vertsRecvd)
: freq_to_stat frequency : freq_to_stat frequency
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