Re: Can't link assembly routines

2024-03-14 Thread rep . dot . nop
On 13 March 2024 19:43:27 CET, Steve Kargl  
wrote:
>On Wed, Mar 13, 2024 at 12:05:16PM +, Ken Woolridge wrote:
>> 
>> When I attempt to link my test program (FF.F90) which calls UPPER_CASE (an 
>> assembly routine) I get the following error:
>> 
>> C:/Program 
>> Files/GCC/bin/../lib/gcc/i686-pc-mingw32/13.2.0/../../../../i686-pc-mingw32/bin/ld.exe:
>>  FF.OBJ:FF.F90:(.text+0x10c): undefined reference to `upper_case_'
>> collect2.exe: error: ld returned 1 exit status
>
>Well, does your archive contain a symbol name upper_case_?
>

See -funderscoring (sp)?
I think nowadays, you would use ISO_C_BINDING to describe the interface, 
though. I'm pretty sure that is documented somewhere..


Re: OpenACC 2.7: front-end support for readonly modifier: Add basic OpenACC 'declare' testing

2024-03-14 Thread Tobias Burnus

Hi all, hi Thomas & Chung-Lin,

Thomas Schwinge wrote:

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.?


I bet so; it is not as bad as with the others as it is "only" an 
optimization hint, but it makes sense to make it available.


Note that when you place the 'module' in the same file as the module 
users ('use'), the compiler might know things because they are in the 
same translation unit / file not because it is in the module ...



  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.

...

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'.


That was the idea: If only new information gets added (if used), older 
compilers still work. This has huge limitations and does not work as 
well as imagined but here it should work: Older .mod will work with new 
compilers, even though the reverse might not be true.


Tobias


Re: OpenACC 2.7: front-end support for readonly modifier: Add basic OpenACC 'declare' testing

2024-03-14 Thread Tobias Burnus

Hi all, hi Thomas & Chung-Lin,

Thomas Schwinge wrote:

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.?


I bet so; it is not as bad as with the others as it is "only" an
optimization hint, but it makes sense to make it available.

Note that when you place the 'module' in the same file as the module
users ('use'), the compiler might know things because they are in the
same translation unit / file not because it is in the module ...


  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.

...

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'.


That was the idea: If only new information gets added (if used), older
compilers still work. This has huge limitations and does not work as
well as imagined but here it should work: Older .mod will work with new
compilers, even though the reverse might not be true.

Tobias


OpenACC 2.7: front-end support for readonly modifier: Add basic OpenACC 'declare' testing (was: [PATCH, OpenACC 2.7, v2] readonly modifier support in front-ends)

2024-03-14 Thread Thomas Schwinge
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