Changes between Version 4 and Version 5 of DataParallel/Library


Ignore:
Timestamp:
Feb 11, 2011 3:50:59 AM (3 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/Library

    v4 v5  
    77DPH comes with the following blobs of source code: 
    88 
    9   * `dph/dph-prim-seq` implements the DPH Primitive Interface for sequential machines.  Compiling it yields package `dph-prim-seq`. 
     9  * `dph/dph-prim-seq` implements the DPH Primitive Interface for sequential machines.  Compiling it yields package `dph-prim-seq`.  It depends on the packages `vector` and `primitive`. 
    1010 
    1111  * `dph/dph-prim-par` implements the DPH Primitive Interface for parallel machines.  Compiling it yields package `dph-prim-seq`. 
     
    2121== How the DPH packages are coupled to GHC == 
    2222 
    23 GHC knows about DPH as follows.  A single flag `-dph` switches on the following: 
     23GHC knows about DPH as follows. 
    2424 
    25   * Adds `-package dph` ('''SLPJ: correct?'''), so that the user can `import Data.Array.Parallel`.  And so that the right package gets linked in the link step. 
     25  * The flags `-fdph-seq` and `-fdph-par` add `-package dph-seq` and `-package-dph-par`, respectively, so that the user can `import Data.Array.Parallel` and friends.  And so that the right package gets linked in the link step. 
    2626 
    27   * Runs a special pass called the '''vectoriser'''.  This generates a close coupling between the vectoriser and the library: 
     27  * The flag `-fvectorise` runs a special pass called the '''vectoriser'''.  
    2828    * The vectoriser generates code that mentions (by Original Name) various functions defined in `dph-prim-seq` or `dph-prim-par` (depending on the compiler flag used).  So if you change where a function is defined in `dph-prim-*`, or the name of the function, you have to make a corresponding change in GHC. 
    2929    * The vectoriser knows quite a lot about the internal working of the library. For instance, it knows about the array representation. 
     
    3131 
    3232 
    33  
    3433'''SLPJ: is it correct that GHC only generates Names in dph-prim?  If not, could it be made true?''' 
    35  
    36 == DPH and ways == 
    37  
    38 When compiling a module with `-dph`, its imported modules must also have been compiled with `-dph`.  It's a bit like profiling; so maybe compiling with `-dph` should count as another "way".  This is an unresolved issue.  Compiling the entire `base` package (say) with `-dph` might well be overkill; for example, we don't want to vectorise the IO library. 
    39  
    40 At the moment, we finesse this problem by simply requiring that the user solves it; and hence we do not use any `base` package functions in vectorised code. 
    4134 
    4235== Array library of flat and segmented operations == 
    4336 
    44 '''TODO:''' Here we need to document the structure of the current implementation with subpages for the more complicated aspects (e.g., representation types, distributed types, and gangs). 
     37'''TODO:''' Here we need to document the structure of the current implementation with subpages for the more complicated aspects (e.g., representation types, distributed types, and gangs).  Here a dump of an old description of the library structure (which may be somewhat out of date): 
     38{{{ 
     39Data.Array.Parallel.Lifted 
     40        ... the final user types ... 
     41 
     42Data.Array.Parallel.Unlifted 
     43  Re-exports Data.Array.Parallel.Unlifted.Parallel 
     44             Data.Array.Parallel.Unlifted.Distributed 
     45             Data.Array.Parallel.Unlifted.Segmented 
     46             Data.Array.Parallel.Unlifted.Flat 
     47 
     48Data.Array.Parallel.Unlifted.Parallel 
     49  Parallel operations over UArrs.  No new data types! 
     50  These operations each 
     51        - convert the incoming (UArr t) to a Dist (UArr t) 
     52        - run the operation in parallel using a gang 
     53        - convert the result back to a (UArr t') 
     54  Plus fusion rules, of course! 
     55 
     56Data.Array.Parallel.Unlifted.Distributed 
     57  Logically: type Dist a = Array GangMember a 
     58        That is, one 'a' per gang member 
     59  Mutable version: MDist 
     60 
     61  Element types: unboxed, and products, (),  
     62                 *and* UArr, SUArr, Segd. 
     63  
     64Data.Array.Parallel.Unlifted.Segmented 
     65  Provides SUArr, which are segmented UArrs with exactly one nesting level 
     66  Logically: type SUArr a = UArr (UArr a) 
     67  Element types: unboxed, and products and (). 
     68 
     69  Again, a mutable version MSUArr is defined internally. 
     70 
     71Data.Array.Parallel.Unlifted.Flat 
     72  Provides immutable (UArr) arrays of unboxed 
     73  values, and strict products thereof. 
     74 
     75  Simply lifts BUArr to work over strict products (incl unit). 
     76  Internally to Flat, we also define mutable (MUArr) arrays,  
     77  but they aren't exported. 
     78 
     79        .UArr: representation 
     80        .Loop: main loop combinator over UArr, loopU 
     81        .Fusion: fusion rules for loopU 
     82        .Combinators: instantiate loopU (to get fold, scan, map etc) 
     83   
     84  The exported maps and folds over these arrays are  
     85  purely sequential 
     86 
     87Data.Array.Parallel.Arr.BUArr 
     88  Arrays of *unboxed* values, immutable (BUArr t) and mutable (MBUArr 
     89  t), indexed by Int.  Supports slicing (= sub-segment) operations. 
     90 
     91  ToDo: combine with UArray and STUArray? (But they are indexed by Ix.) 
     92 
     93  ToDo: a common pattern (e.g. when filtering) is that we allocate a 
     94  big mutable array, *partially* fill it, and then want to shrink to 
     95  fixed size when freezing it. (This is needed in Don's ByteString 
     96  library too.) 
     97 
     98 
     99Data.Array.Parallel.Base.Fusion 
     100  Specialised combining functions that specialise loopU to be map, fold, etc 
     101  They are also useful for loopBU; hence not in Unlifted.Flat 
     102   
     103Data.Array.Parallel.Arr.BBArr 
     104  Similar to BUArr, but for strict, boxed values.   
     105  Representation: Array, STArray. 
     106  Main application: array of UArrs in Distibuted.Types 
     107}}}