Changes between Version 29 and Version 30 of DataParallel/VectPragma


Ignore:
Timestamp:
Oct 10, 2011 4:28:05 AM (3 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/VectPragma

    v29 v30  
    6767{-# VECTORISE type T #-} 
    6868}}} 
    69 indicates that the type `T` should be vectorised and embeds no parallel arrays.  This is the same as where the vectoriser automatically decides to vectorise a type, but no special vectorised representation needs to be generated as the type embeds no arrays.  The purpose of this pragma is to enable the vectorisation of imported types from modules that where not compiled with vectorisation enabled. 
    70  
    71 The data type constructor `T` that together with its constructors `Cn` may be used in vectorised code, where `T` and the `Cn` represent themselves in vectorised code. An example is the treatment of 'Bool'.  'Bool' together with 'False' and 'True' may appear in vectorised code and they remain unchanged by vectorisation.  (There is no need for a special representation as the values cannot embed any arrays.) 
     69indicates that the type `T` should be automatically vectorised even if it is imported.  This is the default for all data types declared in the current module. If the type embeds no parallel arrays, no special vectorised representation will be generated.  
    7270 
    7371The type constructor `T` must be in scope, but it may be imported.  'PData' and 'PRepr' instances are automatically generated by the vectoriser. 
    7472 
    75 '''ALTERNATIVE:''' This pragma simply means to treat an imported tycon as if it was defined in this module (and is automatically vectorised as usual).  This is what I just implemented. 
    76  
    77 '''OPEN QUESTION:''' 
    78  * Do we need to be able to specify that an imported type embedding arrays should be vectorised including the generation of a specialised right-hand side? 
     73Examples are the vectorisation of types, such as `Ordering` and `[]`, defined in the `Prelude`. 
    7974 
    8075=== With right-hand side === 
    8176 
     77For a type constructor `T`, the pragma 
    8278{{{ 
    8379{-# VECTORISE type T = T' #-} 
    8480}}} 
     81directs the vectoriser to replace `T` by `T'` in vectorised code and to use the corresponding data constructors of `T'` instead of those of `T`.  This implies that the two type constructors must be of the same kind and that the data constructors of `T` and `T'` need to be of the same number and type.  
    8582 
    86 '''TODO:''' 
    87  * This isn't fully implemented yet.  (Implemented up to and including desugaring and being put into `ModGuts`, but not used in the vectoriser.) 
     83The type constructor `T` must be in scope, but it may be imported.  'PData' and 'PRepr' instances must be explicitly defined — they are not automatically generated. 
     84 
     85An example is the handling of `Bool`, where we represent `Bool` by itself in vectorised code, but want to use the custom instances of 'PData' and 'PRepr' defined in the DPH libraries. 
    8886 
    8987== The VECTORISE SCALAR pragma for type constructors == 
     
    9997The type constructor `T` must be in scope, but it may be imported.  The `PData` and `PRepr` instances for `T` need to be manually defined.  (For types that the vectoriser automatically determines that they don't need a vectorised version, instances for `PData` and `PRepr` are still generated automatically.) 
    10098 
    101 NB: The crucial difference between `{-# VECTORISE type T1 #-}` and `{-# VECTORISE SCALAR type T2 #-}` is that the *representation* (i.e., the constructors) of the latter can only be used in scalar code. However, the representation of both `T1` and `T2` does not get vectorised — so, both types are suitable for code that does not get vectorised due to vectorisation avoidance. 
     99NB: The crucial difference between `{-# VECTORISE SCALAR type T1 #-}` and `{-# VECTORISE type T2 #-}`, where `T2` embeds no parallel arrays, is that the *representation* (i.e., the constructors) of the former can only be used in scalar code. However, neither the representation of `T1` nor `T2` does get vectorised — so, both types are suitable for code that does not get vectorised due to vectorisation avoidance. 
    102100 
    103101'''TODO:'''