Coarrays in the Context of XcalableMP
99
with a subset of nodes, then the corresponding subset of images will be the executing
images for the task region. The current number of images and my image number,
which are given by inquire functions num_images and this_image also match
the executing images, and the SYNC_IMAGES statement synchronizes the executing
images. When the execution encounters the END TASK directive corresponding to
the TASK directive, the set of executing images is reinstated.
Requirement for the Implementation The runtime library should manage the
executing image set and the current image index in a stack in order to reinstate
them at the exit point of the task.
2.2 Allocation of Coarrays
A coarray or a coarray variable is a variable that can be referred from the other
images. A coarray with the ALLOCATABLE attribute is called an allocatable
coarray, and is otherwise called a non-allocatable coarray. A non-allocatable
coarray may not be a pointer and must have an explicit shape and the SAVE attribute.
In order to help intuitive understanding, we refer to a non-allocatable coarray a static
coarray. The lifetime of a static coarray is throughout execution of the program on
all images, even if the coarray is declared in a procedure called with a subset of
images.
On the other hand, an allocatable coarray is allocated with the ALLOCATE
statement and freed either explicitly with the DEALLOCATE statement or implicitly
at the end of the scope in which the ALLOCATE statement is executed (automatic
deallocation).
Static coarrays can be declared as scalar or array variables as follows:
real(8), save :: a(100,100)[ * ]
type(user_defined_type), save :: s[2,2, * ]
The square brackets in the declaration distinguish coarray variables from other
(non-coarray) variables. The declaration declares the virtual shape of the images,
and the last dimension must be deferred (as ‘ * ’).
Allocatable coarrays can be declared as follows:
real(8), allocatable :: b(:,:)[:]
type(user_defined_type), allocatable :: t[:,:,:]
A notable constraint is that at any synchronization point in program execution, coarrays must have the same dimensions (sizes of all axes) for all images
(symmetric memory allocation). Therefore, a static coarray must have the same
shape for all images during program execution, and an allocatable coarray must be
allocated and deallocated collectively at the same time with the same dimensions
for the executing images. Thanks to the symmetric memory allocation rule, all
executing images can have the same symmetrical memory layout, which makes it
Précédent

- 106/265

Suivant