Fix memory leaks in the parallel version

parent 68e478fb
...@@ -77,9 +77,9 @@ select_dist_bench "False" = dist False ...@@ -77,9 +77,9 @@ 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)
bench_args "short" = (gg13, 11) bench_args "short" = (gg13, 11000)
bench_args "intermediate" = (gg124, 157) bench_args "intermediate" = (gg124, 157000)
bench_args "long" = (gg1245, 157) bench_args "long" = (gg1245, 1570000)
bench_args _ = error "Invalid Version" bench_args _ = error "Invalid Version"
main :: IO () main :: IO ()
......
...@@ -162,6 +162,17 @@ vertex_server staticMachConf crdt table statData = do ...@@ -162,6 +162,17 @@ vertex_server staticMachConf crdt table statData = do
r <- receiveTimeout idleTimeout [ r <- receiveTimeout idleTimeout [
match $ \("vertex", x, slot, k) -> do match $ \("vertex", x, slot, k) -> do
-- say $ "Got a vertex!" -- say $ "Got a vertex!"
return $ Just (x, slot, k)
, match $ \("dump") -> do
return $ Nothing
]
case r of
Nothing -> do let creditRetd = credit_retd statData
newCreditRetd <- return_credit staticMachConf crdt creditRetd
let newStatData = statData {credit_retd = newCreditRetd}
vertex_server staticMachConf zero table newStatData
Just msg -> case msg of
Just (x, slot, k) -> do
let creditPlusK = credit_atomic k crdt let creditPlusK = credit_atomic k crdt
nowTime = now nowTime = now
vertsRecvd = verts_recvd statData vertsRecvd = verts_recvd statData
...@@ -179,19 +190,12 @@ vertex_server staticMachConf crdt table statData = do ...@@ -179,19 +190,12 @@ 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 Nothing -> 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,
last_event = now} last_event = now}
dump_table staticMachConf table newStatData dump_table staticMachConf table newStatData
]
case r of
Nothing -> do let creditRetd = credit_retd statData
newCreditRetd <- return_credit staticMachConf crdt creditRetd
let newStatData = statData {credit_retd = newCreditRetd}
vertex_server staticMachConf zero table newStatData
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
......
...@@ -129,7 +129,7 @@ freq_from_stat stat = ...@@ -129,7 +129,7 @@ freq_from_stat stat =
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- auxiliary functions -- auxiliary functions
inc :: Int -> Array Int Int -> Array Int Int inc :: Int -> Array Int Int -> Array Int Int
inc i t = t // [(i, t ! i + 1)] inc i t = t!i `seq` t // [(i, t!i + 1)]
fi :: (Integral a, Num b) => a -> b fi :: (Integral a, Num b) => a -> b
fi = fromIntegral fi = fromIntegral
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