Changes between Version 14 and Version 15 of DataParallel/Vectorisation


Ignore:
Timestamp:
May 29, 2007 7:23:50 AM (8 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/Vectorisation

    v14 v15  
    5454{{{
    5555data fS :|| fP = !fS :|| !fP
    56 vfunS (fS :|| _ ) = fS
    57 vfunP (_  :|| fP) = fP
     56funS (fS :|| _ ) = fS
     57funP (_  :|| fP) = fP
    5858}}}
    5959On top of this we define a vectorised function space constructor:
    6060{{{
    61 newtype a :-> b = Fun ((a -> b) :|| (PArr a -> PArr b))
    62 funS (Fun (fS :|| _ )) = fS
    63 funP (Fun (_  :|| fP)) = fP
     61newtype a :-> b = VFun ((a -> b) :|| (PArr a -> PArr b))
     62vfunS (VFun (fS :|| _ )) = fS
     63vfunP (VFun (_  :|| fP)) = fP
    6464}}}
    6565So, 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.
     
    7272==== Lifted functions ====
    7373
    74 In lifted code, we represent functions by explicit closures combining scalar and lifted versions.  We do so using ''array closures'':
     74In lifted code, we also use `(:||)` to represent pairs of scalar and lifted functions, but here the second component is an array closure; thusly:
    7575{{{
    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            }
     76newtype a :=> b = LFun ((a -> b) :|| ACls (PArr a) (PArr b))
     77
     78data ACls arr brr
     79 = forall e. PA e =>
     80     ACls { aclsFun :: !(PArr e -> arr -> brr)
     81          , aclsEnv :: PArr e
     82          }
     83
     84lfunS (LFun (fS :|| _        )) = fS
     85lfunP (LFun (_  :|| ACls fP e)) = fP e
    8286}}}
    83 We apply array closures using
    84 {{{
    85 ($||) :: (a :=> b) -> PArr a -> PArr b
    86 (ACls _ afun es) $:: as = afun es as
    87 }}}
     87
     88The 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#`.
    8890
    8991