Hi Gerald,
Gerald Pfeifer wrote:
+ <li>OpenACC 3.4: In Fortran, named constants (<code>PARAMETER</code>) used as
+ <em>var</em> in clauses are now accepted (and ignored as not being
+ required). The support for named constants has been added to the
+ specification and GCC for better compatibility with existing code.</li>
2) Just "Support for ..." (without "The").
3) I'm afraid I don't understand the phrase "(and ignored as not being
required)". As in, I'm not trying to be difficult, I simply don't get
it - which may be due to me not being a Fortran nor OpenACC expert.
Wild guess: are you thinking "optionally accepted"?
Well, I am not sure that that wording is any clearer …
Answer:
Yes in the sense: It makes no sense to specify it, but if the user
insists, GCC now accepts it as clause argument - and does nothing
with it (→ removes/ignores is).
Before OpenACC 3.4, it was invalid to specify it but other compilers
accepted it - such that real-world code uses it. Now compilers
are supposed to accept it - but may ignore/remove it after parsing.
* * *
Do you have a better wording suggestion?
Otherwise, I will just remove the parenthesized words.
* * *
Long version:
Code uses something like this: First, a named constant
is defined such as
real, parameter :: pi = 3.1415
! This is similar but not the same as
! C23's and (a bit more similar) C++'s
! constexpr float pi = 3.1415;
... and then the compiler is instructed to put it
on the device; for instance
!$acc declare copyin(pi)
! — or —
!$acc enter date copyin(pi)
... where 'create' and 'copyin' are clauses.
However, according OpenACC <= 3.3, 'pi' is not a _var_ / variable
and in case of GCC, the symbol 'pi' also never materializes,
being resolved to its numeric value whenever used.
It turned out that the Nvidia compiler, which is the main OpenACC
compiler, actually accepts code like the one above - and that
there is code out there, which uses it. - For instance, the
ICON weather/climate model does.
As real-world code is unlikely to change, the OpenACC 3.4 spec
now has the following wording:
"In this spec, a _var_ (in italics) is one of the following:
...
• a named constant in Fortran.
If during an optimization phase _var_ is removed by the compiler,
appearances of _var_ in data clauses are ignored. […]".
Hence: named constants are now permitted according to the spec
and also with gfortran, but gfortran removes the clause
(ignores it, "optimized" it away) in the frontend - such that
no middle-end code is generated for the clause.
(I am relatively certain that other compilers also do not require
the clause - even if they accept it, but I have not experimented.)
Tobias
PS: Note that everything above is only for clauses that take a _var_
as argument (→ data clauses); named constants were and are perfectly
fine for those clauses taking expressions.