This is an archive of the discontinued LLVM Phabricator instance.

Flang semantic check support for tile and unroll OpenMP Directive.
Needs RevisionPublic

Authored by abidmalikwaterloo on Jan 27 2023, 6:28 PM.

Details

Summary

Added semantic check support for tile and unroll OpenMP Directive.
OpenMP 5.1

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 27 2023, 6:28 PM
abidmalikwaterloo requested review of this revision.Jan 27 2023, 6:28 PM
abidmalikwaterloo edited projects, added Restricted Project; removed Restricted Project.
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 6:32 PM
clementval requested changes to this revision.Jan 29 2023, 4:43 AM
clementval added a subscriber: clementval.

Looks like smth is missing from your patch. There is also clang-format errors.

This revision now requires changes to proceed.Jan 29 2023, 4:43 AM

Looks like smth is missing from your patch. There is also clang-format errors.

I just uploaded the header file to take feedback.

Looks like smth is missing from your patch. There is also clang-format errors.

I just uploaded the header file to take feedback.

Well there is not much to comment on.

Looks like smth is missing from your patch. There is also clang-format errors.

I just uploaded the header file to take feedback.

Well there is not much to comment on.

I will upload the implementation and test cases as well

Update the patch with basic support for semantic checks of
OpenMP Tile and Unroll Constructs
OpenMP 5.1

Herald added a project: Restricted Project. · View Herald Transcript

Corrected the format of tests

Format correction for omp-tile-size.f90

abidmalikwaterloo edited the summary of this revision. (Show Details)Mar 1 2023, 6:12 PM

Remove redundent code

Ping!

flang/lib/Semantics/check-omp-structure.h
257

Are there any more checks needed at this stage? Besides checking integer expression, the length of the list should be equal to the depth of the nested loops

flang/test/Semantics/OpenMP/omp-do-tile.f90
4

The build is failing on the tests. Is this the right way to write the semantic tests for Flang?

llvm/include/llvm/Frontend/OpenMP/OMP.td
72 ↗(On Diff #501738)

We need a list of integers to take care of the nested loops

!$omp tile sizes(size-list) 
   loop-nest 
[!$omp end tile]
luporl added a subscriber: luporl.Mar 6 2023, 9:37 AM
luporl added inline comments.
flang/test/Semantics/OpenMP/omp-do-tile.f90
3

Nit: it's better to put the !2.11.9.1 tile Cconstruct part on a new line.

4

There are extra spaces in your RUN line. This should work:
! RUN: %python %S/../test_errors.py %s %flang -fopenmp

7–8

test_errors.py will fail to match the error string here. It must be in a single line.

abidmalikwaterloo marked 2 inline comments as done.

Made changes to take semantic checks for OPENMP TILE--> SIZE clause so it
can take list of integers

Made corrcection in Formating

Added test for tile size clause

Make correction to the format of OMP.td

clementval added inline comments.Mar 17 2023, 9:09 AM
flang/lib/Semantics/check-omp-structure.cpp
424–425

I don't think the directive can be tile and unroll at the same time.

630

Remove

clementval added inline comments.Mar 17 2023, 9:15 AM
flang/test/Semantics/OpenMP/omp-do-tile.f90
9

Can you add test with non-constant integer. The standard does precise that

size-list is a list s1,…,sn of positive integer expressions.

clementval requested changes to this revision.Mar 17 2023, 9:18 AM
This revision now requires changes to proceed.Mar 17 2023, 9:18 AM
abidmalikwaterloo marked 2 inline comments as done.Mar 21 2023, 12:37 PM
abidmalikwaterloo added inline comments.
flang/test/Semantics/OpenMP/omp-do-tile.f90
9

Do you mean initialing a variable and then using it in the sizes clause: e.g. sizes (2, x, 2)?

Made changes based on the comments. No it does not check
for both tile and unroll constructs.

abidmalikwaterloo marked an inline comment as not done.Apr 4 2023, 7:45 AM

ping

kiranchandramohan requested changes to this revision.Apr 4 2023, 8:38 AM

Thanks for this patch. Have some request for changes.

flang/lib/Semantics/check-omp-structure.cpp
659

Nit: Remove commented code.

660

Nit: Do not use auto, specify the type here.

663
683
flang/lib/Semantics/check-omp-structure.h
63–73

Are these changes required?

72

Why is this change required?

flang/test/Parser/omp-tile-multisize.f90
10

Might be good to specify different sizes for each loop.

23–26

You have to check that the size for all loops. Only one is checked here.

flang/test/Semantics/OpenMP/omp-do-tile.f90
8
9

Yeah, an expression like 2 + 2.
Also a variable that is defined as constant.

integer, parameter :: x = -3
!$omp unroll partial(x)
...
flang/test/Semantics/OpenMP/omp-do-unroll.f90
4
This revision now requires changes to proceed.Apr 4 2023, 8:38 AM
abidmalikwaterloo marked an inline comment as done.Apr 6 2023, 9:19 AM
abidmalikwaterloo added inline comments.
flang/lib/Semantics/check-omp-structure.h
63–73

My understanding is that the tile/unroll constructs can be called from the most loop-related directives. That's why I make both of them part of the set.

72

Again, my understanding is there will set of constructs that will be called from the tileset.

abidmalikwaterloo marked 12 inline comments as done.

Made changes in check-omp-structure.cpp as per reviewer's comments. Added two new tests.

clementval added inline comments.Apr 17 2023, 11:21 AM
flang/test/Semantics/OpenMP/omp-do-tile.f90
9

Do you mean initialing a variable and then using it in the sizes clause: e.g. sizes (2, x, 2)?

yes

abidmalikwaterloo marked an inline comment as done.Apr 19 2023, 11:41 AM
abidmalikwaterloo added inline comments.
flang/test/Semantics/OpenMP/omp-do-tile.f90
9

Already included for tiles. Will include a test for unrolling as well

abidmalikwaterloo marked an inline comment as done.

Added a new test for unrolling construct with add expression

tschuett added inline comments.
flang/lib/Semantics/check-omp-structure.cpp
659

Do you need to check whether u is std::nullopt first before you do *u?

679

Same here.

flang/lib/Semantics/check-omp-structure.cpp
659

If it is std::nullopt, I do not think it is a semantic error. It will be a bug then. You initiate it when you see something in the clause. It can't be null. This is my understanding.

You always have to check optionals, before you can access its content.

clementval added inline comments.Aug 4 2023, 1:52 PM
flang/lib/Semantics/check-omp-structure.cpp
659

So you should use evaluate::ToInt64 directly.

kiranchandramohan requested changes to this revision.Aug 9 2023, 7:47 AM
kiranchandramohan added a subscriber: do.

@do Will you be taking over this patch?

This revision now requires changes to proceed.Aug 9 2023, 7:47 AM