repa-3.4.0.1: High performance, regular, shape polymorphic parallel arrays.

Safe HaskellNone
LanguageHaskell98

Data.Array.Repa.Eval.Gang

Description

Gang Primitives.

Synopsis

Documentation

theGang :: Gang Source

This globally shared gang is auto-initialised at startup and shared by all Repa computations.

In a data parallel setting, it does not help to have multiple gangs running at the same time. This is because a single data parallel computation should already be able to keep all threads busy. If we had multiple gangs running at the same time, then the system as a whole would run slower as the gangs would contend for cache and thrash the scheduler.

If, due to laziness or otherwise, you try to start multiple parallel Repa computations at the same time, then you will get the following warning on stderr at runtime:

Data.Array.Repa: Performing nested parallel computation sequentially.
    You've probably called the compute or copy function while another
    instance was already running. This can happen if the second version
    was suspended due to lazy evaluation. Use deepSeqArray to ensure that
    each array is fully evaluated before you compute the next one.

data Gang Source

A Gang is a group of threads that execute arbitrary work requests.

Instances

forkGang :: Int -> IO Gang Source

Fork a Gang with the given number of threads (at least 1).

gangSize :: Gang -> Int Source

O(1). Yield the number of threads in the Gang.

gangIO :: Gang -> (Int -> IO ()) -> IO () Source

Issue work requests for the Gang and wait until they complete.

If the gang is already busy then print a warning to stderr and just run the actions sequentially in the requesting thread.

gangST :: Gang -> (Int -> ST s ()) -> ST s () Source

Same as gangIO but in the ST monad.