This is an archive of the discontinued LLVM Phabricator instance.

Meta directive runtime support
Needs ReviewPublic

Authored by abidmalikwaterloo on Mar 22 2022, 12:48 PM.

Details

Reviewers
jdoerfert
ABataev
Summary

The patch extends the current implementation
for runtime support. The current patch build AST
of the when clauses in sorted order using the
context selector score

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 12:48 PM
abidmalikwaterloo requested review of this revision.Mar 22 2022, 12:48 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript

This contains a lot of unrelated changes, leftover comments, etc. As you clean up the code, please also include tests. Clang format the patch, go over the new code and make sure you follow the coding style. Remove unneeded parts (e.g., a map into which you simply push objects then take them out to push them into a vector).

Also, have you seen D120573?

I quickly went through the D120573. There are many overlapping.

Is it okay if I can put comments on the patch?

Is it okay if I can put comments on the patch?

Not sure what you mean but feel free.

would it make sense to submit separate patches for when (OMPC_when) and otherwise (OMPC_otherwise) clauses? The D120573 also has OMPC_when support.

There should be an update to D122255. It should not create the new one.D123598
--->
I did the following :
arc patch D122255
"did something/cleaning"
git commit -a
arc diff
---->

I update it but it created a new patch D123598.
I marked it Abandon. Not sure how to delete it.
I am submitting it again after cleaning the codes
and adding some basic tests.

The last update removed all previous updates. Can you point me to the correct way to do it?
I did the following :
arc patch D122255
"did something/cleaning"
git commit -a --amend
arc diff

Cleaned the code and added tests.

Should I update the patch? I am waiting for quick feedback on the concept of handling conditions.

ABataev added inline comments.
clang/include/clang/AST/OpenMPClause.h
8980

condition?

9014–9015

make it private

9021

const

9026

const

clang/include/clang/AST/StmtOpenMP.h
5889

Remove this change

clang/include/clang/Basic/DiagnosticSemaKinds.td
11085

We do not use explamations in messages, better to have something only single default ...

clang/include/clang/Sema/Sema.h
11212

Comment for this new function

11721

formatting

clang/lib/AST/OpenMPClause.cpp
1675–1678

