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
8866

condition?

8900–8901

make it private

8907

const

8912

const

clang/include/clang/AST/StmtOpenMP.h
5479

Remove this change

clang/include/clang/Basic/DiagnosticSemaKinds.td
10852 ↗(On Diff #423305)

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

clang/include/clang/Sema/Sema.h
10686

Comment for this new function

11141

formatting

clang/lib/AST/OpenMPClause.cpp
1614–1617

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

clang/lib/AST/StmtPrinter.cpp
658

Do not insert empty line here

659–660

formatting

663

use isa

665

Camel naming style expceted

666

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

667

Formatting

clang/lib/Parse/ParseOpenMP.cpp
2433

What is this?

2474

Restore original code here

2498–2507

Remove this extra stuff

2546

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
8900–8901

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
8900–8901

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
1614–1617

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
2433

comment removed

jdoerfert added inline comments.Jul 12 2022, 2:12 PM
clang/include/clang/Basic/DiagnosticSemaKinds.td
10852 ↗(On Diff #423305)

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

clang/lib/AST/OpenMPClause.cpp
1614–1617

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?

1679

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
677
clang/lib/Parse/ParseOpenMP.cpp
2474

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

2547

typo

2568

We don't use comments like these.

2590

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
4705

Still unrelated newlines.

7400

Code style, ArchMatch.

7449

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
4796

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
20 ↗(On Diff #442661)

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
377

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
10852 ↗(On Diff #423305)

It should be "Only one default clause is allowed.

clang/lib/AST/OpenMPClause.cpp
1679

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
7449

Ok. What do you mean by existing matching logic?

clang/lib/Sema/SemaStmt.cpp
4796

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
3144 ↗(On Diff #442661)

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

clang/lib/Sema/SemaOpenMP.cpp
7449

@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
1679

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
7449

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
1679

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

clang/lib/Parse/ParseOpenMP.cpp
2590

correcrted.

clang/lib/Sema/SemaOpenMP.cpp
7449

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
19

Remove empty comment

1619–1620

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

2454–2462

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).