Issue 230530.1: Data Sharing Attribute
| Author: | Jakub Jelinek |
|---|---|
| Champion: | Jakub Jelinek |
| Date submitted: | 2023-05-30 |
| Date revised: | 2024-03-18 |
| Date closed: | |
| Type: | Enhancement |
| Status: | Open |
| DWARF version: | 6 |
Background
OpenMP/OpenACC allows sharing, mapping or privatization of variables in OpenMP/OpenACC constructs. It can be useful to let the debugger know when variables are shared, mapped or privatized and which kind of privatization it is.
Dumb example:
void foo (int *g)
{
int a = 42, b = 16, c, d, e = 16, f;
#pragma omp parallel shared(a) firstprivate (b) private (c)
{
c = 0;
#pragma omp atomic
a++;
#pragma omp for firstprivate (e) lastprivate (e) private (d)
for (f = 0; f < 16; f++)
{
d = b + c + f;
g[d] = e;
if (f == 15)
e = 8;
}
}
#pragma omp target map(tofrom: a)
{
a += e;
}
}
Here, a is explicitly shared in the parallel region (all threads operate on the same variable), e is implicitly shared there, c is privatized (each thread gets a distinct copy of the variable, for e.g. C++ default constructed), b is firstprivatized (like privatization, but each copy is initialized from the original variable; for e.g. C++ copy constructed) and on the worksharing loop d is privatized (each thread on that construct only has a private copy) and e is also privatized, initialized from the original at the start and value from last iteration copied back. f is implicitly privatized in that loop. And in the offloading region a is explicitly mapped to the other device and value copied back at the end, while e is implicitly firstprivatized. Only firstprivate+lastprivate is allowed on the same variable in one construct, other data sharing states should be exclusive in the same OpenMP/OpenACC construct, though the same variable could be e.g. shared in outer parallel construct and then privatized in inner task construct.
Proposed Changes
Add in Table 2.2:
DW_AT_data_sharing Data sharing or mapping (OpenMP or OpenACC)
Insert before 2.11 Artificial Entries and renumber:
2.11 Data Sharing or Mapping of Declarations
OpenMP or OpenACC allow privatization, sharing or mapping of declarations or their parts inside the body of certain constructs.
The data sharing attribute or mapping of a declaration is represented by
DW_AT_data_sharingattribute on a local copy of the declaration's debugging information entry, whose value is a bitwise or of constants drawn from the set of codes listed in Table 2.XX.Table 2.XX Data sharing or mapping attributes DW_DATASHARING_none DW_DATASHARING_shared DW_DATASHARING_private DW_DATASHARING_firstprivate DW_DATASHARING_lastprivate DW_DATASHARING_reduction DW_DATASHARING_mapped DW_DATASHARING_implicit DW_DATASHARING_lo_user DW_DATASHARING_hi_user
DW_DATASHARING_implicitis bitwise ORed into the value if the data sharing or mapping has been determined implicitly (predetermined or implicitly determined) and should be clear if it has been specified explicitly.If bits from
DW_DATASHARING_lo_usertoDW_DATASHARING_hi_userare set, it is vendor-defined data sharing.In section 7.1 Vendor Extensibility, add
DW_DATASHARING,beforeDW_ENDin second paragraph.
In Table 7.5 add
DW_AT_data_sharing ‡ 0x94 constant
Insert before 7.12 Source Languages and renumber:
7.12 Data Sharing Codes
The encodings of the constants used in the
DW_AT_data_sharingattribute are given in Table 7.XX.Table 7.XX: Data Sharing encodings Data Sharing name Value ------------------------------------- DW_DATASHARING_none 0x00 DW_DATASHARING_shared 0x01 DW_DATASHARING_private 0x02 DW_DATASHARING_firstprivate 0x04 DW_DATASHARING_lastprivate 0x08 DW_DATASHARING_reduction 0x10 DW_DATASHARING_mapped 0x20 DW_DATASHARING_implicit 0x40 DW_DATASHARING_lo_user 0x100000 DW_DATASHARING_hi_user 0xfff00000The value
DW_DATASHARING_noneis equivalent to the absence of theDW_AT_data_sharingattribute.
Appendix A.
Add DW_AT_data_sharing to DW_TAG_variable.
2024-03-18: Rename DW_AT_DATA_SHARING to DW_DATASHARING. Fixes in the Background section. Add vendor extensibility.