LIBDVM2 (1158351), страница 6
Текст из файла (страница 6)
Using the distributed array as a pattern is allowed only if this array has already been mapped on an abstract machine representation. Moreover, using an abstract machine representation as a pattern is allowed only if this representation has been mapped on a processor system. So the function align_ only distributes elements of the aligned distributed array among processors from this processor system.
Consider distributed array alignment in detail. Let F be a multifunctional with the domain of definition in a space of indexes of the aligned array and with the image in the space of indexes of the pattern:
| F((I1, ... ,Ii, ... ,In) ) = | F1(I1, ... ,Ii, ... ,In) x |
where:
| x | - is a symbol of the Cartesian product; |
| n | - rank of the distributed array; |
| m | - rank of the pattern; |
| Ii | - index variable of the i-th dimension of the aligned array; |
| Fj | - multifunction, which range of value is a range of index variable of pattern j-th dimension. |
An alignment of the distributed array with the pattern is a defining the F multifunction. This defining designates that an element (I1, ... ,In) of an aligned array has to be located on the processor if and only if some pattern elements from F((I1, ... ,In)) set are mapped on this processor. The set F((I1, ... ,In)) is an image-set, and components of this set are vectors of space of indexes of the pattern.
The F1, ... , Fm functions are named «coordinate alignment rules». Run-Time Library provides the following set of alignment rules:
1. Fj(I1, ... ,In) = {Aj * Ik + Bj} , where:
| k=f(j) | - dimension number of an aligned array (1 k n, f(j1) # f(j2) when j1 # j2); |
| Aj | - integer; |
| Bj | - nonnegative integer. |
This alignment rule means that for each element (I1,…, In) of index space of the aligned array the corresponding image-set contains one element – Aj*Ik+Bj. This element belongs to the value range of the index variable of the pattern j-th dimension.
Note, that Aj and Bj have to meet the following requirements:
0 Bj MAXj; and 0 Aj *MAXk + Bj MAXj , where:
| MAXj | - maximum of the index variable of the j-th dimension; |
| MAXk | - maximum of the index variable of the aligned array k-th dimension. |
2. Fj(I1, ... ,In) = {q Mj: 0 q MAXj} , where:
| Mj | - range of values of the index value of the pattern j-th dimension; |
| MAXj | - maximum of the index variable of the pattern j-th. |
This mapping rule means that for each element (I1,…, In) of index space of the aligned array a corresponding image-set, consists of whole range of values of index variable of the pattern j-th dimension. (In such a case, the symbol «*» («any of the admissible») is usually used).
Examples.
-
Alignment rule F( (I1,I2) ) = {I1}x{I2} means that element of two-dimensional array has to be mapped onto any processor, an element of two-dimensional pattern is mapped on, if the indexes of both elements are equal.
-
Alignment rule F( (I1,I2) ) = {*}x{I1+5}x{*} means that the element of two-dimensional array has to be mapped onto any processor, an element of three-dimensional pattern is mapped on, if the index of the pattern second dimension is equal to the index of the aligned array first dimension plus 5. The index of the aligned array second dimension and the indexes of the pattern first and third dimension are not considered.
-
Alignment rule F( (I1,I2,I3) ) = {*}x{*} means, that each element of three-dimensional array has to be mapped onto each processor, any element of two-dimension pattern is mapped on. The indexes of the aligned array and of the pattern are not considered.
-
Alignment rule F( (I1,I2) ) = {0}x{1}x{2} means, that an element of two-dimensional array has to be mapped onto each processor, the element (0,1,2) of three-dimensional pattern is mapped on. The indexes of aligned array are not considered.
Defining the aligned array distribution among pattern space (that is the defining F1, ... ,Fm functions) it is necessary to take into account that all elements of the distributed array have to be inside the pattern space. Observance of correct mapping on each stage of a chain of alignments guarantees the correct final distribution of array elements among the processors.
Note that if an array is used as a pattern, then after realignment of this array by the function realn_ (see section 7.3), the array aligned with this pattern keeps its location.
When the function align_ is called the parameters of the alignment rule Fj(I1,...,In)= {Aj*Ik+Bj} for the j-th pattern dimension have to be defined as follows:
| AxisArray[j-1] | contains value k; |
| CoeffArray[j-1] | contains value Aj; |
| ConstArray[j-1] | contains value Bj. |
To define alignment rule Fj(I1, ... ,In) with image in set of all values of the index variable of j-th dimension of template for any I1, ... ,In, the value AxisArray[j-1] (k value) has to be set to -1. The values CoeffArray[j-1] and ConstArray[j-1] are irrelevant in this case.
The number of the alignment rules has to be equal to the rank of the pattern, when the function align_ is called.
The function returns zero.
Note. The distributed array mapping, specified for function align_, may be implemented only in the case, if for all the processors, at least one array element is mapped onto, a local size of each array dimension, obtained as a result of mapping, is not less than widths of high and low shadow edges of the dimension.
7.2. Alignments superposition.
Let the function G defines the location of the n-dimensional array in the space of the r-dimensional pattern; and let the function P defines the location of the r-dimensional array in the space of the m-dimensional pattern:
| G((I1, ... ,Ii, ... ,In)) = | G1(I1, ... ,Ii, ... ,In) x |
| P((J1, ... ,Jj, ... ,Jr)) = | P1(J1, ... ,Jj, ... ,Jr) x |
Then the result of alignment P (by function align_) of r-dimensional array PatternDA in m-dimensional pattern Pattern space; and of next alignment G of n-dimensional array DA in r-dimensional array PatternDA space is alignment F of n-dimensional array DA in m-dimensional pattern Pattern space. F is a product (superposition) of P and G:
| | U{P(v)} = | F1(I1, ... ,Ii, ... ,In) x |
The coordinate alignment rules Fs (0 s m) from F mapping are a superposition of the coordinate alignment rules for P and G mappings:
1. Let Ps((J1, ... ,Jr)) = {q Ms: 0 q MAXs} , where:
| MAXs | - maximum of the index variable of the s-th dimension of Pattern; |
| Ms | - range of values of the index variable of the pattern Pattern s-th dimension. |
Then Fs(I1, ... ,In) ) = Ms,
that is the full replication of the array DA along the s-th dimension of the pattern Pattern.
| 2. | Let | Ps((J1, ... ,Jr)) = Cs * Jk + Ds and |
where:
| Jk | - index variable of the k-th dimension of the array PatternDA; |
| Il | - index variable of the l-th dimension of the array DA; |
| Cs, Qs | - integers; |
| Dk, Rk | - nonnegative integers. |
Then Fs((I1, ... ,In)) = As * Il + Bs ,
where As = Cs * Qk и Bs = Cs * Rk + Ds.
| 3. | Let | Ps((J1, ... ,Jr)) = Cs * Jk + Ds and |
where:
| Jk | - index variable of the k-th dimension of the array PatternDA; |
| Cs | - integer; |
| Ds | - nonnegative integer; |
| MAXk | - maximum of the index variable of the k-th dimension of the array PatternDA; |
| Mk | - range of values of the index variable of the PatternDA array k-th dimension. |
Then
| Fs((I1, ... ,In)) = | U {Cs * Jk + Ds} , |
that is the partial replication (stretched by the linear function Ps) of the array DA along the s-th dimension of the pattern Pattern.















