Changes between Version 14 and Version 15 of DataParallel/Vectorisation
 Timestamp:
 May 29, 2007 7:23:50 AM (7 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

DataParallel/Vectorisation
v14 v15 54 54 {{{ 55 55 data fS : fP = !fS : !fP 56 vfunS (fS : _ ) = fS57 vfunP (_ : fP) = fP56 funS (fS : _ ) = fS 57 funP (_ : fP) = fP 58 58 }}} 59 59 On top of this we define a vectorised function space constructor: 60 60 {{{ 61 newtype a :> b = Fun ((a > b) : (PArr a > PArr b))62 funS (Fun (fS : _ )) = fS63 funP (Fun (_ : fP)) = fP61 newtype a :> b = VFun ((a > b) : (PArr a > PArr b)) 62 vfunS (VFun (fS : _ )) = fS 63 vfunP (VFun (_ : fP)) = fP 64 64 }}} 65 65 So, we have `(>_v) = (:>)`. Note that the type arguments to `(:>)` will be vectorised types (not vanilla types). Consequently, instances of `PA` and `PArr` need to be defined for vectorised types. … … 72 72 ==== Lifted functions ==== 73 73 74 In lifted code, we represent functions by explicit closures combining scalar and lifted versions. We do so using ''array closures'':74 In lifted code, we also use `(:)` to represent pairs of scalar and lifted functions, but here the second component is an array closure; thusly: 75 75 {{{ 76 data a =>> b 77 = forall e. PA e => 78 ACls { aclsFun :: !(e > a > b) 79 , aclsAFun :: !(PArr e > PArr a > PArr b) 80 , aclsEnv :: PArr e 81 } 76 newtype a :=> b = LFun ((a > b) : ACls (PArr a) (PArr b)) 77 78 data ACls arr brr 79 = forall e. PA e => 80 ACls { aclsFun :: !(PArr e > arr > brr) 81 , aclsEnv :: PArr e 82 } 83 84 lfunS (LFun (fS : _ )) = fS 85 lfunP (LFun (_ : ACls fP e)) = fP e 82 86 }}} 83 We apply array closures using 84 {{{ 85 ($) :: (a :=> b) > PArr a > PArr b 86 (ACls _ afun es) $:: as = afun es as 87 }}} 87 88 The following questions may arise: 89 * Why do we use array types as arguments of `ACls`, rather than array element types? Answer: We need this to be able to handle functions manipulating unboxed values. For example, consider a `inc# :: Int# > Int#`. What's the type of an array closure for `inc#`? Given the current definition, we can denote the type as `ACls (UArr Int) (UArr Int)` (as `Int#* = UArr Int`). In contrast, we would get a kind error if `ACls` would take element types and we'd use `ACls Int# Int#`. 88 90 89 91