Commit 88100d3d authored by Yiannis Tsiouris's avatar Yiannis Tsiouris

Refactoring + trying to identify the problem (not working)

parent f9fba183
...@@ -23,9 +23,10 @@ import Control.Distributed.Process (Process, ProcessId, NodeId, ...@@ -23,9 +23,10 @@ import Control.Distributed.Process (Process, ProcessId, NodeId,
import Data.Hashable (hash) import Data.Hashable (hash)
import Data.Maybe (fromJust) import Data.Maybe (fromJust)
import Credit (ACredit, Credit, credit, credit_atomic, import Credit (ACredit, Credit, credit,
debit_atomic, debit_atomic_nz, credit_atomic, debit_atomic,
is_one, is_zero, zero) debit_atomic_nz, is_one, is_zero,
zero)
import qualified Sequential as Sq (Generator, orbit) import qualified Sequential as Sq (Generator, orbit)
import Table (Freq, Vertex, VTable, import Table (Freq, Vertex, VTable,
freq_from_stat, freq_to_stat, freq_from_stat, freq_to_stat,
...@@ -234,18 +235,19 @@ defaultCt = Ct { verts_recvd = 0 ...@@ -234,18 +235,19 @@ defaultCt = Ct { verts_recvd = 0
-- initialise worker -- initialise worker
init :: Int -> Int -> Bool -> Process () init :: Int -> Int -> Bool -> Process ()
init localTableSize idleTimeout spawnImgComp = do init localTableSize idleTimeout spawnImgComp =
let table = new localTableSize
receiveWait [ receiveWait [
match $ \("init", staticMachConf0) -> do match $ \("init", staticMachConf0) -> do
let statData = defaultCt let staticMachConf1 = set_idle_timeout staticMachConf0 idleTimeout
staticMachConf1 = set_idle_timeout staticMachConf0 idleTimeout staticMachConf =
staticMachConf = if spawnImgComp then staticMachConf1 if spawnImgComp then staticMachConf1
else clear_spawn_img_comp staticMachConf1 else clear_spawn_img_comp staticMachConf1
credit = zero vertex_server staticMachConf zero (new localTableSize) defaultCt
vertex_server staticMachConf credit table statData
] ]
vertex_server :: ParConf -> Credit -> VTable -> Ct -> Process ()
vertex_server _ _ _ _ = return ()
{-
-- main worker loop: server handling vertex messages; -- main worker loop: server handling vertex messages;
-- StaticMachConf: info about machine configuration -- StaticMachConf: info about machine configuration
-- Credit: credit currently held by the server, -- Credit: credit currently held by the server,
...@@ -286,6 +288,7 @@ vertex_server staticMachConf credit table statData = do ...@@ -286,6 +288,7 @@ vertex_server staticMachConf credit table statData = do
let newStatData = statData {credit_retd = newCreditRetd} let newStatData = statData {credit_retd = newCreditRetd}
vertex_server staticMachConf zero table newStatData vertex_server staticMachConf zero table newStatData
Just _ -> return () Just _ -> return ()
-}
-- handle_vertex checks whether vertex X is stored in Slot of Table; -- handle_vertex checks whether vertex X is stored in Slot of Table;
-- if not, it is in inserted there and the images of the generators -- if not, it is in inserted there and the images of the generators
...@@ -294,7 +297,6 @@ vertex_server staticMachConf credit table statData = do ...@@ -294,7 +297,6 @@ vertex_server staticMachConf credit table statData = do
handle_vertex :: ParConf -> Vertex -> Int -> Credit -> VTable handle_vertex :: ParConf -> Vertex -> Int -> Credit -> VTable
-> Process (Credit, VTable) -> Process (Credit, VTable)
handle_vertex staticMachConf x slot credit table handle_vertex staticMachConf x slot credit table
-- check whether x is already in table
| is_member x slot table = return (credit, table) -- x already in table; | is_member x slot table = return (credit, table) -- x already in table;
-- do nothing -- do nothing
| otherwise = do -- x not in table | otherwise = do -- x not in table
......
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