massiv-0.1.2.0: Massiv (Массив) is an Array Library.

Copyright (c) Alexey Kuleshevich 2018 BSD3 Alexey Kuleshevich experimental non-portable None Haskell2010

Data.Massiv.Core.Scheduler

Description

Synopsis

# Documentation

Arguments

 :: Scheduler a Scheduler to use -> IO a Action to hand of to a worker -> IO ()

Helper function that allows scheduling work to be done in parallel. Use withScheduler to be able to get to a Scheduler.

Arguments

 :: [Int] Worker Stations, i.e. capabilities. Empty list will result in utilization of all available capabilities. -> (Scheduler a -> IO b) Action that will be scheduling all the work. -> IO (Int, Array a)

Run arbitrary computations in parallel. A pool of workers is initialized, unless Worker Stations list is empty and a global worker pool is currently available. All of those workers will be stealing work that you can schedule using scheduleWork. The order in which work is scheduled will be the same as the order of the resuts of those computations, stored withing the resulting array. Size of the array, which is also the first element in the returned tuple, will match the number of times scheduleWork has been invoked. This function blocks until all of the submitted jobs has finished or one of them resulted in an exception, which will be re-thrown here.

Important: In order to get work done truly in parallel, program needs to be compiled with -threaded GHC flag and executed with +RTS -N.

withScheduler' :: [Int] -> (Scheduler a -> IO b) -> IO [a] Source #

Just like withScheduler, but returns computed results in a list, instead of an array.

withScheduler_ :: [Int] -> (Scheduler a -> IO b) -> IO () Source #

Just like withScheduler, but discards the results.

Arguments

 :: Index ix => [Int] Worker Stations (capabilities) -> ix Size -> (Scheduler a -> Int -> Int -> Int -> IO b) Submit function -> IO [a]

Linearly (row-major first) and equally divide work among available workers. Submit function will receive a Scheduler, length of each chunk, total number of elements, as well as where chunks end and slack begins. Slack work will get picked up by the first worker, that has finished working on his chunk. Returns list with results in the same order that work was submitted

divideWork_ :: Index ix => [Int] -> ix -> (Scheduler a -> Int -> Int -> Int -> IO b) -> IO () Source #

Same as divideWork, but discard the result.