LIBDVM2 (1158351), страница 16
Текст из файла (страница 16)
| *StreamPtr | - the input file descriptor. |
| ArrayHeader | - the header of the distributed array. |
| InitIndexArray | - array, which i-th element is the initial value of the index variable of the (i+1)-th dimension of the distributed array. |
| LastIndexArray | - array, which i-th element ] is the last value of the index variable of the (i+1)-th dimension of the distributed array. |
| StepArray | - array, which i-th element is the step value for the index variable of the (i+1)-th dimension of the distributed array. |
The function reads the sub-array of the distributed array. This sub-array is determined by the following set of the index corteges:
| {I1 M1: I1 = InitIndexArray[0] | +StepArray[0] *P1 } x |
where:
| x | - symbol of Cartesian product; |
| n | - rank of the distributed array; |
| Ik | - index variable of the k-th dimension of the distributed array; 0Pk(LastIndexArray[k-1]-InitIndexArray[k-1]+1)/StepArray[k-1]. |
The subarray to be read is a block (stretched, if at least one StepArray[i] is not equal to 1).
The reading is executed until the exhaustion of the source elements. The elements are copied in the order, according to the C language discipline of allocating of the elements in the memory, that is the right index is changed more faster then the left one. If the initial value of the index by some dimension of the target array is greater or equal to its last value, then the index of this dimension is not changed during copy operation. Note, that Run-Time Library considers the last index value of any dimension as a minimum of the defined value in the function call and the real size of this dimension minus 1.
To use a full scope of the target array without requesting the size of the object by some dimension (see section 17.2), Run-Time Library supposes that the value of the initial index value can be equal to -1. In that case, the initial index value is supposed to be equal to zero, the step be equal to 1, and the last index value be equal to the size of the dimension minus 1.
The function returns the number of the copied elements.
| long dvm_dfread ( | long | ArrayHeader[], |
| ArrayHeader | - the header of the distributed array. |
| Count | - the number of the elements to read. |
| *StreamPtr | - the descriptor of the input file. |
The function dvm_dfread reads no more than Count of the first elements of the distributed array (in order of allocation this array in memory). If Count is greater then zero the number of the copied elements is supposed to be minimum of Count and the real number of the elements in the distributed array. If Count is a negative number then the function reads the distributed array entirely.
The function returns the number of the copied elements.
16.3. Writing sub-array of distributed array to file.
| long DisArrWrite( | DVMFILE | *StreamPtr, |
| *StreamPtr | - the descriptor of the output file. |
| ArrayHeader | - the header of the distributed array. |
| InitIndexArray | - array, which i-th element is the initial value of the index variable of the (i+1)-th dimension of the distributed array. |
| LastIndexArray | - array, which i-th element ] is the last value of the index variable of the (i+1)-th dimension of the distributed array. |
| StepArray | - array, which i-th element is the step value for the index variable of the (i+1)-th dimension of the distributed array. |
The functions writes the sub-array of the distributed array. This sub-array is determined by the following set of the index corteges:
| {I1 M1: I1 = InitIndexArray[0] | +StepArray[0] *P1 } x |
where:
| x | - symbol of Cartesian product; |
| n | - rank of the distributed array; |
| Ik | - index variable of the k-th dimension of the distributed array; 0Pk(LastIndexArray[k-1]-InitIndexArray[k-1]+1)/StepArray[k-1]. |
The subarray to be coped is a block (stretched, if at least one StepArray[i] is not equal to 1).
The writing is executed until the exhaustion of the source elements. The elements are copied in the order, according to the C language discipline of allocating of the elements in the memory, that is the right index is changed more faster then the left one. If the initial value of the index by some dimension of the source array is greater or equal to its last value, then the index of this dimension is not changed during copy operation. Note, that Run-Time Library considers the last index value of any dimension as a minimum of the defined value in the function call and the real size of this dimension minus 1.
To use a full scope of the source array without requesting of the size of the object by some dimension (see section 17.2), Run-Time Library supposes that the value of the initial index value can be equal to -1. In that case, the initial index value is supposed to be equal to zero, the step is equal to 1, and the last index value is equal to the size of the dimension minus 1.
The function returns the number of the copied elements.
| long dvm_dfwrite( | long | ArrayHeader[], |
| ArrayHeader | - the header of the distributed array. |
| Count | - the number of the elements to be copied. |
| *StreamPtr | - the descriptor of the output file. |
The function dvm_dfwrite writes no more then Count of the first elements of the distributed array (in order of allocation this array in memory). If Count is greater then zero the number of the copied elements is supposed to be minimum of Count and the real number of the elements in the distributed array. If Count is a negative number then the function writes the distributed array entirely.
The function returns the number of the copied elements.
Note. The first Count elements in order of the memory allocation are not a block in common case and can be described in the following way. Let decomposition of the number Count by the dimension weights of the distributed array is
|
| N |
where:
| n | - rank of the distributed array; |
| Ki | - decomposition coefficient of i-th dimension (0 Ki Si -1 , Si - size of i-th dimension); |
| Wi | - weight of i-th dimension. |
| Wi = | { | n |
|
Then first Count elements may be represented as the following union of blocks:
| n | n | | | | | |
Therefore reading (writing) the first Count elements of the distributed array by the function dvm_dfread (dvm_dfwrite) is equivalent to sequential reading (writing) existing blocks B1, ... ,Bn using the function DisArrRead (DisArrWrite) (the block Bm exists, if Km is not equal to zero).
17. Miscellaneous functions.
17.1. Requesting size of object.
long getrnk_(ObjectRef *ObjectRefPtr);
The function getrnk_ returns the rank of the object, defined by *ObjectRefPtr.
The following entities can be used as objects:
-
a distributed array (in that case the pointer is the first word of the array header);
-
a representation of the abstract machine;
-
a processor system;
-
map of the abstract machine representation;
-
map of the distributed array;
-
a parallel loop.
If the pointer *ObjectRefPtr is not a pointer to any of the mentioned above objects, then the function returns zero.
For the map (of array or abstract machine representation) the rank of the object, that is the source for the map, is returned.
17.2. Requesting size of object dimension.
| long getsiz_( | ObjectRef | *ObjectRefPtr, |
The function returns the size of the object *ObjectRefPtr by the dimension *AxisPtr.
The following entities can be used as objects:
-
distributed array (in that case the pointer is the first word of the array header);
-
the representation of the abstract machine;
-
the processor system;
-
parallel loop
The size of the distributed array dimension is equal to
ceil((LastIndex - InitIndex + 1) / Step) ,















