Skip to content

[Flang][OpenMP] Add OpenMP standards support doc #132707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kiranchandramohan
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the flang Flang issues not falling into any other category label Mar 24, 2025
| target teams distribute parallel loop construct | P | |
| teams distribute parallel loop simd construct | P | |
| target teams distribute parallel loop simd construct | P | |

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am conservatively marking all target-related constructs (including combined ones) as Partial support. I can correct the entries if they are fully supported.

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together Kiran.

Copy link
Contributor Author

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tblah for the quick review.

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor suggestions


This document summarizes OpenMP standards support in Flang. The information is only provided as a guideline. The
TODOs/Not Yet Implemented messages emitted by the compiler for unimplemented features should be treated as authoritative.
Standards support is provided upto OpenMP 4.0 for now. It will be extended later for OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth putting in a date here, so there is some indication of how valid this sentence is?

Suggested change
Standards support is provided upto OpenMP 4.0 for now. It will be extended later for OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.
As of March 2025, standards support is provided upto OpenMP 4.0. It will be extended later for OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.

Are we working on support for OpenMP > 4.0? If so, perhaps the second sentence could be rephrased to better reflect this. Perhaps

We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0. 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we working on support for OpenMP > 4.0?

Yes. Some might be working already. Just that I have not spent time characterising the support.

Your suggestions look good. Have made the change.

- **Y** : When the implementation is complete
- **N** : When the implementation is absent

Note : No distinction is made between the support in the Parser/Semantics, MLIR or Lowering support, and OpenMPIRBuilder support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another optional rephrase (if I understand your intent correctly)

Suggested change
Note : No distinction is made between the support in the Parser/Semantics, MLIR or Lowering support, and OpenMPIRBuilder support.
Note : No distinction is made between the support in Parser/Semantics, MLIR, Lowering or the OpenMPIRBuilder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@NimishMishra NimishMishra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for compiling this. I am okay with the list and their current status.

Are we not adding task construct though?

@kiranktp
Copy link
Contributor

I think we are missing taskgroup as well.

@kiranchandramohan
Copy link
Contributor Author

Are we not adding task construct though?

I think we are missing taskgroup as well.

These came in OpenMP 3.0/3.1. Or do you mean there is something unsupported that you want to report?

@NimishMishra
Copy link
Contributor

These came in OpenMP 3.0/3.1. Or do you mean there is something unsupported that you want to report?

Okay understood. I think we want to say we support OpenMP 4.0 + additional features which we list in the table. I got confused with the line "The standards support information is provided as a table with three columns that are self explanatory. The Status column uses the letters P, Y, N for the implementation status"

