[project @ 2001-06-28 14:15:04 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/core/LICENSE)
6 --
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
10 --
11 -- $Id: Parallel.hs,v 1.1 2001/06/28 14:15:01 simonmar Exp $
12 --
13 -- Parallel Constructs
14 --
15 -----------------------------------------------------------------------------
16
17 module Control.Parallel (
18 par, seq -- re-exported
19 #if defined(__GRANSIM__)
20 , parGlobal, parLocal, parAt, parAtAbs, parAtRel, parAtForNow
21 #endif
22 ) where
23
24 import Prelude
25
26 #ifdef __GLASGOW_HASKELL__
27 import GHC.Conc ( par )
28 #endif
29
30 #if defined(__GRANSIM__)
31 import PrelBase
32 import PrelErr ( parError )
33 import PrelGHC ( parGlobal#, parLocal#, parAt#, parAtAbs#, parAtRel#, parAtForNow# )
34
35 {-# INLINE parGlobal #-}
36 {-# INLINE parLocal #-}
37 {-# INLINE parAt #-}
38 {-# INLINE parAtAbs #-}
39 {-# INLINE parAtRel #-}
40 {-# INLINE parAtForNow #-}
41 parGlobal :: Int -> Int -> Int -> Int -> a -> b -> b
42 parLocal :: Int -> Int -> Int -> Int -> a -> b -> b
43 parAt :: Int -> Int -> Int -> Int -> a -> b -> c -> c
44 parAtAbs :: Int -> Int -> Int -> Int -> Int -> a -> b -> b
45 parAtRel :: Int -> Int -> Int -> Int -> Int -> a -> b -> b
46 parAtForNow :: Int -> Int -> Int -> Int -> a -> b -> c -> c
47
48 parGlobal (I# w) (I# g) (I# s) (I# p) x y = case (parGlobal# x w g s p y) of { 0# -> parError; _ -> y }
49 parLocal (I# w) (I# g) (I# s) (I# p) x y = case (parLocal# x w g s p y) of { 0# -> parError; _ -> y }
50
51 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 }
52 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 }
53 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 }
54 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 }
55
56 #endif
57
58 -- Maybe parIO and the like could be added here later.
59 #ifndef __GLASGOW_HASKELL__
60 -- For now, Hugs does not support par properly.
61 par a b = b
62 #endif