LIBDVM2 (1158351), страница 13
Текст из файла (страница 13)
The size of distributed array element in bytes (a number of read bytes) is returned.
13.4.4. Assigning value to element of local part of distributed array.
| long wlocel_( | void | *BufferPtr, |
| ArrayHeader | - a header of the distributed array. |
| IndexArray | - array, which i-th element is index value of modified element of the distributed array on (i+1)-th dimension. |
| BufferPtr | - pointer to the memory area, where the value is located. |
The function can be executed successfully only by the processor, in whose memory the specified element is located.
The size of distributed array element in bytes is returned.
13.4.5. Coping element of local part of distributed array to element of local part of other distributed array.
| long clocel_( | long | FromArrayHeader[], |
| FromArrayHeader | - header of read distributed array. |
| FromIndexArray | - ditributed array, which i-th element is index value of read element of the distributed array on (i+1)-th dimension. |
| ToArrayHeader | - header of the other distributed array, the element will be assigned by the read value. |
| ToIndexArray | - array, which j-th element is index value of updated element of the distributed array on (i+1)-th dimension. |
The function can be executed successfully only by the processor, in whose memory the read and written elements are allocated. The types of read and written elements must be the same.
The number of copied bytes is returned.
13.4.6. Requesting address of element of local part of distributed array.
| char *GetLocElmAddr( | long | ArrayHeader[], |
| ArrayHeader | - header of the distributed array. |
| IndexArray | - array, which i-th element is index value of element of distributed array on (i+1)-th dimension. |
The function can be executed successfully only by the processor, in whose memory the specified element is allocated.
The pointer to the first byte of the element is returned.
13.5. Macros to access elements of local part of distributed array of rank from1 to 7.
The following macros to access the elements from the local part of the distributed array with rank from 1 to 7 can be used in C programs:
| <DAElmType> DAElm<Rank> ( | long | ArrayHeader[], |
| ArrayHeader | - header of the distributed array. |
| Rank | - the rank of the distributed array. |
| DAElmType | - the type of the element of the distributed array. |
| Indexi | - index value of the requested element on the i-th dimension of the distributed array. |
Each of these macros is L-value in the C language.
The access to local part of distributed array by means of macros is more effective, then the access by the functions, described in section 13.3.
It is assumed that the array with the header ArrayHeader was created with the base pointer equal to NULL.
14. Regular access to remote data.
The access to the distributed array elements, allocated on the other processor (remote elements) is implemented by means of creation of a special buffer (a remote element buffer) on the current processor and coping it required remote data. The required remote elements are determined by specified for each dimension of the distributed array linear rules of sampling (regular access) of the form
Ai*Vi + Bi ,
where:
| I | - a number of the distributed array dimension; |
| Vi | - index variable of sampling rule of i-th dimension of the array; |
| Ai, Bi | - integer constants. |
On the current processor a range of values is specified for each index variable Vi. As a result required remote elements are represented as a stretched block, allocated in the buffer in compact (not stretched) form.
Dealing with remote element buffer is similar to dealing with local part of distributed array (see section 13).
For the purpose of optimization the remote element buffers can be combined the groups and filling all buffers of the group is executed by one operation.
14.1 Creating remote element buffer of distributed array.
| long crtrb ( | long | ArrayHeader[], |
| ArrayHeader | - header of the distributed array |
| BufferHeader | - header of a remote element buffer to be created |
| BasePtr | - base pointer for access to the remote element buffer |
| *StaticSignPtr | - flag of static buffer creation |
| CoeffArray | - array, which i-th element is coefficient of index variable of the linear sampling rule for (i+1)-th dimension of the array (Ai). |
| ConstArray | - array, which i-th element is constant of index variable of the linear sampling rule for (i+1)-th dimension of the array (Bi). |
| InitIndexArray | - array, which i-th element is initial value of index variable of the linear sampling rule for (i+1)-th dimension of the array. |
| LastIndexArray | - array, which i-th element is last value of index variable of the linear sampling rule for (i+1)-th dimension of the array. |
| StepArray | - array, which i-th element is step of index variable of linear sampling rule for (i+1)-th dimension of the array. |
The function crtrb_ creates a buffer to allocate remote elements of the distributed array with header ArrayHeader.
The created buffer header BufferHeader is the array of r+1 elements of type "long", where r is the number of the distributed array dimensions, for which CoeffArray[i] # 0 or ConstArray[i] <0, i.e. a number of the array dimensions, for which linear sampling rule is not constant (see below). The buffer header allocation in memory (static or dynamic) is perfumed by a user program, and the buffer initialization is performed by Run-Time Library when executing the function crtrb_.
The base pointer BasePtr must refer to any variable of the same type as the type of the distributed array elements. The variable value is irrelevant, because the base pointer is used only for access to remote elements of the distributed array, allocated in the created buffer.
Dealing with the header of remote elements buffer and base pointer is considered in detail in section 14.5.
If the flag *StaticSignPtr of static buffer is not equal to zero, then the created buffer will be not deleted automatically, when the control exits the program block (see section 8). Such buffer can be deleted only explicitly using the function delrb_ considered below.
The buffer, created by the function crtb_, is intended to allocate remote elements, determined by the index vectors of the form
( CoeffArray[0]*V1 + ConstArray[0] ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CoeffArray[i-1]*Vi + ConstArray[i-1] ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CoeffArray[n-1]*Vn + ConstArray[n-1] ) ,
where:
| n | - the distributed array rank; | |
| CoeffArray[i-1]*Vi + ConstArray[i-1] | - linear coordinate sampling rule for i-th dimension of the array; | |
| Vi | - index variable of sampling rule for i-th dimension of the array | |
InitIndexArray[i-1] Vi LastIndexArray[i-1]
when StepArray[i-1] > 0
or
LastIndexArray[i-1] Vi InitIndexArray[i-1]
when StepArray[i-1] < 0
Correct sampling rules must satisfy to the following conditions:
0 CoeffArray[i-1]*InitIndexArray[i-1]+ConstArray[i-1] < Sizei,
0 CoeffArray[i-1]*LastIndexArray[i-1]+ConstArray[i-1] < Sizei,
where Sizei - size of i-th dimension of the distributed array (1 i n).
The buffer will not be created (more exactly, the buffer for zero number of the elements will be created, even if for one i
InitIndexArray[i-1] > LastIndexArray[i-1] when StepArray[i-1] > 0
or
LastIndexArray[i-1] > InitIndexArray[i-1] when StepArray[i-1] < 0
For full coverage by the sampling rule of i-th dimension of the distributed array CoeffArray[i-1] must be equal to zero, and ConstArray[i-1] must be equal to -1. The such specification is equivalent to sampling rule 1*Vi + 0 , where 0 Vi < Sizei.
The function returns zero.
14.2. Initializing loading remote element buffer of distributed array.
long loadrb_ (long BufferHeader[]);
BufferHeader - header of the remote element buffer.
The function loadrb_ initializes loading of specified buffer by the distributed array elements, for which the buffer was created by the function crtrb_.
The function returns zero.
14.3. Waiting for completion of loading remote element buffer of distributed array.
long waitrb_ (long BufferHeader[]);
BufferHeader - header of the remote element buffer.
The function returns zero.
14.4. Deleting remote element buffer of distributed array.
long delrb_ (long BufferHeader[]);
BufferHeader - header of the remote element buffer to be deleted.
Non-static remote element buffer can be deleted by the function delrb_ only in the case if it was created in the current program block.
To delete remote element buffer the function delobj_ can also be used (see section 17.5).















