aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2019-01-22 19:01:44 +0000
committerYann Herklotz <ymherklotz@gmail.com>2019-01-22 19:01:44 +0000
commit0636119cb5faf8e55a4a17bb00d15d6710679c35 (patch)
tree7524e2a67a514eefcab588ac09f3c2c527c7efee /app
parent125388a9fa696e354961545887f07633f06b3107 (diff)
downloadverismith-0636119cb5faf8e55a4a17bb00d15d6710679c35.tar.gz
verismith-0636119cb5faf8e55a4a17bb00d15d6710679c35.zip
Better multithreading
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 76fe45c..aeda6a6 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -13,6 +13,12 @@ import Shelly
import qualified Test.QuickCheck as QC
import VeriFuzz
+myForkIO :: IO () -> IO (MVar ())
+myForkIO io = do
+ mvar <- newEmptyMVar
+ _ <- forkFinally io (\_ -> putMVar mvar ())
+ return mvar
+
genRand :: C.CtrDRBG -> Int -> [ByteString] -> [ByteString]
genRand gen n bytes | n == 0 = ranBytes : bytes
| otherwise = genRand newGen (n - 1) $ ranBytes : bytes
@@ -57,14 +63,14 @@ runEquivalence t i = do
cd (fromText "equiv" </> fromText n)
catch_sh (runEquiv defaultYosys defaultYosys (Just defaultXst) circ) $ onFailure n
cd ".."
- runEquivalence t $ i+1
+ --runEquivalence t $ i+1
where
n = t <> "_" <> T.pack (show i)
main :: IO ()
--main = sample (arbitrary :: Gen (Circuit Input))
main = do
- _ <- forkIO $ runEquivalence "test_1" 0
- _ <- forkIO $ runEquivalence "test_2" 0
- _ <- forkIO $ runEquivalence "test_3" 0
- runEquivalence "test_4" 0
+ num <- getNumCapabilities
+ vars <- sequence $ (\x -> myForkIO $
+ runEquivalence ("test_" <> T.pack (show x)) 0) <$> [1..num]
+ sequence_ $ takeMVar <$> vars