Update vectoriser now that PData has moved.
authorBen Lippmeier <benl@ouroborus.net>
Thu, 5 May 2011 03:59:00 +0000 (13:59 +1000)
committerBen Lippmeier <benl@ouroborus.net>
Thu, 12 May 2011 10:36:21 +0000 (20:36 +1000)
compiler/vectorise/Vectorise/Builtins/Initialise.hs
compiler/vectorise/Vectorise/Builtins/Modules.hs

index ecb8a98..5f4735c 100644 (file)
@@ -40,20 +40,29 @@ initBuiltins
 initBuiltins pkg
  = do mapM_ load dph_Orphans
 
+      -- From dph-common:Data.Array.Parallel.PArray.PData
+      --   PData is a type family that maps an element type onto the type
+      --   we use to hold an array of those elements.
+      pdataTyCon       <- externalTyCon        dph_PData       (fsLit "PData")
+
+      --   PR is a type class that holds the primitive operators we can 
+      --   apply to array data. Its functions take arrays in terms of PData types.
+      prClass           <- externalClass        dph_PData      (fsLit "PR")
+      let prTyCon     = classTyCon prClass
+          [prDataCon] = tyConDataCons prTyCon
+
       -- From dph-common:Data.Array.Parallel.Lifted.PArray
+      --   A PArray (Parallel Array) holds the array length and some array elements
+      --   represented by the PData type family.
       parrayTyCon      <- externalTyCon        dph_PArray      (fsLit "PArray")
       let [parrayDataCon] = tyConDataCons parrayTyCon
 
-      pdataTyCon       <- externalTyCon        dph_PArray      (fsLit "PData")
       paClass           <- externalClass        dph_PArray      (fsLit "PA")
       let paTyCon     = classTyCon paClass
           [paDataCon] = tyConDataCons paTyCon
           paPRSel     = classSCSelId paClass 0
 
       preprTyCon       <- externalTyCon        dph_PArray      (fsLit "PRepr")
-      prClass           <- externalClass        dph_PArray      (fsLit "PR")
-      let prTyCon     = classTyCon prClass
-          [prDataCon] = tyConDataCons prTyCon
 
       closureTyCon     <- externalTyCon dph_Closure            (fsLit ":->")
 
@@ -162,13 +171,17 @@ initBuiltins pkg
                , liftingContext   = liftingContext
                }
   where
-    mods@(Modules {
-               dph_PArray         = dph_PArray
-             , dph_Repr           = dph_Repr
-             , dph_Closure        = dph_Closure
-             , dph_Scalar         = dph_Scalar
-             , dph_Unboxed        = dph_Unboxed
-             })
+    -- Extract out all the modules we'll use.
+    -- These are the modules from the DPH base library that contain
+    --  the primitive array types and functions that vectorised code uses.
+    mods@(Modules 
+                { dph_PArray    = dph_PArray
+                , dph_PData     = dph_PData
+                , dph_Repr      = dph_Repr
+                , dph_Closure   = dph_Closure
+                , dph_Scalar    = dph_Scalar
+                , dph_Unboxed   = dph_Unboxed
+                })
       = dph_Modules pkg
 
     load get_mod = dsLoadModule doc mod
@@ -254,7 +267,7 @@ initBuiltinPAs (Builtins { dphModules = mods }) insts
 -- | Get the names of all builtin instance functions for the PR class.
 initBuiltinPRs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]
 initBuiltinPRs (Builtins { dphModules = mods }) insts
-  = liftM (initBuiltinDicts insts) (externalClass (dph_PArray mods) (fsLit "PR"))
+  = liftM (initBuiltinDicts insts) (externalClass (dph_PData mods) (fsLit "PR"))
 
 
 -- | Get the names of all DPH instance functions for this class.
index d5b10cb..275f271 100644 (file)
@@ -18,6 +18,7 @@ data Modules
         , dph_Instances                :: Module
         , dph_Combinators      :: Module
         , dph_Scalar           :: Module
+        , dph_PData             :: Module
         , dph_Prelude_PArr     :: Module
         , dph_Prelude_Int      :: Module
         , dph_Prelude_Word8    :: Module
@@ -39,6 +40,8 @@ dph_Modules pkg
        , dph_Combinators    = mk (fsLit "Data.Array.Parallel.Lifted.Combinators")
        , dph_Scalar         = mk (fsLit "Data.Array.Parallel.Lifted.Scalar")
 
+        , dph_PData          = mk (fsLit "Data.Array.Parallel.PArray.PData")
+
        , dph_Prelude_PArr   = mk (fsLit "Data.Array.Parallel.Prelude.Base.PArr")
        , dph_Prelude_Int    = mk (fsLit "Data.Array.Parallel.Prelude.Base.Int")
        , dph_Prelude_Word8  = mk (fsLit "Data.Array.Parallel.Prelude.Base.Word8")