From 5fea8f22f379713f0af748eb04a957ff6a9d6bfa Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Sat, 14 Oct 2023 12:20:36 +0200 Subject: utilize all processors --- app/Parallel.hs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 app/Parallel.hs (limited to 'app/Parallel.hs') diff --git a/app/Parallel.hs b/app/Parallel.hs new file mode 100644 index 0000000..0b57545 --- /dev/null +++ b/app/Parallel.hs @@ -0,0 +1,9 @@ +module Parallel (parMapM) where + +import Control.Concurrent.ParallelIO.Local (parallel, withPool) +import GHC.Conc (getNumProcessors) + +parMapM :: (a -> IO b) -> [a] -> IO [b] +parMapM f xs = do + n <- getNumProcessors + withPool n $ \pool -> parallel pool (map f xs) -- cgit v1.2.3