Changes between Version 12 and Version 13 of DataParallel/Regular


Ignore:
Timestamp:
Aug 18, 2009 6:02:35 AM (6 years ago)
Author:
gckeller
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DataParallel/Regular

    v12 v13  
    8989=== Shape Invariant Computations on Arrays === 
    9090 
     91The array operations described in this and the following subsection 
     92are available on both strict and delayed arrays, and yield the same 
     93result, with the exception that in case of delayed arrays, the result 
     94is only calculated once its forced by calling `fromDArray`. No 
     95intermediate array structures are ever created. 
     96 
    9197The library provides a range of operation where the dimensionality of 
    9298the result depends on the dimensionality of the argument in a 
     
    117123type MapIndex    = Index () 
    118124}}} 
    119  
     125Given this definition, the type of `select` now becomes 
     126{{{ 
     127select:: (U.Elt e, Shape dim, Shape dim') => Array dim e -> SelectIndex dim dim'  -> Array dim' e 
     128}}} 
     129Example: 
     130{{{ 
     131arr:: Array DIM3 Double 
     132select arr (IndexFixed 3 (IndexAll (IndexAll IndexNil))) 
     133}}} 
     134The index type is also used to express the type of generalised replicate: 
     135{{{ 
     136replicate:: Array dim' e -> SelectIndex dim dim'  -> Array dim e 
     137}}} 
     138Even though the index type serves well to express the relationship 
     139between the selector/multiplicator and the dimensionality of the 
     140argument and the result array, it is somehow inconvenient to use, as 
     141the examples demonstrate. This is therefore another example where we 
     142need to add another layer to improve the usability of the library.  
    120143 
    121144Note that the library provides no way to statically check the pre- and 
     
    123146to be done at run time using assertions. 
    124147 
     148== Array Operations == 
     149    
     150Backpermute and default backpermute are two general operations which allow  
     151the programmer to express all structural operations which reorder or extract 
     152elements based on their position in the argument array: 
     153{{{ 
     154backpermute:: (U.Elt e, Shape dim, Shape dim') =>  
     155  Array dim e -> dim' -> (dim' -> dim) -> Array dim' e 
     156 
     157backpermuteDft::(U.Elt e, Shape dim, Shape dim') =>  
     158  Array dim e -> e -> dim' -> (dim' -> Maybe dim) -> Array dim' e 
     159}}} 
     160 
     161 
     162{{{ 
     163map:: (U.Elt a, U.Elt b, Shape dim) => (a -> b) -> Array dim a -> Array dim b 
     164 
     165zip:: (U.Elt a, U.Elt b, Shape dim) => Array dim a -> Array dim b-> Array dim (a :*: b) 
     166 
     167zipWith:: (U.Elt a, U.Elt b, U.Elt c, Shape dim) =>  
     168          (a -> b -> c) -> Array dim a -> Array dim b-> Array dim c 
     169 
     170mapFold:: (U.Elt e, Shape dim) => (e -> e-> e) -> e -> Array (dim :*: Int) e  -> Array dim  e 
     171 
     172reshape:: (Shape dim', Shape dim, U.Elt e) => Array dim e -> dim' -> Array dim' e 
     173}}} 
     174 
     175The following operations could be (and in the sequential implementation indeed are)  expressed 
     176in terms of backpermute and default backpermute. However, a programmer should aim at using more 
     177specialised functions when provided, as they carry more information about the pattern of reordering.  
     178In particular in the parallel case, this could be used to provide significantly more efficient  
     179implementation which make use of locality and communication patterns. 
     180{{{ 
     181shift:: (Shape dim, U.Elt e) => Array dim e -> e -> dim -> Array dim e 
     182 
     183rotate:: (Shape dim, U.Elt e) => Array dim e -> e -> dim -> Array dim e 
     184 
     185tile::  (Shape dim, U.Elt e) => Array dim e -> dim -> dim -> Array dim e 
     186}}}