1 -----------------------------------------------------------------------------
3 -- Module : Control.Parallel
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/core/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
11 -- $Id: Parallel.hs,v 1.1 2001/06/28 14:15:01 simonmar Exp $
13 -- Parallel Constructs
15 -----------------------------------------------------------------------------
17 module Control.Parallel (
18 par, seq -- re-exported
19 #if defined(__GRANSIM__)
20 , parGlobal, parLocal, parAt, parAtAbs, parAtRel, parAtForNow
26 #ifdef __GLASGOW_HASKELL__
27 import GHC.Conc ( par )
30 #if defined(__GRANSIM__)
32 import PrelErr ( parError )
33 import PrelGHC ( parGlobal#, parLocal#, parAt#, parAtAbs#, parAtRel#, parAtForNow# )
35 {-# INLINE parGlobal #-}
36 {-# INLINE parLocal #-}
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
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 }
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 }
58 -- Maybe parIO and the like could be added here later.
59 #ifndef __GLASGOW_HASKELL__
60 -- For now, Hugs does not support par properly.