[project @ 2005-04-04 08:02:53 by simonmar]
[packages/old-time.git] / Control / Parallel.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module : Control.Parallel
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
6 --
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
10 --
11 -- Parallel Constructs
12 --
13 -----------------------------------------------------------------------------
14
15 module Control.Parallel (
16 par, seq -- re-exported
17 #if defined(__GRANSIM__)
18 , parGlobal, parLocal, parAt, parAtAbs, parAtRel, parAtForNow
19 #endif
20 ) where
21
22 import Prelude
23
24 #ifdef __GLASGOW_HASKELL__
25 import GHC.Conc ( par )
26 #endif
27
28 #if defined(__GRANSIM__)
29 import PrelBase
30 import PrelErr ( parError )
31 import PrelGHC ( parGlobal#, parLocal#, parAt#, parAtAbs#, parAtRel#, parAtForNow# )
32
33 {-# INLINE parGlobal #-}
34 {-# INLINE parLocal #-}
35 {-# INLINE parAt #-}
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
45
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 }
48
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 }
53
54 #endif
55
56 -- Maybe parIO and the like could be added here later.
57 #ifndef __GLASGOW_HASKELL__
58 -- For now, Hugs does not support par properly.
59 par a b = b
60 #endif