"=      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ A > is a group of threads which execute arbitrary work requests. A To get the gang to do work, write Req-uest valuesto its MVars The D type encapsulates work requests for individual members of a gang. Tell the worker that we'-re shutting the gang down. The worker should  signal that it'9s received the equest down by writing to the MVar before ( returning to its caller (forkGang) :Instruct the worker to run the given action then signal it's done  by writing to the MVar. (The gang is shared by all computations. +Create a new request for the given action. 0Block until a thread request has been executed. 3 NOTE: only one thread can wait for the request. "A sequential gang has no threads. The worker thread of a . > The threads blocks on the MVar waiting for a work request. Finaliser for worker threads. 7 We want to shutdown the corresponding thread when it's MVar becomes unreachable. 3 Without this Repa programs can complain about Blocked indefinitely on an MVar Z because worker threads are still blocked on the request MVars when the program ends. Y Whether the finalizer is called or not is very racey. It happens about 1 in 10 runs M when for the repa-edgedetect benchmark, and less often with the others. We'7re relying on the comment in System.Mem.Weak that says  If there are no other threads to run, the runtime system will check for runnable finalizers before declaring the system to be deadlocked. =If we were creating and destroying the gang cleanly we wouldn't need this, but theGang S is created with a top-level unsafePerformIO. Hacks beget hacks beget hacks... Fork a 0 with the given number of threads (at least 1). The number of threads in the . Issue work requests for the ) and wait until they have been executed. ? If the gang is already busy then just run the action in the  requesting thread. LTODO: We might want to print a configurable warning that this is happening. IIssue some requests to the worker threads and wait for them to complete. Number of threads in the gang. !Request vars for worker threads. $Action to run in all the workers, it's given the ix of " the particular worker thread it's running on. Same as  but in the  monad.  1Element types that can be stored in Repa arrays. CWe use this to prevent bindings from being floated inappropriatey.  Doing a  sometimes isn'+t enough, because the GHC simpplifier can  erase these, and/#or still move around the bindings. +Generic zero value, helpful for debugging. *Generic one value, helpful for debugging.  Fill a vector sequentially. Vector to fill. &Fn to get the value at a given index. Fill a vector in parallel. Vector to fill. &Fn to get the value at a given index.  vector to write elements into -fn to evaluate an element at the given index width of image. )Fill a block in a 2D image, in parallel. ; Coordinates given are of the filled edges of the block. I We divide the block into columns, and give one column to each thread. vector to write elements into .fn to evaluate an element at the given index. width of whole image &x0 lower left corner of block to fill y0 (low x and y value) x1 upper right corner of block ,y1 (high x and y value, last index to fill) Fill a block in a 2D image. ; Coordinates given are of the filled edges of the block. vector to write elements into. .fn to evaluate an element at the given index. width of whole image 'x0 lower left corner of block to fill y0 (low x and y value) x1 upper right corner of block ,y1 (high x and y value, last index to fill) =Class of types that can be used as array shapes and indices. )Get the number of dimensions in a shape. FThe shape of an array of size zero, with a particular dimensionality. GThe shape of an array with size one, with a particular dimensionality. (Compute the intersection of two shapes. 0Add the coordinates of two shapes componentwise >Get the total number of elements in an array with this shape. :Check whether this shape is small enough so that its flat  indices an be represented as . If this returns  then your = array is too big. Mostly used for writing QuickCheck tests. FConvert an index into its equivalent flat, linear, row-major version. Shape of the array. Index into the array.  Inverse of  . Shape of the array. "Index into linear representation. 0Check whether an index is within a given shape. Start index for range. Final index for range. Index to check for. -Convert a shape into its list of dimensions. (Convert a list of dimensions to a shape -Ensure that a shape is completely evaluated. 3Check whether an index is a part of a given shape. Shape of the array. Index.       2Our index type, used for both shapes and indices. An index of dimension zero     -Class of index types that can map to slices. :Map an index of a full shape onto an index of some slice. 9Map an index of a slice onto an index of the full shape. SMap the type of an index in the slice, to the type of the index in the full shape. !RMap a type of the index in the full shape, to the type of the index in the slice. "%Place holder for any possible shape. #$*Select all indices at a certain position. %  !"#$% $%"#!   !"##$%% &\Represents a convolution stencil that we can apply to array. Only statically known stencils  are supported right now. ':Static stencils are used when the coefficients are fixed,  and known at compile time. ()*+GHow to handle the case when the stencil lies partly outside the array. ,:Clamp points outside to the same value as the edge pixel. -1Treat points outside as having a constant value. .DMake a stencil from a function yielding coefficients at each index. Extent of stencil. #Get the coefficient at this index. / Wrapper for . that requires a DIM2 stencil. extent of stencil #Get the coefficient at this index. &'()*+,-./ &'()*'()*+-,,-./06QuasiQuoter for producing a static stencil defintion. A definition like    [stencil2| 0 1 0  1 0 1  0 1 0 |] Is converted to:   makeStencil2 (Z:.3:.3)  (\ix -> case ix of + Z :. -1 :. 0 -> Just 1 + Z :. 0 :. -1 -> Just 1 + Z :. 0 :. 1 -> Just 1 + Z :. 1 :. 0 -> Just 1 - _ -> Nothing) Parse a stencil definition.  TODO: make this more robust. 00)Fill a block in a 2D image, in parallel. ; Coordinates given are of the filled edges of the block. I We divide the block into columns, and give one column to each thread. vector to write elements into &make a cursor to a particular element shift the cursor by an offset .fn to evaluate an element at the given index. width of whole image &x0 lower left corner of block to fill y0 (low x and y value) 'x1 upper right corner of block to fill 4y1 (high x and y value, index of last elem to fill) Fill a block in a 2D image. ; Coordinates given are of the filled edges of the block. vector to write elements into. &make a cursor to a particular element shift the cursor by an offset .fn to evaluate an element at the given index. width of whole image 'x0 lower left corner of block to fill y0 (low x and y value) 'x1 upper right corner of block to fill 4y1 (high x and y value, index of last elem to fill) (1?Generates array elements for a particular region in the array. 27Elements can be computed using these cursor functions. 3'Make a cursor to a particular element. 4:Shift the cursor by an offset, to get to another element. 5Load/)compute the element at the given cursor. 6;Elements are already computed and sitting in this vector. 7 A rectangle/cube of arbitrary dimension. @ The indices are of the minimum and maximim elements to fill. 89-Represents a range of elements in the array. :4The union of a possibly disjoint set of rectangles. ;<=Covers the entire array. >-Defines the values in a region of the array. ?@.The range of elements this region applies to. A2How to compute the array elements in this region. BRepa arrays. CD The entire extent of the array. E0Arrays can be partitioned into several regions. F6Ensure the structure for an array is fully evaluated. . As we are in a lazy language, applying the force" function to a delayed array doesn't [ actually compute it at that point. Rather, Haskell builds a suspension representing the  appliction of the force function to that array. Use  deepSeqArray to ensure the array > is actually computed at a particular point in the program. GLike F$ but seqs all the arrays in a list. Z This is specialised up to lists of 4 arrays. Using more in the list will break fusion. 6Ensure the structure for a region is fully evaluated. ;Ensure the structure for some regions are fully evaluated. #Ensure a range is fully evaluated. Ensure a Generator' s structure is fully evaluated. H&Wrap a scalar into a singleton array. I.Take the scalar value from a singleton array. JTake the extent of an array. K#Unpack an array into delayed form. LM&Get an indexed element from an array. Q This uses the same level of bounds checking as your Data.Vector installation. NO&Get an indexed element from an array. ' If the element is out of range then . P?Get an indexed element from an array, without bounds checking. B This assumes that the regions in the array give full coverage. 9 An array with no regions gets zero for every element. Q Create a Delayed array from a function. R Create a Manifest array from an unboxed . & The elements are in row-major order. SConvert a list to an array. , The length of the list must be exactly the   of the extent given, else . $123456789:;<=>?@ABCDEFGHIJKLMNOPQRS$162345234567889=:;<:;<=>?@A?@ABCDECDEFGHIJKLMNOPQRSTConvert an array to an unboxed  Data.Vector, forcing it if required. + The elements come out in row-major order. U4Convert an array to a list, forcing it if required. V#Force an array, so that it becomes Manifest. O The array is split into linear chunks and each chunk evaluated in parallel. W#Force an array, so that it becomes Manifest. U This forcing function is specialised for DIM2 arrays, and does blockwise filling. $Fill an array region into a vector. ) This is specialised for DIM2 regions. R The region is evaluated in parallel in a blockwise manner, where each block is U evaluated independently and in a separate thread. For delayed or cursored regions W access their source elements from the local neighbourhood, this specialised version 4 should given better cache performance than plain  fillRegionP. Vector to write elements into. Extent of entire array. Region to fill. Fill a rectangle in a vector. Vector to write elements into. Extent of entire array. Generator for array elements. Rectangle to fill. TUVWTUVWXUnstructured traversal. Source array. .Function to produce the extent of the result. -Function to produce elements of the result. A It is passed a lookup function to get elements of the source. ZFirst source array. Second source array. .Function to produce the extent of the result. ,Function to produce elements of the result. 9 It is passed lookup functions to get elements of the  source arrays. [0Unstructured traversal over two arrays at once. First source array. Second source array. .Function to produce the extent of the result. ,Function to produce elements of the result. 9 It is passed lookup functions to get elements of the  source arrays. \]2Unstructured traversal over three arrays at once. ^_1Unstructured traversal over four arrays at once. XYZ[\]^_XZ[\]^_`0Impose a new shape on the elements of an array. > The new extent must be the same size as the original, else . 8TODO: This only works for arrays with a single region. abAppend two arrays. c2Transpose the lowest two dimensions of an array. 1 Transposing an array twice yields the original. d;Extend an array, according to a given slice specification. " (used to be called replicate). e@Take a slice from an array, according to a given specification. f!Backwards permutation of an array' s elements. 7 The result array has the same extent as the original. Extent of result array. 0Function mapping each index in the result array " to an index of the source array. Source array. g)Default backwards permutation of an array' s elements.  If the function returns ' then the value at that index is taken  from the default array (arrDft) Default values (arrDft) 0Function mapping each index in the result array " to an index in the source array. Source array. `abcdefg`abcdefgh(Interleave the elements of two arrays. 8 All the input arrays must have the same extent, else . L The lowest dimenion of the result array is twice the size of the inputs.  - interleave2 a1 a2 b1 b2 => a1 b1 a2 b2 - a3 a4 b3 b4 a3 b3 a4 b4 i*Interleave the elements of three arrays. j)Interleave the elements of four arrays. hijhijk`Apply a worker function to each element of an array, yielding a new array with the same extent. PThis is specialised for arrays of up to four regions, using more breaks fusion. l:Combine two arrays, element-wise, with a binary operator. 3 If the extent of the two array arguments differ,  then the resulting array' s extent is their intersection. klmnopklq7Sequentially fold the innermost dimension of an array.  Combine this with  transpose to fold any other dimension. r0Sequentially fold all the elements of an array. s)Sum the innermost dimension of an array. t"Sum all the elements of an array. qrstqrstu/Generate an aribrary shape that does not have 0's for any component. vEGenerate an arbitrary shape where each dimension is more than zero, ! but less than a specific value. wxECreate an arbitrary small array, restricting the size of each of the  dimensions to some value. -Generate an arbitrary index, which may have 0's for some components. uvwxuvwxuvwx$Select indices matching a predicate See if this predicate matches. &.. and apply fn to the matching index *.. then write the result into the vector. )Extent of indices to apply to predicate. 1Number of elements written to destination array. 2Select indices matching a predicate, in parallel. G The array is chunked up, with one chunk being given to each thread. K The number of elements in the result array depends on how many threads  you're running the program with. See if this predicate matches. yAProduce an array by applying a predicate to a range of integers. F If the predicate matches, then use the second function to generate  the element. RThis is a low-level function helpful for writing filtering operations on arrays. 2 Use the integer as the index into the array you're filtering. $If the Int matches this predicate, /... then pass it to this fn to produce a value "Range between 0 and this maximum. "Array containing produced values. yyz0Force an array before passing it to a function. {0Force an array before passing it to a function. m  !"#$%123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstyz{KBCDE>?@A9=:;<78162345FGHIJKz{LMNOPQRSVWTU`abcdefgklmnopqrstXZ\^Y[]_hijyz{|0Check if an index lies inside the given extent.  As opposed to inRange from Data.Array.Repa.Index, K this is a short-circuited test that checks that lowest dimension first. Extent of array. Index to check. }1Check if an index lies outside the given extent.  As opposed to inRange from Data.Array.Repa.Index, J this is a short-circuited test that checks the lowest dimension first. Extent of array. Index to check. ~GGiven the extent of an array, clamp the components of an index so they I lie within the given array. Outlying indices are clamped to the index " of the nearest border element. Extent of array. Index to clamp. RMake a 2D partitioned array given two generators, one to produce elements in the D border region, and one to produce values in the internal region. 3 The border must be the same width on all sides. Extent of array. Width of border. Generator for border elements. "Generator for internal elements. |}~|}~|}~ A index into the flat array. 3 Should be abstract outside the stencil modules. Like " but with the parameters flipped. Like " but with the parameters flipped. 0Apply a stencil to every element of a 2D array. # The array must be manifest else . 0Apply a stencil to every element of a 2D array. # The array must be manifest else . )How to handle the boundary of the array. Stencil to apply. Array to apply stencil to. 9Apply this function to values read from the array before ' transforming them with the stencil. LLike above, but clamp out of bounds array values to the closest real value. &Data template for stencils up to 7x7. &'()*+,-./0&'()*+-,./0QuickCheck properties for Data.Array.Repa.Index. QuickCheck properties for Data.Array.Repa and its children.      !"#$%&'()*+,-./0122334567899:: ; < = > ? @ A B C DEFGHIJKLLMNOPQRRSTUUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~        repa-2.0.0.3Data.Array.RepaData.Array.Repa.ShapeData.Array.Repa.IndexData.Array.Repa.SliceData.Array.Repa.StencilData.Array.Repa.Arbitrary Data.Array.Repa.Specialised.Dim2Data.Array.Repa.PropertiesData.Array.Repa.Internals.GangData.Array.Repa.Internals.Elt%Data.Array.Repa.Internals.EvalChunked'Data.Array.Repa.Internals.EvalBlockwiseData.Array.Repa.Stencil.Base Data.Array.Repa.Stencil.Template&Data.Array.Repa.Internals.EvalCursoredData.Array.Repa.Internals.Base!Data.Array.Repa.Internals.Forcing"Data.Array.Repa.Operators.Traverse$Data.Array.Repa.Operators.IndexSpace$Data.Array.Repa.Operators.Interleave!Data.Array.Repa.Operators.Mapping#Data.Array.Repa.Operators.Reduction Data.Array.Repa.Internals.Select Data.Array.Repa.Operators.SelectElttouchzerooneShaperankzeroDimunitDim intersectDimaddDimsize sizeIsValidtoIndex fromIndex inShapeRange listOfShape shapeOfListdeepSeqinShapeDIM5DIM4DIM3DIM2DIM1DIM0:.ZSlice sliceOfFull fullOfSlice SliceShape FullShapeAnyAllStencil StencilStatic stencilExtent stencilZero stencilAccBoundary BoundClamp BoundConst makeStencil makeStencil2stencil2 Generator GenCursor genMakeCursorgenShiftCursor genLoadElem GenManifestRectRange RangeRects rangeMatch rangeRectsRangeAllRegion regionRangeregionGeneratorArray arrayExtent arrayRegions deepSeqArray deepSeqArrays singletontoScalarextentdelay!index!? safeIndex unsafeIndex fromFunction fromVectorfromListtoVectortoListforceforce2traverseunsafeTraverse traverse2unsafeTraverse2 traverse3unsafeTraverse3 traverse4unsafeTraverse4reshapeappend++ transposeextendslice backpermutebackpermuteDft interleave2 interleave3 interleave4mapzipWith+^-^*^/^foldfoldAllsumsumAllarbitraryShapearbitrarySmallShapearbitraryListOfLengtharbitrarySmallArrayselect withManifest withManifest' isInside2 isOutside2clampToBorder2 makeBordered2 forStencil2forStencilFrom2 mapStencil2mapStencilFrom2props_DataArrayRepaIndexprops_DataArrayRepaGangReq ReqShutdownReqDotheGangnewReqwaitReqseqGang gangWorkerfinaliseWorkerforkGanggangSizegangIOparIOgangSTbaseGHC.STST getGangTimediffTime traceGang traceGangSTghc-primGHC.Primseq fillChunkedS fillChunkedPfillVectorBlockwisePfillVectorBlockPfillVectorBlock GHC.TypesIntGHC.BoolFalse parseStencil2 makeStencil2'fillCursoredBlock2PfillCursoredBlock2 deepSeqRegiondeepSeqRegions deepSeqRange deepSeqGeninRange Data.MaybeNothingvector-0.7.0.1Data.Vector.Unboxed.BaseVectorGHC.Errerror fillRegion2P fillRect2 $fArbitrary:.selectChunkedSselectChunkedPCursorunsafeAppStencilCursor2unsafeAppStencilCursor2_clamp template7x7 genInShape2