Hi!
On 2024-03-13T10:12:17+0100, I wrote:
> On 2024-03-07T17:02:02+0900, Chung-Lin Tang
> wrote:
>> Also added simple 'declare' tests, but there is not anything to scan in the
>> 'tree-original' dump though.
>
> Yeah, the current OpenACC 'declare' implementation is "special".
Actually -- commit 38958ac987dc3e6162e2ddaba3c7e7f41381e079
"OpenACC 2.7: front-end support for readonly modifier: Add basic OpenACC
'declare' testing",
see attached.
But I realized another thing: don't we have to handle the 'readonly'
modifier also in Fortran module files, that is, next to the OpenACC
'declare' 'copyin' handling in 'gcc/fortran/module.cc':
'AB_OACC_DECLARE_COPYIN' etc.? Chung-Lin, please check, via test cases.
'gfortran.dg/goacc/routine-module*', for example, should provide some
guidance of how to achieve actual module file use, and then do the same
'scan-tree-dump' as in the current 'readonly' modifier test cases.
I suppose the code changes would look similar to
commit a61f6afbee370785cf091fe46e2e022748528307
"OpenACC 'nohost' clause", for example. By means of only emitting a tag
in the module file if the 'readonly' modifier is specified, we should
maintain compatibility with the current 'MOD_VERSION'.
Grüße
Thomas
>> diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
>> index 7b154eb3ca7..db84b06289b 100644
>> --- a/gcc/fortran/dump-parse-tree.cc
>> +++ b/gcc/fortran/dump-parse-tree.cc
>> @@ -1400,6 +1400,9 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n)
>> fputs (") ALLOCATE(", dumpfile);
>>continue;
>> }
>> + if ((list_type == OMP_LIST_MAP || list_type == OMP_LIST_CACHE)
>> + && n->u.map.readonly)
>> +fputs ("readonly,", dumpfile);
>>if (list_type == OMP_LIST_REDUCTION)
>> switch (n->u.reduction_op)
>>{
>> @@ -1467,7 +1470,7 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n)
>>default: break;
>>}
>>else if (list_type == OMP_LIST_MAP)
>> -switch (n->u.map_op)
>> +switch (n->u.map.op)
>>{
>>case OMP_MAP_ALLOC: fputs ("alloc:", dumpfile); break;
>>case OMP_MAP_TO: fputs ("to:", dumpfile); break;
>> diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
>> index ebba2336e12..32b792f85fb 100644
>> --- a/gcc/fortran/gfortran.h
>> +++ b/gcc/fortran/gfortran.h
>> @@ -1363,7 +1363,11 @@ typedef struct gfc_omp_namelist
>> {
>>gfc_omp_reduction_op reduction_op;
>>gfc_omp_depend_doacross_op depend_doacross_op;
>> - gfc_omp_map_op map_op;
>> + struct
>> +{
>> + ENUM_BITFIELD (gfc_omp_map_op) op:8;
>> + bool readonly;
>> +} map;
>>gfc_expr *align;
>>struct
>> {
>> diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
>> index 38de60238c0..5c44e666eb9 100644
>> --- a/gcc/fortran/openmp.cc
>> +++ b/gcc/fortran/openmp.cc
>> @@ -1210,7 +1210,7 @@ gfc_match_omp_map_clause (gfc_omp_namelist **list,
>> gfc_omp_map_op map_op,
>> {
>>gfc_omp_namelist *n;
>>for (n = *head; n; n = n->next)
>> -n->u.map_op = map_op;
>> +n->u.map.op = map_op;
>>return true;
>> }
>>
>> @@ -1524,7 +1524,7 @@ gfc_match_omp_clause_reduction (char pc,
>> gfc_omp_clauses *c, bool openacc,
>> gfc_omp_namelist *p = gfc_get_omp_namelist (), **tl;
>> p->sym = n->sym;
>> p->where = p->where;
>> -p->u.map_op = OMP_MAP_ALWAYS_TOFROM;
>> +p->u.map.op = OMP_MAP_ALWAYS_TOFROM;
>>
>> tl = >lists[OMP_LIST_MAP];
>> while (*tl)
>> @@ -2181,11 +2181,25 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const
>> omp_mask mask,
>> {
>>if (openacc)
>> {
>> - if (gfc_match ("copyin ( ") == MATCH_YES
>> - && gfc_match_omp_map_clause (>lists[OMP_LIST_MAP],
>> - OMP_MAP_TO, true,
>> - allow_derived))
>> -continue;
>> + if (gfc_match ("copyin ( ") == MATCH_YES)
>> +{
>> + bool readonly = gfc_match ("readonly : ") == MATCH_YES;
>> + head = NULL;
>> + if (gfc_match_omp_variable_list ("",
>> + >lists[OMP_LIST_MAP],
>> + true, NULL, , true,
>> + allow_derived)
>> + == MATCH_YES)
>> +{
>> + gfc_omp_namelist *n;
>> + for (n = *head; n; n = n->next)
>> +{
>> + n->u.map.op = OMP_MAP_TO;
>> + n->u.map.readonly = readonly;
>> +}
>> + continue;
>> +}
>> +}
>> }
>>else if