This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpenMP] Restrict types for omp.parallel args
ClosedPublic

Authored by shraiysh on Apr 20 2022, 7:33 PM.

Details

Summary

This patch restricts the value of if clause expression to an I1 value.
It also restricts the value of num_threads clause expression to an I32
value.

Diff Detail

Event Timeline

shraiysh created this revision.Apr 20 2022, 7:33 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 20 2022, 7:33 PM
shraiysh requested review of this revision.Apr 20 2022, 7:33 PM
ftynse added a subscriber: ftynse.Apr 26 2022, 1:26 AM

Any reason to restrict num_threads to be 32-bit specifically? The spec says it must evaluate to a positive integer value, nothing about its size. I would rather keep it as AnyInteger, and maybe even allowed Index.

Any reason to restrict num_threads to be 32-bit specifically? The spec says it must evaluate to a positive integer value, nothing about its size. I would rather keep it as AnyInteger, and maybe even allowed Index.

We can use IntLikeType for this.

shraiysh updated this revision to Diff 426237.Apr 30 2022, 10:27 AM

Any reason to restrict num_threads to be 32-bit specifically? The spec says it must evaluate to a positive integer value, nothing about its size. I would rather keep it as AnyInteger, and maybe even allowed Index.

We can use IntLikeType for this.

I kept it i32 mainly because OpenMP Runtime Library accepts it as i32. I am changing it to IntLikeType as suggested, however I think Index also suits the intent. Let me know if we want to change it to Index type and I will do so.

LGTM.
You may have some of the tests for num_threads with index, i64 etc.

flang/test/Lower/OpenMP/parallel.f90
20

Nit: Can you add a non-default kind for logical and test that too?

This revision is now accepted and ready to land.Apr 30 2022, 11:28 PM
shraiysh updated this revision to Diff 426336.May 1 2022, 11:12 PM

Addressed comments

This revision was automatically updated to reflect the committed changes.