Commit c7bb52d6 authored by Aggelos Giantsios's avatar Aggelos Giantsios

Add type aliases for the configuration

The configuration is the type of the
StaticMachConf variable
parent fba696a6
...@@ -27,13 +27,12 @@ import WorkerAux ...@@ -27,13 +27,12 @@ import WorkerAux
import Types import Types
( Generator ( Generator
, Freq , Freq
, SeqConf
, Stats , Stats
, Vertex , Vertex
, VTable , VTable
) )
type Conf = ([Generator], Int)
-- DATA -- DATA
-- Static Machine Configuration: -- Static Machine Configuration:
-- {Gs, --list of generators -- {Gs, --list of generators
...@@ -70,7 +69,7 @@ orbit gs xs tableSize = (orbit, [stat]) ...@@ -70,7 +69,7 @@ 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 :: Conf -> 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)
...@@ -80,7 +79,7 @@ vertex_server staticMachConf table queue vertsRecvd = ...@@ -80,7 +79,7 @@ vertex_server staticMachConf table queue vertsRecvd =
-- 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 :: Conf -> 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
...@@ -95,7 +94,7 @@ handle_vertex staticMachConf x table queue = ...@@ -95,7 +94,7 @@ handle_vertex staticMachConf x table queue =
-- hash_vertex computes the hash table slot of vertex X -- hash_vertex computes the hash table slot of vertex X
hash_vertex :: Conf -> 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
...@@ -105,13 +104,13 @@ hash_vertex staticMachConf x = ...@@ -105,13 +104,13 @@ hash_vertex staticMachConf x =
-- auxiliary functions -- auxiliary functions
-- functions operating on the StaticMachConf -- functions operating on the StaticMachConf
mk_static_mach_conf :: [Generator] -> Int -> Conf mk_static_mach_conf :: [Generator] -> Int -> SeqConf
mk_static_mach_conf gs tableSize = (gs, tableSize) mk_static_mach_conf gs tableSize = (gs, tableSize)
get_gens :: Conf -> [Generator] get_gens :: SeqConf -> [Generator]
get_gens staticMachConf = fst staticMachConf get_gens staticMachConf = fst staticMachConf
get_table_size :: Conf -> Int get_table_size :: SeqConf -> Int
get_table_size staticMachConf = snd staticMachConf get_table_size staticMachConf = snd staticMachConf
-- produce readable statistics -- produce readable statistics
......
...@@ -6,6 +6,8 @@ module Types ( Ct(..) ...@@ -6,6 +6,8 @@ module Types ( Ct(..)
, Freq , Freq
, Host , Host
, MaybeHosts(..) , MaybeHosts(..)
, ParConf
, SeqConf
, Stats , Stats
, Vertex , Vertex
, VTable) where , VTable) where
...@@ -15,6 +17,7 @@ import Data.Array ...@@ -15,6 +17,7 @@ import Data.Array
) )
import Control.Distributed.Process import Control.Distributed.Process
( NodeId ( NodeId
, ProcessId
) )
type Freq = [Int] type Freq = [Int]
...@@ -25,6 +28,8 @@ type Generator = Vertex -> Vertex ...@@ -25,6 +28,8 @@ type Generator = Vertex -> Vertex
type Host = (NodeId, Int, Int, Int) -- Node, Procs, TableSize, IdleTimeout type Host = (NodeId, Int, Int, Int) -- Node, Procs, TableSize, IdleTimeout
data MaybeHosts = Seq Int data MaybeHosts = Seq Int
| Par [Host] | Par [Host]
type SeqConf = ([Generator], Int)
type ParConf = ([Generator], ProcessId, [ProcessId], Int, Int, Bool)
-- counters/timers record -- counters/timers record
data Ct = Ct { data Ct = Ct {
......
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