This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Detect SPMD compatible kernels and execute them as such
ClosedPublic

Authored by jdoerfert on May 11 2021, 10:08 PM.

Details

Summary

In the spirit of TRegions [0], this patch analyzes a kernel and tracks
if it can be executed in SPMD-mode. If so, we flip the arguments of
the __kmpc_target_init and deinit call to enable the mode.

The code analysis is done interprocedurally by extending the
AAKernelInfo abstract attribute to track SPMD compatibility as well.

[0] https://link.springer.com/chapter/10.1007/978-3-030-28596-8_11

Diff Detail

Event Timeline

jdoerfert created this revision.May 11 2021, 10:08 PM
jdoerfert requested review of this revision.May 11 2021, 10:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2021, 10:09 PM
jdoerfert retitled this revision from [OpenMP] Detect SPMD compatible kernels and execute them as such NOTE: The global "exec_mode" flag needs to be changed as well, will update this shortly. More tests needed. to [OpenMP] Detect SPMD compatible kernels and execute them as such.May 11 2021, 10:09 PM
jdoerfert edited the summary of this revision. (Show Details)
tianshilei1992 added inline comments.Jun 25 2021, 8:04 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
536–538

|| or |?

jdoerfert added inline comments.Jun 25 2021, 9:29 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
536–538

Either. I can make it ||

ormris removed a subscriber: ormris.Jun 25 2021, 1:19 PM
jdoerfert updated this revision to Diff 356099.Jul 1 2021, 10:10 PM

Rebase and cleanup. Adjust global flag as well. Add remarks, assumption support and more testing.

jdoerfert edited the summary of this revision. (Show Details)Jul 1 2021, 10:10 PM
jdoerfert updated this revision to Diff 356100.Jul 1 2021, 10:11 PM

Rename tracker

jdoerfert updated this revision to Diff 356101.Jul 1 2021, 10:17 PM

Minor updates

jdoerfert updated this revision to Diff 356569.Jul 5 2021, 3:09 PM

Minor fixes

carlo.bertolli accepted this revision.Jul 6 2021, 9:13 AM

I have very small comments. LGTM.

llvm/lib/Transforms/IPO/OpenMPOpt.cpp
2764

is it two of three underscore's? Elsewhere, it has three between OMPRTL and the fun name.

2848

If this is an optimization remark, you might want to use "noomp" or other equivalent OpenMP standard name. omp_spmd_amenable is clang only (not openmp spec's defined) and might create a compiler specific slang.

2865

It'd be nice to use something like "OMPInformationCache" to store "_exec_mode" instead of a magic string here...so if anybody changes clang, we can capture it here.

This revision is now accepted and ready to land.Jul 6 2021, 9:13 AM
This revision was landed with ongoing or failed builds.Jul 10 2021, 10:34 AM
This revision was automatically updated to reflect the committed changes.
jdoerfert marked 2 inline comments as done.
thakis added a subscriber: thakis.Jul 10 2021, 12:13 PM

One of your 12 commits broke check-clang on all the bots: https://lab.llvm.org/buildbot/#/console

Please take a look and revert if it takes a while to look.

And consider spreading out commits a bit so that if one has to be reverted, it can be a bit more precise than reverting all. Also, please watch the tree a bit after committing.