---
```

This document summarizes OpenMP standards support in Flang. The information is only provided as a guideline. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This document summarizes OpenMP standards support in Flang. The information is only provided as a guideline. The
This document summarizes the supported features of the OpenMP API in Flang. The information is only provided as a guideline. The

(OpenMP is not a standard in the true sense, like with the ISO standards.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be OK to go with OpenMP specification?
This document summarizes the supported features of the OpenMP specification in Flang

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


This document summarizes OpenMP standards support in Flang. The information is only provided as a guideline. The
TODOs/Not Yet Implemented messages emitted by the compiler for unimplemented features should be treated as authoritative.
As of March 2025, standards support is provided upto OpenMP 4.0. We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that it has been requested to have a date in the document, but I would treat the modification date of the file in the commit log as being more accurate than the date in the document that could easily be missed when updating the file (plus, it does not protect us from the document becoming outdated over time).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that https://clang.llvm.org/docs/OpenMPSupport.html has split OpenMP support into C/C++ & Fortran already. Presumably it makes sense to either fully join those documents, or remove the Fortran side from the clang docs, and just add a reference to this document.

Also typo

Suggested change
As of March 2025, standards support is provided upto OpenMP 4.0. We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.
As of March 2025, standards support is provided up to OpenMP 4.0. We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.

From the table below, OpenMP 4.0 support is not 100% complete yet, so maybe "up to" gives a wrong impression here; I'd read it as "4.0 support is fully implemented".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that https://clang.llvm.org/docs/OpenMPSupport.html has split OpenMP support into C/C++ & Fortran already. Presumably it makes sense to either fully join those documents, or remove the Fortran side from the clang docs, and just add a reference to this document.

Would it be all right to address this separately? Ideally, each Frontend should list its OpenMP support separately. Removing the entry from Clang would require a separate set of reviewers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote the statement regarding standards support.

Changing the support statement in Clang docs is out of scope for this PR.

| target teams distribute parallel loop simd construct | P | |

## OpenMP 3.1, OpenMP 2.5, OpenMP 1.1
All features except a few corner cases in atomic, copyin constructs/clauses are supported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these corner cases be made explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

tblah added a commit to tblah/llvm-project that referenced this pull request Mar 31, 2025
Precise OpenMP standards support information is being documented in llvm#132707

Flang now has good support for OpenMP Version 3.1 and earlier.
tblah added a commit that referenced this pull request Apr 2, 2025
Precise OpenMP standards support information is being documented in
#132707

Flang now has good support for OpenMP Version 3.1 and earlier.
Copy link
Contributor

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm excited to see this, thanks for adding it! This will close an old issue of mine :)

Comment on lines 23 to 25
- **P** : When the implementation is incomplete for a few cases
- **Y** : When the implementation is complete
- **N** : When the implementation is absent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to explain that this is Yes/No/Partial (presumably)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


This document summarizes OpenMP standards support in Flang. The information is only provided as a guideline. The
TODOs/Not Yet Implemented messages emitted by the compiler for unimplemented features should be treated as authoritative.
As of March 2025, standards support is provided upto OpenMP 4.0. We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that https://clang.llvm.org/docs/OpenMPSupport.html has split OpenMP support into C/C++ & Fortran already. Presumably it makes sense to either fully join those documents, or remove the Fortran side from the clang docs, and just add a reference to this document.

Also typo

Suggested change
As of March 2025, standards support is provided upto OpenMP 4.0. We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.
As of March 2025, standards support is provided up to OpenMP 4.0. We are actively working towards supporting OpenMP 4.5, OpenMP 5.* and OpenMP 6.0.

From the table below, OpenMP 4.0 support is not 100% complete yet, so maybe "up to" gives a wrong impression here; I'd read it as "4.0 support is fully implemented".

OpenMP standard -> OpenMP API
specify corner cases for atomic, threadprivate
Nit spellings
Copy link
Contributor

@bhandarkar-pranav bhandarkar-pranav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Kiran. Just one minor nit.


This document outlines the OpenMP API features supported by Flang. It is intended as a general reference.
For the most accurate information on unimplemented features, rely on the compiler’s TODO or “Not Yet Implemented”
messages, which are considered authoritative. Flang provides full support for OpenMP 3.1 and partial support for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Like you mention in the section on previous standards (<=3.1) there are some, albeit very few, corner cases that are not supported. I think this line here is then misleading; it'll make a reader believe 3.1 is fully supported and chances are he won't bother to scroll down to the section below to find info about the corner cases. Perhaps consider something like, but not necessary exactly, the following

Aside from very few corner cases, Flang provides full support for OpenMP 3.1 [See detail here](#OpenMP 3.1,-OpenMP 2.5,-OpenMP-1.1). There is also partial (in development) support for OpenMP 4.0

(Note: I may have got the link syntax wrong especially around the use of commas).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

@kiranchandramohan kiranchandramohan force-pushed the openmp_standards_support branch from 292a350 to 3230516 Compare April 9, 2025 16:55
Copy link
Contributor

@kparzysz kparzysz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

For any target construct we don't support the device clause. For distribute we don't support dist_schedule. For teams, we don't fully support reduction (e.g. no declare reduction).

@kiranchandramohan
Copy link
Contributor Author

I plan to submit this PR early next week if there are no objections.

Copy link
Contributor

@NimishMishra NimishMishra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for this.

@kiranchandramohan kiranchandramohan merged commit 2c2ba7e into llvm:main Apr 22, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants