Skip to content

[OpenMP][Flang]Fix omp_get_cancellation return type from integer to logical #142990

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
merged 1 commit into from
Jun 12, 2025

Conversation

Mxfg-incense
Copy link
Contributor

Fix #142833
According to the OpenMP 5.2 spec, modify the return type of omp_get_cancellation() to logical.

@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Jun 5, 2025
Copy link
Contributor

@eugeneepshteyn eugeneepshteyn left a comment

Choose a reason for hiding this comment

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

LGTM. Is it worth adding some sort of unit test?

@Mxfg-incense
Copy link
Contributor Author

LGTM. Is it worth adding some sort of unit test?

I’m not sure if it’s necessary to add a test. But I found that the earliest version of omp_get_cancellation(), as specified in the OpenMP 4.0 spec, already had its return value defined as a logical type, and this has not changed. It seems an error in the original implementation.

Copy link
Contributor

@mjklemm mjklemm left a comment

Choose a reason for hiding this comment

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

LGTM

@kparzysz
Copy link
Contributor

The C implementation returns int. I haven't had time to check myself, but do we know that the C return value is correctly translated into LOGICAL?

@eugeneepshteyn
Copy link
Contributor

The C implementation returns int. I haven't had time to check myself, but do we know that the C return value is correctly translated into LOGICAL?

Very good point. Luckily, OpenMP runtime uses 0 for FALSE and !0 for TRUE, and flang (like gfortran) uses 0 for .FALSE. and 1 for .TRUE., so I think it's compatible. If flang used -1 for .TRUE., then we would have a problem.

@Mxfg-incense
Copy link
Contributor Author

Who can help me merge this PR?

@el-ev el-ev merged commit 968d8ea into llvm:main Jun 12, 2025
11 checks passed
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flang][OpenMP] Incorrect signature for omp_get_cancellation()
6 participants