This is an archive of the discontinued LLVM Phabricator instance.

[flang][NFC] Add F2023X documentation
ClosedPublic

Authored by klausler on Jun 27 2023, 1:43 PM.

Details

Summary

Add a document that summarizes Fortran 202X's upcoming
features and their urgency for implementation.

Diff Detail

Event Timeline

klausler created this revision.Jun 27 2023, 1:43 PM
Herald added a project: Restricted Project. · View Herald Transcript
klausler requested review of this revision.Jun 27 2023, 1:43 PM
everythingfunctional added inline comments.
flang/docs/F202X.md
91–96

I'd be curious to know if you have any examples of real world code that rely on the length of a buffer not changing, or would have meaningful different observable behaviour. In my experience the typical usage would be more like:

character(:), allocatable :: buffer
allocate(character(20)::buffer)
write(buffer,'F5.3') 3.14159
print *, trim(buffer)

which wouldn't show observably different behavior. Or at worst:

character(:), allocatable :: buffer
allocate(character(20)::buffer)
write(buffer,'F5.3') 3.14159
print *, buffer

where it is observably different (no more trailing blanks), but is likely to be a welcome change, not an unwelcome one.

klausler added inline comments.Jun 27 2023, 5:13 PM
flang/docs/F202X.md
91–96

I'm going to have to add portability warnings for usage of deferred-length character allocatables in these contexts and see how often they are triggered by nonclassified codes in order to give you an accurate reproducible answer to that. Part of the difficulty here is that this isn't usage that can be easily grepped for.

flang/docs/F202X.md
91–96

I think you're going to get a lot of false positives that way. I suspect the majority of cases will be from code that looks like:

character(:), allocatable :: buffer
allocate(character(1000) :: buffer)
write(buffer, 'F5.3') 3.14159
buffer = trim(buffer)

and are going to go, oh good, I can delete those two lines and just write:

character(:), allocatable :: buffer
write(buffer, 'F5.3') 3.14159

Now how do I turn the warning off? I'll tell you right now I'm in that camp.

My reading of your answer is either:

  • "I don't know of any code that will actually break, but I'd like to scare everybody anyway", or
  • "I know of some code that will break, but I'm not going to go to the effort of telling you what the problem actually is"

Thanks for putting up this document. Very informative and likely good feedback for standards committee members. I see that Brad has already commented, may be Mark and Gary also might be interested.

A comment on the source line changes, relaxation for BOZ constants, using rank-one arrays to specify the rank and bounds of arrays might be useful.

flang/docs/F202X.md
141

There might be some performance benefits if lowering can use llvm attributes like argmem/argmemonly for simple functions.
https://github.com/llvm/llvm-project/blob/main/llvm/docs/Frontend/PerformanceTips.rst#modeling-memory-effects

199

Is Select case support for enumeration types new?

Thanks for putting up this document. Very informative and likely good feedback for standards committee members. I see that Brad has already commented, may be Mark and Gary also might be interested.

A comment on the source line changes, relaxation for BOZ constants, using rank-one arrays to specify the rank and bounds of arrays might be useful.

F18 has always had no limit on free from source line length; are there other source line changes that I missed?

The BOZ literal changes originated in other implementations and they should already work in f18. Some compilers allow BOZ as output statement I/O data items, and that is intentionally not supported.

I did miss the thing about using vectors for bounds in array declarations; will read up on that and add it. Thanks for the tip!

flang/docs/F202X.md
141

My understanding is that calls to PURE procedures could use memory(read, argmem:readwrite, inaccessiblemem:readwrite) and SIMPLE could drop the read. Is that also what you have in mind?

Calls to SIMPLE procedures from DO CONCURRENT are also safe from the bug that feature has with PURE procedures.

199

It must be, since ENUMERATION TYPE is new in F202X.

Thanks for putting up this document. Very informative and likely good feedback for standards committee members. I see that Brad has already commented, may be Mark and Gary also might be interested.

A comment on the source line changes, relaxation for BOZ constants, using rank-one arrays to specify the rank and bounds of arrays might be useful.

F18 has always had no limit on free from source line length; are there other source line changes that I missed?

The BOZ literal changes originated in other implementations and they should already work in f18. Some compilers allow BOZ as output statement I/O data items, and that is intentionally not supported.

For both these (line-length and BOZ) I was thinking a statement like the above will be good for conveying the status of these features.

There is probably a requirement to provide warnings or errors if these limits are breached for source line length.
6.3.2.1 A line shall contain at most ten thousand characters.
6.3.2.6 A statement shall not have more than one million characters.

I did miss the thing about using vectors for bounds in array declarations; will read up on that and add it. Thanks for the tip!

flang/docs/F202X.md
141

Yes, I am hoping that the argument-only memory access might help enable more optimisation since it does not access any global memory.

We have seen in the past a case where there are two usages of the same pure function with the same arguments and it required classic-flang to provide the memory attributes to do a CSE.

bose_f in the following example.
https://github.com/yambo-code/yambo/blob/931e54cd54d721ca5cbbe8df3cfae4b6e2f1ffc8/src/qp/QP_ppa_cohsex.F#L622

There is probably a requirement to provide warnings or errors if these limits are breached for source line length.
6.3.2.1 A line shall contain at most ten thousand characters.
6.3.2.6 A statement shall not have more than one million characters.

Fortran compilers are supposed to check numbered constraints and report on violations, but "shall"s in other text are optional. (And it's all on the honor system anyway -- there's no validation test suite or certification process.)

The 10,000 character limit per line would be easy to check, but the statement limit on characters would require some thought and would cost more than o(statements).

klausler updated this revision to Diff 535861.Jun 29 2023, 9:47 AM

Edits to reflect review comments.

This revision is now accepted and ready to land.Jun 29 2023, 10:20 AM
This revision was landed with ongoing or failed builds.Jul 3 2023, 10:18 AM
This revision was automatically updated to reflect the committed changes.