1 -----------------------------------------------------------------------------
3 -- Module : Control.Parallel
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
11 -- Parallel Constructs
13 -----------------------------------------------------------------------------
15 module Control.Parallel (
16 par, seq -- re-exported
17 #if defined(__GRANSIM__)
18 , parGlobal, parLocal, parAt, parAtAbs, parAtRel, parAtForNow
24 #ifdef __GLASGOW_HASKELL__
25 import GHC.Conc ( par )
28 #if defined(__GRANSIM__)
30 import PrelErr ( parError )
31 import PrelGHC ( parGlobal#, parLocal#, parAt#, parAtAbs#, parAtRel#, parAtForNow# )
33 {-# INLINE parGlobal #-}
34 {-# INLINE parLocal #-}
36 {-# INLINE parAtAbs #-}
37 {-# INLINE parAtRel #-}
38 {-# INLINE parAtForNow #-}
39 parGlobal :: Int -> Int -> Int -> Int -> a -> b -> b
40 parLocal :: Int -> Int -> Int -> Int -> a -> b -> b
41 parAt :: Int -> Int -> Int -> Int -> a -> b -> c -> c
42 parAtAbs :: Int -> Int -> Int -> Int -> Int -> a -> b -> b
43 parAtRel :: Int -> Int -> Int -> Int -> Int -> a -> b -> b
44 parAtForNow :: Int -> Int -> Int -> Int -> a -> b -> c -> c
46 parGlobal (I# w) (I# g) (I# s) (I# p) x y = case (parGlobal# x w g s p y) of { 0# -> parError; _ -> y }
47 parLocal (I# w) (I# g) (I# s) (I# p) x y = case (parLocal# x w g s p y) of { 0# -> parError; _ -> y }
49 parAt (I# w) (I# g) (I# s) (I# p) v x y = case (parAt# x v w g s p y) of { 0# -> parError; _ -> y }
50 parAtAbs (I# w) (I# g) (I# s) (I# p) (I# q) x y = case (parAtAbs# x q w g s p y) of { 0# -> parError; _ -> y }
51 parAtRel (I# w) (I# g) (I# s) (I# p) (I# q) x y = case (parAtRel# x q w g s p y) of { 0# -> parError; _ -> y }
52 parAtForNow (I# w) (I# g) (I# s) (I# p) v x y = case (parAtForNow# x v w g s p y) of { 0# -> parError; _ -> y }
56 -- Maybe parIO and the like could be added here later.
57 #ifndef __GLASGOW_HASKELL__
58 -- For now, Hugs does not support par properly.