|
DWARF Standard
|
| 090824.1 |
Tommy Hoffner |
Coshape of Coarrays in Fortran 2008 |
Enhancement |
Open |
Tommy Hoffner |
Feature
-------
DWARF Extension to express the coshape of coarrays in Fortran 2008
Background
----------
The new Fortran 2008 standard added the Coarray Fortran feature.
Overview
--------
Coarray Fortran (CAF) makes Fortran an efficient SPMD parallel language
with simple syntactic extensions. A single program is replicated a fixed
number of times. Each replication, called an image, has its own set of data
objects. The coarray extension allows programmers to express data distribution
through coarrays.
The shape of a normal array is defined by its dimensions and the lower/upper
bounds of each dimension. Array subscripts are used to locate a specific array
element (i.e. round brackets).
The shape of a coarray is the same as a normal array. A coarray always has
the same shape on each image. Coarrays also have coshape definitions.
For example:
integer, save :: mycoarray(9,8,7,6)[10,0:9,0:*]
defines the shape and coshape of coarray 'mycoarray', where (9,8,7,6) is the
shape of coarray 'mycoarray' and [10,0:9,0:*] is the coshape of 'mycoarray'.
The upper bound of the last codimension is always a * (asterisk), which means
the upper bound of the last codimension is determined either at the compile
time (by a compiler option) or at the run time (by an environment variable).
Each image can access the local object of a coarray as well as the corresponding
object on any other images. When accessing a coarray element on another image,
the programmer specifies explicitly the image by using subscripts in square
brackets (cosubscripts). For example, the following statement accesses the
coarray element myarray(1,2,3,4) on the image specified by cosubscript [3,1,2].
i = myarray(1,2,3,4)[3,1,2]
Similar to the subscript is evaluated to an integer offset of the array
element, the cosubscript is evaluated to a linearized integer image number.
For example, with coshape [10,0:9,0:*], cosubscript [3,1,2] is evaluated
to image number 312.
To evaluate a cosubscript, a debugger needs the coshape information of a
coarray. This proposal is to extend DWARF to express the coshape of coarrays
as follows.
simple array example (no coarray yet):
real A(3,5)
integer i,j
do 20 j = 1, 3
do 10 i = 1, 3
a(i,j) = real(i)/real(j)
10 continue
20 continue
end
DWARF:
<1><92>: Abbrev Number: 5 (DW_TAG_array_type)
DW_AT_sibling : <a3>
DW_AT_ordering : 1 (column major)
DW_AT_type : <85>
<2><9c>: Abbrev Number: 6 (DW_TAG_subrange_type)
DW_AT_lower_bound : 1
DW_AT_upper_bound : 3
<2><9f>: Abbrev Number: 6 (DW_TAG_subrange_type)
DW_AT_lower_bound : 1
DW_AT_upper_bound : 5
<1><a3>: Abbrev Number: 7 (DW_TAG_subprogram)
DW_AT_name : _main
DW_AT_low_pc : 0
DW_AT_high_pc : 0xfc
DW_AT_calling_convention: 2 (program)
DW_AT_external : 1
DW_AT_frame_base : 1 byte block: 6f (DW_OP_reg31)
DW_AT_type : <77>
<2><ba>: Abbrev Number: 8 (DW_TAG_variable)
DW_AT_location : 2 byte block: 91 18 (DW_OP_fbreg: 24)
DW_AT_name : a
DW_AT_decl_file : 1
DW_AT_decl_line : 0
DW_AT_type : <92>
Coarray example:
real A (3,5) [0:10,0:15]
DWARF:
<1><92>: Abbrev Number: 5 (DW_TAG_array_type)
DW_AT_sibling : <a3>
DW_AT_ordering : 1 (column major)
DW_AT_is_shared_type: 1
DW_AT_type : <85>
<2><9c>: Abbrev Number: 6 (DW_TAG_subrange_type)
DW_AT_lower_bound : 1
DW_AT_upper_bound : 3
<2><9f>: Abbrev Number: 6 (DW_TAG_subrange_type)
DW_AT_lower_bound : 1
DW_AT_upper_bound : 5
<2><xx>: Abbrev Number: 6 (DW_TAG_subrange_type)
DW_AT_is_co_shape : 1
DW_AT_lower_bound : 0
DW_AT_upper_bound : 10
<2><xx>: Abbrev Number: 6 (DW_TAG_subrange_type)
DW_AT_is_co_shape : 1
DW_AT_lower_bound : 0
DW_AT_upper_bound : 15
<1><a3>: Abbrev Number: 7 (DW_TAG_subprogram)
DW_AT_name : _main
DW_AT_low_pc : 0
DW_AT_high_pc : 0xfc
DW_AT_calling_convention: 2 (program)
DW_AT_external : 1
DW_AT_frame_base : 1 byte block: 6f (DW_OP_reg31)
DW_AT_type : <77>
<2><ba>: Abbrev Number: 8 (DW_TAG_variable)
DW_AT_location : 2 byte block: 91 18 (DW_OP_fbreg: 24)
DW_AT_name : a
DW_AT_decl_file : 1
DW_AT_decl_line : 0
DW_AT_type : <92>
There are similar constructs in other languages, Some only replicate the part
of the object/array that is actually referenced/used while some replicate the
full array (like corray fortran). in both cases there is a need to find out
which image has a specific array element, The information would be slightly
differently used in the two cases, but the need to describe the distribution
is the same.