dph-prim-par: parallel extracts, extra strictness
authorAmos Robinson <amos.robinson@gmail.com>
Mon, 27 Aug 2012 02:02:48 +0000 (12:02 +1000)
committerAmos Robinson <amos.robinson@gmail.com>
Mon, 27 Aug 2012 02:02:48 +0000 (12:02 +1000)
dph-prim-par/Data/Array/Parallel/Unlifted/Distributed/Primitive/Gang.hs
dph-prim-par/Data/Array/Parallel/Unlifted/Parallel/Extracts.hs
dph-prim-seq/Data/Array/Parallel/Unlifted/Stream/Segments.hs

index 6538171..65f6ba2 100644 (file)
@@ -207,7 +207,7 @@ gangIO (Gang n mvs busy) what workload p
                 isBusy          <- swapMVar busy True
                 if isBusy 
                  then do 
-                        traceGang $ "WARNING: Gang was already busy, running sequentially "
+                        traceGang $ "WARNING: Gang was already busy, running sequentially: " ++ what
                         mapM_ p [0 .. n-1]
                  else do
                         traceGangSplit $ "Issuing  par   " ++ what
index 6d64265..b0149d7 100644 (file)
@@ -120,27 +120,19 @@ extractsFromVectorsUPVSegdP
         -> Vectors a
         -> Vector a
 
-extractsFromVectorsUPVSegdP upvsegd vectors
- = joinD theGang balanced
- $ mapD what
+extractsFromVectorsUPVSegdP !upvsegd !vectors
+ = let !segs    = UPVSegd.takeDistributed       upvsegd
+       !vsegids = UPVSegd.takeVSegidsRedundant  upvsegd
+       !ussegd  = UPSSegd.takeUSSegd
+                $ UPVSegd.takeUPSSegdRedundant  upvsegd
+   in joinD theGang balanced
+    $ mapD (What "extractsFromVectorsUPVSegdP")
         theGang
         (extractsFromVectorsUPSSegd_split
                 ussegd
                 vsegids
                 vectors)
         segs
- where  what
-         = let  lens    = UPVSegd.takeLengths upvsegd
-           in   (What $ "dph-prim-par: extractsFromVectorsUPVSegdP." 
-                      P.++ show lens)
-        {-# NOINLINE what #-}
-
-        segs    = UPVSegd.takeDistributed upvsegd
-        {-# INLINE segs #-}
-
-        vsegids = UPVSegd.takeVSegidsRedundant upvsegd
-        ussegd  = UPSSegd.takeUSSegd 
-                $ UPVSegd.takeUPSSegdRedundant upvsegd
 
 {-# INLINE_UP extractsFromVectorsUPVSegdP #-}
 
@@ -153,7 +145,7 @@ extractsFromVectorsUPSSegd_split
         -> ((USegd.USegd,Int),Int)
         -> Vector a
 
-extractsFromVectorsUPSSegd_split ussegd vsegids vectors which
+extractsFromVectorsUPSSegd_split !ussegd !vsegids !vectors !which
         = Seq.unstream 
         $ US.streamSegsFromVectorsUSSegd_split vectors
                 ussegd vsegids which
index 85f17ce..0656562 100644 (file)
@@ -248,8 +248,8 @@ streamSegsFromVectorsUSSegd_split
         -> Stream m a
 
 streamSegsFromVectorsUSSegd_split
-        vectors (USSegd _ !segStarts !segSources _)
-        vsegids ((!segd,!seg_off),!el_off)
+        !vectors !ussegd
+        !vsegids ((!segd,!seg_off),!el_off)
  = let  here            = "streamSegsFromVectorsUSSegd_split"
 
         -- Total number of elements to be streamed
@@ -259,6 +259,18 @@ streamSegsFromVectorsUSSegd_split
         -- Total number of segments.
         !segsTotal      = U.length lengths
 
+        !segStarts      = USSegd.takeStarts  ussegd
+        !segSources     = USSegd.takeSources ussegd
+
+        vsegid seg      = index here vsegids    (seg + seg_off)
+        {-# INLINE vsegid #-}
+        source pseg     = index here segSources  pseg
+        {-# INLINE source #-}
+        start  pseg     = index here segStarts   pseg
+        {-# INLINE start #-}
+        len    seg      = index here lengths     seg
+        {-# INLINE len #-}
+
         -- seg, ix of that seg in usegd, length of seg, elem in seg
         {-# INLINE_INNER fnSeg #-}
         fnSeg (!ixSeg, !baSeg, !ixEnd, !ixElem)
@@ -270,10 +282,10 @@ streamSegsFromVectorsUSSegd_split
 
                   -- Move to the next seg.
                   else let ixSeg'       = ixSeg + 1
-                           ixPSeg       = index here vsegids (ixSeg' + seg_off)
-                           sourceSeg    = index here segSources ixPSeg
-                           startSeg     = index here segStarts  ixPSeg
-                           lenSeg       = index here lengths    ixSeg'
+                           ixPSeg       = vsegid ixSeg'
+                           sourceSeg    = source ixPSeg
+                           startSeg     = start  ixPSeg
+                           lenSeg       = len    ixSeg'
                            el_off'      = if ixSeg' == 0 then el_off else 0
                            (arr, startArr, _) 
                                         = US.unsafeIndexUnpack vectors sourceSeg