LIBDVM2 (1158351), страница 7
Текст из файла (страница 7)
The described alignment F is equivalent to the sequence of the alignments P and G. Consider the case, when the pattern Pattern is not an abstract machine representation. Then it is aligned by some function Q with another pattern. In this case, the alignment functions F and Q may be substituted by their superposition Q*F. So, the resulting alignment of the array DA with the abstract machine representation can be built substituting sequential alignment functions by their superposition. (Run-Time Library does it to align the array DA by the pattern PatternDA when the function align_ is called.)
7.3. Realigning distributed array.
| long realn_ ( | long | ArrayHeader[], |
| ArrayHeader | - the header of the distributed array to be realigned. |
| *PatternRefPtr | - pointer to the alignment pattern. |
| AxisArray | - array, which j-th element is a dimension number of the distributed array used in linear alignment rule for pattern (j+1)-th dimension. |
| CoeffArray | - array, which j-th element is a coefficient for the distributed array index variable used in linear alignment rule for the pattern (j+1)-th dimension. |
| ConstArray | - array, which j-th element is a constant used in the linear alignment rule for the pattern (j+1)-th dimension. |
| *NewSignPtr | - the flag of updating of the distributed array (to be equal to 1). |
The function realn_ cancels the allocation of the distributed array with header *ArrayHeaderPtr, defined previously by the function align_(or malign_, see section 7.5). The function sets a new allocation for this array according to the parameters AxisArray, CoefArray and ConstArray. If this array has been used as pattern of alignment of some arrays, nevertheless the allocations of these arrays are not changed.
The contents of realigned array will be updated (cleared), if the value *NewSignPtr is not equal zero and will be kept in other case. When contents of the array is kept its shadow edges (see section 12) are not kept; when the array is updated the shadow edges are cleared.
The array can be realigned by function realn_ only, if it was created by the function crtda_ with parameter *ReDistrParPtr equal to 2 or 3 (see section 6).
The function returns non-zero, if realigned array has a local part on current processor, and zero in other case.
7.4. Requesting map
| ArrayMapRef arrmap_ ( | long | ArrayHeader[], |
| ArrayHeader | - header of the distributed array |
| *StaticSignPtr | - flag of static map creation |
The function arrmap_ creates an object (a map), describing current mapping of the distributed array onto the processor system representation, and returns a pointer to the created object.
The map contains in particular the following information:
-
a pointer to the processor system representation, distributed array is mapped on;
-
alligning rules for all dimensions of the representation;
-
the ranks of the distributed array and the abstract machine representation (for checking).
If flag of static map *StaticSignPtr is not equal to zero, then the map will not be deleted when control exits a program block (see section 8). Such map can be deleted only explicitly by function delarm_ considered in section 7.7.
7.5. Specifying distributed array mapping according to map.
| long malign_ ( | long | ArrayHeader[], |
| ArrayHeader |
|
| *AMViewRefPtr |
|
| *ArrayMapRefPtr |
|
The function malign_ performs distributed array mapping onto abstract machine representation according to map.
The ranks of the distributed array and the abstract machine representation must be equal to corresponding ranks in map.
If AMViewRefPtr is equal to NULL or *AMViewRefPtr is equal to zero, then abstract machine representation, whose pointer is in the map, will be used as alignment pattern.
The function returns non-zero, if mapped array has a local part on the current processor, and zero in the other case.
7.6. Realigning distributed array according to map.
| long mrealn_ ( | long | ArrayHeader[], |
| ArrayHeader |
|
| *AMViewRefPtr |
|
| *ArrayMapRefPtr |
|
| *NewSignPtr |
|
Function mrealn_ cancels allocation defined earlier by the function. malign_ (or align_ , see section 7.1) for the distributed array with header *ArrayHeaderPtr, and defines for the array new allocation according to specified map. The allocation of all distributed arrays, for whose alignment considered array was used as pattern, will not be changed.
The ranks of the distributed array and the abstract machine representation must be equal to corresponding ranks in the map.
If AMViewRefPtr is NULL or *AMViewRefPtr is zero, then abstract machine representation, whose pointer is in the map, will be used as alignment pattern.
The contents of realigned array will be updated (cleared), if the value *NewSignPtr is not equal zero and will be kept in other case. When contents of the array is kept its shadow edges (see section 12) are not kept; when the array is updated the shadow edges are cleared.
The array can be realigned by function mrealn_ only in the case, if it was created by the function crtda_ with parameter *ReDistrParPtr equal to 2 or 3 (see section 6).
The function returns non-zero, if remapped array has a local part on the current processor, and zero in other case.
7.7. Deleting map.
long delarm_ (ArrayMapRef *ArrayMapRefPtr);
*ArrayMapRefPtr - pointer to the map of the distributed array.
The function deletes the map of the distributed array created by function arrmap_. After deleting the map the pointer can be used by user program for its own goals.
Note, that non-static map can be deleted by function delarm_ only in the case when it was created in the current program block.
To delete map the function delobj_ can also be used (see section 17.5).
The function returns zero.
Note. One of the possible usage of the functions, aligning the distributed arrays according to the map is keeping and restoring the array allocation in procedures, dealing with external distributed arrays with their redistribution.
Note that at the moment of using the map for mapping and remapping arrays, the array, being source for the map, may not exist.
8. PROGRAM BLOCK DEFINITION.
8.1. Block beginning
long begbl_(void);
The function begbl_ defines the beginning of the localization block for the following system objects:
-
distributed array;
-
abstract machine representation;
-
processor system;
-
reduction;
-
reduction group;
-
shadow edge group of the distributed arrays;
All these objects, being created in the localization block, are local ones. This means that these objects will be automatically deleted, when the control exits from this block. The exception is the static objects, which have to be deleted explicitly. The localization blocks can be nested.
Note, when abstract machine representation is deleted, all distributed arrays, mapped on the representation, are also deleted.
The function returns zero.
8.2. Block end
long endbl_(void);
The function endbl_ marks the end of the localization block. The function returns zero.
9. Parallel loop defining.
9.1. Creating parallel loop.
LoopRef crtpl_ (long *RankPtr);
*RankPtr - rank of the parallel loop.
The function crtpl_ creates the parallel loop (and so, defines its beginning). The function returns pointer to the created object.
9.2. Mapping parallel loop.
| long mappl_ ( | LoopRef | *LoopRefPtr, |
| *LoopRefPtr | - pointer to the parallel loop. |
| *PatternRefPtr | - pointer to the pattern of the parallel loop mapping. |
| AxisArray | - array, which j-th element is a dimension number of the parallel loop (that is the number of the index variable) used in linear alignment rule for the pattern (j+1)-th dimension. |
| CoeffArray | - array, which j-th element is a coefficient for the parallel loop index variable used in linear alignment rule for the pattern (j+1)-th dimension. |
| ConstArray | - array, which j-th element is a constant used in the linear alignment rule for the pattern (j+1)-th dimension. |
| LoopVarAddrArray | - array, which j-th element is an address (cast to ‘AddrType’) of the index variable of the parallel loop (i+1)-th dimension. |
| InInitIndexArray | - input array, which j-th element is an initial value for the index variable of the parallel loop (i+1)-th dimension. |
| InLastIndexArray | - input array, which j-th element is a last value for the index variable of the parallel loop (i+1)-th dimension. |
| InStepArray | - input array, which j-th element is a step value for the index variable of the parallel loop (i+1)-th dimension. |
| OutInitIndexArray | Output array, which j-th element is calculated initial value for the index variable of the parallel loop (i+1)-th dimension. |
| OutLastIndexArray | - output array, which j-th element is calculated last value for the index variable of the parallel loop (i+1)-th dimension. |
| OutStepArray | - output array, which j-th element is calculated step value for the index variable of the parallel loop (i+1)-th dimension. |
The function mappl_ creates regular mapping of the parallel loop onto the abstract machine representation, according to the defined mapping rules and the descriptions of the loop dimensions. The function distributes iterations of the loop among child abstract machines from this representation. The pattern defines the abstract machine representation. This pattern can be either the representation by itself, or the distributed array («indirect mapping»). In the last case, the pointer to the pattern is the first word of the distributed array header.
Using distributed array as a pattern is allowed only if this array has been mapped on a abstract machine representation; and using an abstract machine representation as a pattern is allowed only if this representation has been mapped on a processor system. So the function mappl_ only distributes iterations of the parallel loop among processors from this processor system.
Conceptually, when the control enters in the parallel branch, the current abstract machine has to be changed. Indeed, the current abstract machine is changed when it is requested only. That is, the Run-Time Library changes the current abstract machine only for necessity to reduce overheads.















