Adapted test/simple/SegSum
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>
Fri, 24 Mar 2006 02:51:45 +0000 (02:51 +0000)
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Fri, 24 Mar 2006 02:51:45 +0000 (02:51 +0000)
  - GADTs aren't fully optimsed atm (see FIXME)

Data/Array/Parallel/test/simple/SegSum.hs
Data/Array/Parallel/test/simple/Sum.hs

index 29f8ed2..3ae465d 100644 (file)
 module SegSum
 where
 
-import PArray
+import Data.Array.Parallel.Unlifted
 
-test :: SPArr UInt Int -> PArr UInt Int
+test :: UArr (UArr Int) -> UArr Int
 test =   snd
        . loopArr
-       . loopSP (\a x -> (a + x::Int, Nothing::Maybe ())) 
+       . loopSU (\a x -> (a + x::Int, Nothing::Maybe ())) 
                (\a i -> (a, Just a)) 0
 
--- Need to recompute the following, as the definition changed.
 {- Inner loop:
+
+  FIXME: This is strange.  The case of `ds1_aJu' has a pattern match failure
+         __DEFAULT (as has the following case), but it shouldn't as the GADT
+         can really only have this one variant at the given type.
+
+     $wtrans_s19q :: GHC.Prim.Int#
+                    -> GHC.Prim.Int#
+                    -> GHC.Prim.Int#
+                    -> GHC.Prim.Int#
+                    -> GHC.Prim.Int#
+                    -> GHC.Prim.State# s_aLy
+                    -> (# GHC.Prim.State# s_aLy, (GHC.Base.Int, GHC.Base.Int) #)
+     [Arity 6
+      Str: DmdType LLLLLL]
+     $wtrans_s19q =
+       \ (ww_X19I :: GHC.Prim.Int#)
+        (ww1_X19N :: GHC.Prim.Int#)
+        (ww2_X19S :: GHC.Prim.Int#)
+        (ww3_X19X :: GHC.Prim.Int#)
+        (ww4_X1a2 :: GHC.Prim.Int#)
+        (w_X1a5 :: GHC.Prim.State# s_aLy) ->
+        case ww1_X19N of wild3_X1p {
+          __DEFAULT ->
+            case ds1_aJu of wild4_aTe {
+              __DEFAULT ->
+                __coerce (# GHC.Prim.State# s_aLy, (GHC.Base.Int, GHC.Base.Int) #) fail6_r1ae;
+              Data.Array.Parallel.Monadic.UArr.UAPrim ds11_aTd ->
+                case ds11_aTd of wild14_aTi {
+                  __DEFAULT ->
+                    __coerce (# GHC.Prim.State# s_aLy, (GHC.Base.Int, GHC.Base.Int) #)
+                    fail6_r1ae;
+                  Data.Array.Parallel.Base.Prim.PrimInt rb22_aTh rb13_aTj rb23_aTk ->
+                    $wtrans_s19q
+                      (GHC.Prim.+# ww_X19I 1)
+                      (GHC.Prim.-# wild3_X1p 1)
+                      ww2_X19S
+                      ww3_X19X
+                      (GHC.Prim.+#
+                         ww4_X1a2
+                         (GHC.Prim.indexIntArray# rb23_aTk (GHC.Prim.+# rb22_aTh ww_X19I)))
+                      w_X1a5
+                }
+            };
+          0 ->
+            let {
+              $w$j_X1aV :: GHC.Prim.State# s_aLy
+                           -> GHC.Prim.Int#
+                           -> GHC.Prim.Int#
+                           -> (# GHC.Prim.State# s_aLy, (GHC.Base.Int, GHC.Base.Int) #)
+              [Arity 3
+               Str: DmdType LLL]
+              $w$j_X1aV =
+                \ (w1_X19C :: GHC.Prim.State# s_aLy)
+                  (ww5_X1ba :: GHC.Prim.Int#)
+                  (ww6_X1bg :: GHC.Prim.Int#) ->
+                  let {
+                    a_X112 [Just L] :: GHC.Prim.Int#
+                    [Str: DmdType]
+                    a_X112 = GHC.Prim.+# ww2_X19S 1
+                  } in 
+                    case GHC.Prim.==# a_X112 wild13_B1 of wild31_XN8 {
+                      GHC.Base.False ->
+                        case a_X112 of wild4_X2J {
+                          __DEFAULT ->
+                            case GHC.Prim.readIntArray#
+                                   @ s_aLy rb31_aWu (GHC.Prim.-# wild4_X2J 1) w1_X19C
+                            of wild21_aX8 { (# s2#5_aXa, r#_aXb #) ->
+                            case GHC.Prim.readIntArray#
+                                   @ s_aLy rb12_aWs (GHC.Prim.-# wild4_X2J 1) s2#5_aXa
+                            of wild22_XZs { (# s2#6_XZv, r#1_XZx #) ->
+                            case GHC.Prim.writeIntArray#
+                                   @ s_aLy
+                                   rb31_aWu
+                                   wild4_X2J
+                                   (GHC.Prim.+# r#_aXb r#1_XZx)
+                                   s2#6_XZv
+                            of s2#7_XXe { __DEFAULT ->
+                            case GHC.Prim.writeIntArray# @ s_aLy rb12_aWs wild4_X2J 0 s2#7_XXe
+                            of s2#8_XZu { __DEFAULT ->
+                            $wtrans_s19q
+                              ww_X19I
+                              (GHC.Prim.indexIntArray# rb2_aJq (GHC.Prim.+# rb_aIN wild4_X2J))
+                              wild4_X2J
+                              ww5_X1ba
+                              ww6_X1bg
+                              s2#8_XZu
+                            }
+                            }
+                            }
+                            };
+                          0 ->
+                            case GHC.Prim.writeIntArray# @ s_aLy rb31_aWu 0 0 w1_X19C
+                            of s2#5_XX6 { __DEFAULT ->
+                            case GHC.Prim.writeIntArray# @ s_aLy rb12_aWs 0 0 s2#5_XX6
+                            of s2#6_XZm { __DEFAULT ->
+                            $wtrans_s19q
+                              ww_X19I
+                              (GHC.Prim.indexIntArray# rb2_aJq rb_aIN)
+                              0
+                              ww5_X1ba
+                              ww6_X1bg
+                              s2#6_XZm
+                            }
+                            }
+                        };
+                      GHC.Base.True ->
+                        (# w1_X19C, ((GHC.Base.I# ww5_X1ba), (GHC.Base.I# ww6_X1bg)) #)
+                    }
+            } in 
+              case ww2_X19S of wild4_X1P {
+                __DEFAULT ->
+                  case GHC.Prim.writeIntArray# @ s_aLy marr#2_XQe ww3_X19X ww4_X1a2 w_X1a5
+                  of s2#5_XWX { __DEFAULT ->
+                  $w$j_X1aV s2#5_XWX (GHC.Prim.+# ww3_X19X 1) ww4_X1a2
+                  };
+                (-1) -> $w$j_X1aV w_X1a5 ww3_X19X ww4_X1a2
+              }
+        };
+
+ --------------- OLD ------------------
+
    [This might look scary, but it seems to be about the optimal Core code
    possible for the performed computation.
 
index 11b0359..a1479ea 100644 (file)
@@ -1,38 +1,40 @@
 module Sum
 where
 
-import PArray
+import Data.Array.Parallel.Unlifted
 
-test :: PArrInt -> Int
-test = loopAcc . loopP (\a x -> (a + x, Nothing::Maybe ())) 0
+test :: UArr Int -> Int
+test = loopAcc . loopU (\a x -> (a + x, Nothing::Maybe ())) 0
 
 
 {- Inner loop:
 
-       $wtrans :: (GHC.Prim.Int#
-                   -> GHC.Base.Int
-                      -> GHC.Prim.Int#
-                         -> GHC.Prim.State# GHC.Prim.RealWorld
-                            -> (# GHC.Prim.State# GHC.Prim.RealWorld,
-                                  (GHC.Base.Int, GHC.Base.Int) #))
-       Arity 4 Just DmdType LS(A)LL
-       $wtrans
-         = \ ww2 :: GHC.Prim.Int#
-             w :: GHC.Base.Int
-             ww3 :: GHC.Prim.Int#
-             w1 :: (GHC.Prim.State# GHC.Prim.RealWorld) ->
-             case GHC.Prim.==# ww2 ww of wild {
-               GHC.Base.True ->
-                 case w of tpl { GHC.Base.I# a ->
-                 (# w1, ((GHC.Base.$wI# ww3), tpl) #)
-                 };
-               GHC.Base.False ->
-                 $wtrans
-                   (GHC.Prim.+# ww2 1)
-                   w
-                   (GHC.Prim.+# ww3 (GHC.Prim.indexIntArray# ww1 ww2))
-                   w1
-             };
-      } in 
+       poly_$wtrans_sPp :: forall s1_aIm.
+                           GHC.Prim.Int#
+                           -> GHC.Base.Int
+                           -> GHC.Prim.Int#
+                           -> GHC.Prim.State# s1_aIm
+                           -> (# GHC.Prim.State# s1_aIm, (GHC.Base.Int, GHC.Base.Int) #)
+       [Arity 4]
+       poly_$wtrans_sPp =
+         \ (@ s1_XJ3)
+           (ww_XPz :: GHC.Prim.Int#)
+           (w_XPC :: GHC.Base.Int)
+           (ww1_XPG :: GHC.Prim.Int#)
+           (w1_XPJ :: GHC.Prim.State# s1_XJ3) ->
+           case GHC.Prim.==# ww_XPz wild11_B1 of wild2_XHP {
+             GHC.Base.False ->
+               poly_$wtrans_sPp
+                 @ s1_XJ3
+                 (GHC.Prim.+# ww_XPz 1)
+                 w_XPC
+                 (GHC.Prim.+#
+                    ww1_XPG (GHC.Prim.indexIntArray# rb2_aPT (GHC.Prim.+# rb_aKA ww_XPz)))
+                 w1_XPJ;
+             GHC.Base.True ->
+               case w_XPC of tpl_aIu { GHC.Base.I# a1_aIv ->
+               (# w1_XPJ, ((GHC.Base.I# ww1_XPG), tpl_aIu) #)
+               }
+           };
 
 -}