Is this correct? Just default( is expected to be printed?

clang/lib/AST/StmtPrinter.cpp
720

Do not insert empty line here

721–722

formatting

726

use isa

728

Camel naming style expceted

729

formatting, use nullptr instead of NULL (or just C)

730

Formatting

clang/lib/Parse/ParseOpenMP.cpp
2488

What is this?

2539

Restore original code here

2562–2571

Remove this extra stuff

2618

What A stands after, what does it mean?

abidmalikwaterloo marked 2 inline comments as done.Jun 30 2022, 11:19 AM
abidmalikwaterloo added inline comments.
clang/include/clang/AST/OpenMPClause.h
9014–9015

Any reason behind this? I went through other classes, this function is public in some and private in some.

ABataev added inline comments.Jun 30 2022, 11:37 AM
clang/include/clang/AST/OpenMPClause.h
9014–9015

The AST is immutable, such functions are/must be used in very rare places.

abidmalikwaterloo marked 14 inline comments as done.

Updated and clean the code based on the comments from
the reviewer!

Ping!

clang/lib/AST/OpenMPClause.cpp
1675–1678

This function is called from StmtPrinter::PrintOMPExecutableDirective in StmtPrinter.CPP. The enclosed Directive and the second matching brace will be printed. See line # 670 in StmtPrinter.CPP

clang/lib/Parse/ParseOpenMP.cpp
2488

comment removed

jdoerfert added inline comments.Jul 12 2022, 2:12 PM
clang/include/clang/Basic/DiagnosticSemaKinds.td
11085

"allowed in" what? Also, there is no test for this, or is there?

clang/lib/AST/OpenMPClause.cpp
1675–1678

The problem is this doesn't make sense. For one, StmtPrinter calls this function conditionally, so you might end up with a lonely closing parenthesis. Also, why would we split the parenthesis into two places?

1740

I'm assuming we already have a printer for trait selectors, no? Doesn't OMPTraitInfo::print do this already and actually handle scores?

clang/lib/AST/StmtPrinter.cpp
728
clang/lib/Parse/ParseOpenMP.cpp
2539

There are plenty of formatting changes in this file and elsewhere. Please retore the original code or properly clang-format the patch.

2619

typo

2669

We don't use comments like these.

2710

This seems to be copied from somewhere. It is unclear why a metadirective needs to have an associated openmp region.

clang/lib/Sema/SemaOpenMP.cpp
4945

Still unrelated newlines.

7751

Code style, ArchMatch.

7800

Why does this perform partial trait matching? We should have code for this. Also, the logic for device_arch and vendor (which is most what there is), is not what we want. Reuse the existing matching logic instead.

clang/lib/Sema/SemaStmt.cpp
4826

Unrelated. Please go over the patch and avoid these in the future. We have so many comments that point out these things that now the comments make it hard to read/review.

clang/test/OpenMP/metadirective_ast_print_new_1.cpp
21

I doubt clang format handles the metadirective well but maybe format the code first without the pragma. This is hard to read. Also the other tests.

You only have ast print tests, what about the rest? Messages (errors/warnings) and codegen?

llvm/lib/Frontend/OpenMP/OMPContext.cpp
375

This does not sort scores properly and for some reason uses a Map as a intermediate storage.
Instead, please combine this with the function below, which already has a proper score comparator.

abidmalikwaterloo marked 4 inline comments as done.Jul 21 2022, 11:56 AM
abidmalikwaterloo added inline comments.
clang/include/clang/Basic/DiagnosticSemaKinds.td
11085

It should be "Only one default clause is allowed.

clang/lib/AST/OpenMPClause.cpp
1740

Looked into the function. OMPTraitInfo::print can be used. The function needs to be extended as well to take the other traits as well.

clang/lib/Sema/SemaOpenMP.cpp
7800

Ok. What do you mean by existing matching logic?

clang/lib/Sema/SemaStmt.cpp
4826

An accidental tap. Removed

abidmalikwaterloo marked 4 inline comments as done.Jul 27 2022, 5:48 AM
abidmalikwaterloo added inline comments.
clang/include/clang/AST/RecursiveASTVisitor.h
3281

If it is not the user's condition or score then what will happen?

clang/lib/Sema/SemaOpenMP.cpp
7800

@jdoerfert I agree that the implementation is incomplete in terms of trait matching. It can be completed. However, I am not clear about your comments about the existing matching logic. I checked OMPContext.CPP and other files. There are functions that can be used to match the traits. But, I could not find any existing logic that can be used here.

jdoerfert added inline comments.Aug 24 2022, 7:33 AM
clang/lib/AST/OpenMPClause.cpp
1740

The function needs to be extended as well to take the other traits as well.

What traits are not handled there?

clang/lib/Sema/SemaOpenMP.cpp
7800

I mean getBestVariantMatchForContext and similar functions in llvm/lib/Frontend/OpenMP/OMPContext.cpp.

abidmalikwaterloo marked 2 inline comments as done.Aug 31 2022, 7:07 AM

I will work on the patch in parts. I am planning to submit taking care of comments except for comments for SemaOpenMP and code generation.

clang/lib/AST/OpenMPClause.cpp
1740

No. It handles everything in terms of printing. I have updated the code. Will upload it as well.

clang/lib/Parse/ParseOpenMP.cpp
2710

correcrted.

clang/lib/Sema/SemaOpenMP.cpp
7800

OK.

abidmalikwaterloo marked 2 inline comments as done.

Updated the PrintStmt.cpp according to the comments

ABataev added inline comments.Sep 20 2022, 12:50 PM
clang/lib/AST/OpenMPClause.cpp
20

Remove empty comment

1680–1681

if (Stmt *S = Node->getDirective())

2526–2534

Remove those empty new lines

abidmalikwaterloo marked 8 inline comments as done and an inline comment as not done.

Clean the formatting comments. The patch is out of attention
for a while. Still need to work on the context selector part
as a next step.

aeubanks removed a subscriber: aeubanks.Dec 15 2022, 7:59 PM

Rebase the patch to origin/main with all updates. Made changes
to make it buildable using the new changes.
(WIP).