This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] 'omp distribute' directive basic support.
ClosedPublic

Authored by carlo.bertolli on Dec 1 2015, 12:16 PM.

Details

Summary

This patch includes parsing and semantic analysis for 'omp distribute' directive for OpenMP 4.5 and regression tests. All clauses present in OpenMP 4.5 for the 'omp distribute' directive are present.

Diff Detail

Repository
rL LLVM

Event Timeline

carlo.bertolli retitled this revision from to [OPENMP] 'omp distribute' directive basic support. .
carlo.bertolli updated this object.
carlo.bertolli set the repository for this revision to rL LLVM.
carlo.bertolli added subscribers: sfantao, cfe-commits.
kkwli0 added inline comments.Dec 2 2015, 5:54 AM
include/clang/AST/OpenMPClause.h
708 ↗(On Diff #41550)

Is it 'schedule'?

835 ↗(On Diff #41550)

'dist_schedule'

lib/Parse/ParseOpenMP.cpp
670

Can we merge it with the OMPC_schedule block? The code is similar.

lib/Sema/SemaOpenMP.cpp
5780

Is the IsNotNegativeIntegerValue useful in this case?

tools/libclang/CIndex.cpp
4489

"OMPDistributeDirective"

ABataev added inline comments.Dec 2 2015, 6:02 AM
include/clang/AST/OpenMPClause.h
667 ↗(On Diff #41550)

This must be in a separate patch

708–709 ↗(On Diff #41550)

I think this is wrong, this is not for dist_schedule, but for schedule clause

779 ↗(On Diff #41550)

This must be in a separate patch

include/clang/AST/RecursiveASTVisitor.h
2732–2738

separate patch

include/clang/AST/StmtOpenMP.h
2279

Distribute directive cannot have inner cancel

include/clang/Basic/OpenMPKinds.h
89–95

Separate patch

lib/AST/StmtPrinter.cpp
882

dist_schedule, not schedule

lib/Basic/OpenMPKinds.cpp
475

distribute is not a worksharing directive

lib/Parse/ParseOpenMP.cpp
162

'distribute' misses clauses, put your changes right after 'teams'

239

Restore the order of target_data and taskloop directives, put distribute right after taskloop

lib/Sema/SemaOpenMP.cpp
1530

It is not required, closely without no-closely means strictly

1989

Add rules for distribute to all other directives

2026–2027

I don't think this change is required

2062–2072

This must be handled in lines 2173-2181

tools/libclang/CIndex.cpp
4489

"OMPDistributeDirective"

carlo.bertolli marked 15 inline comments as done.

Thanks very much for your kind comments and patience at some trivial errors on my side.

This new version of the patch addresses all your concerns and it removes dist_schedule from the patch.
There is only one check in semantic analysis that was non trivial: the description of my solution is addressed in my answer to the related comment.

I will generate a new independent patch for dist_schedule, but in the meantime I look forward to your new comments.

include/clang/AST/OpenMPClause.h
667 ↗(On Diff #41550)

OK - I will create a patch dependent on this one for dist_schedule.

708 ↗(On Diff #41550)

Done

708–709 ↗(On Diff #41550)

Done

835 ↗(On Diff #41550)

Done

lib/Parse/ParseOpenMP.cpp
162

Add {clause} after distribute, but I see that distribute is already after teams in this comment. Where else should I move it?

670

Yes, I also believe that this is the right thing to do as schedule type "static" is the same for dist_schedule and schedule.

lib/Sema/SemaOpenMP.cpp
1989

Done and added rules for distribute itself when containing other directives.

2026–2027

I added this to specifically express that distribute needs to be closely nested inside teams, but then reverted to do something different. Following your next comment I made changes that made this necessary again. Please check my answer to your next comment and the associated change in the new patch.

2062–2072

Those lines (2173-2181) check that teams contains the right directives. It means that we look at the parent and we enter the if-then branch only if the parent region is a teams.
What I am trying to do here is instead check if the parent of any distribute directive is a teams region. If not, I raise an error. This is different form lines 2173-2181 because I need to prove that I am *not* in a teams region.

Anyway, I do agree with you that this should be done elsewhere. I added a new if after the lines you indicated that check the condition above. To report the correct nesting error, however, I needed the ShouldBeInTeamsRegion value above.

Please check the new version of the patch and the regression test for this.

5780

I think this is related to templates and we are not checking the value of ChunkSize until later (lines 5795-5796). I did not find a IsNotNegativeIntegerValue for the type llvm::APSInt but maybe I should look elsewhere?
I am leaving the code as is for now but please let me know how you think should be done instead.

tools/libclang/CIndex.cpp
4489

Done

4489

Done

ABataev added inline comments.Dec 4 2015, 12:26 AM
include/clang-c/Index.h
2263–2267

Update it to the latest changes

include/clang/AST/OpenMPClause.h
708–709 ↗(On Diff #41712)

Revert back these changes, this comment should not be modified

include/clang/AST/StmtOpenMP.h
2282

You forget to modify OMPLoopDirective::classof()

lib/Basic/OpenMPKinds.cpp
460

Revert these changes back

lib/Parse/ParseOpenMP.cpp
162

Remove {clause} after 'teams'

402

Revert back these changes

684

Revert back these changes

carlo.bertolli marked 7 inline comments as done.

This updated patch includes taskloop simd changes form the trunk and it addresses the second round of comments.

lib/Basic/OpenMPKinds.cpp
460

This changed due to taskloop. I have added distribute after taskloop and placed the comment in the same way as is in the current trunk for taskloop.

ABataev accepted this revision.Dec 6 2015, 9:00 PM
ABataev edited edge metadata.
This revision is now accepted and ready to land.Dec 6 2015, 9:00 PM
carlo.bertolli closed this revision.Dec 7 2015, 8:42 PM

This was committed in r255001.

Many thanks for all your help.

carlo.bertolli edited edge metadata.Dec 8 2015, 8:47 PM

Resubmitted at rev255498