Changes between Version 1 and Version 2 of DataParallel/Vectorisation

May 23, 2007 3:46:40 AM (10 years ago)



  • DataParallel/Vectorisation

    v1 v2  
    13== Vectorisation ==
    2022Let us assume that the functions `getArgs`, `print`, and `read` are defined in modules that have not been vectorised.  When vectorising `main`, we want to use the vectorised versions of the functions `sumP`, `mapP` (implied by the comprehension), and `enumFromToP` (implied by the array constructor).  However, all the rest of the code will remain largely unchanged.  (What ''largely unchanged'' means precisely, we still have to define.)  In fact, there will be two versions of `main`.  The original `main` function that, according to our policy, does not use any vectorised code and `main_v` that has all the array code properly vectorised and all the enclosing `IO` code largely unchanged.  In order to make use of vectorisation, the runtime system will have to invoke `main_v`, not `main`.  Moreover, the code calling `main_v` will have to first set up the thread gang and whatever other extra initialisation is needed.  Whether to execute `main` or `main_v` on program start up should probably be determined by whether the `-fvect` option is present during linking or not.
     24=== Two array libraries ===
     26We have to different array libraries:
     27 1. The library in `GHC.PArr`, which defines the wired in array constructor `[:.:]`.  It implements `[:.:]` as a parametric data type represented by vanilla boxed arrays.  It does not involve any type class and also no indexed types.  This code is used whenever arrays are mentioned in unvectorised code (i.e., in both all code of unvectorised modules and in the original versions of functions in vectorised modules).
     28 2. The library in package ndp, which defines a type class `PA` and its associated data type `PArr`.   The type `PArr` implements a flattened array representation for all types `t` for which there is a `PA t` instance.
     29Vectorisation transforms all uses of functions from `GHC.PArr` into uses of package ndp.  It can obviously only due that for computations manipulating values for whose type we have `PA` instances.