Skip to content

Commit

Permalink
Renamed folders
Browse files Browse the repository at this point in the history
  • Loading branch information
kandrio committed Mar 4, 2021
1 parent 83af09e commit 46beb6c
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 151 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 12 additions & 9 deletions ex5/reverse_hash_solver_par.hs → ex05/reverse_hash_solver_par.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ ranges n counter start end =
in
((start, end'):(ranges n (counter-1) (end' + 1) end))

parMap' :: NFData b => (a -> b) -> [a] -> Eval [b]
parMap' f [] = return []
parMap' f (a:as) = do
parMap' :: NFData b => (a -> b) -> [a] -> MVar () -> Eval [b]
parMap' f [] _ = return []
parMap' f (a:as) signal = do
sig <- return (tryReadMVar signal)
return (if (sig /= Nothing) then [] else let b = runEval (rpar (force_eval (f a)))
bs = runEval (parMap' f as signal)
in (b : bs))
{-|
b <- rpar (force_eval (f a))
bs <- parMap' f as
bs <- parMap' f as signal
return (b : bs)


-- Simple parallel solver
-}
solver_par :: (Int -> Int) -> [Int] -> MVar () -> MVar [(Int, Int)] -> Int -> IO ()
solver_par hash _ signal box schedulers = do
let num = schedulers*schedulers*4
output <- runEvalIO (parMap' (hashes_of_range hash) (ranges num num 0 (round(2**27-1))))
let flat_output = concat output -- A list of tuples: (output, input), one for each possible input
output <- runEvalIO (parMap' (hashes_of_range hash) (ranges num num 0 (round(2**27-1))) signal)
let flat_output = concat output
_ <- readMVar signal
_ <- putMVar box (flat_output)
return ()
136 changes: 0 additions & 136 deletions ex1/.ipynb_checkpoints/solution-checkpoint.ipynb

This file was deleted.

6 changes: 0 additions & 6 deletions ex1/small_input.txt.txt

This file was deleted.

Empty file removed ex1/small_output.txt.txt
Empty file.

0 comments on commit 46beb6c

Please sign in to comment.