This is an archive of the discontinued LLVM Phabricator instance.

[AbstractAttributor] Fold __kmpc_parallel_level if possible
ClosedPublic

Authored by tianshilei1992 on Jul 16 2021, 7:46 AM.

Details

Summary

Similar to D105787, this patch tries to fold __kmpc_parallel_level if possible.
Note that __kmpc_parallel_level doesn't take activeness into consideration,
based on current deviceRTLs, its return value can be such as 0, 1, 2, instead
of 0, 129, 130, etc. that also indicate activeness.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Jul 16 2021, 7:46 AM
tianshilei1992 requested review of this revision.Jul 16 2021, 7:46 AM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
tianshilei1992 added inline comments.Jul 16 2021, 7:47 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
444–446

These changes are covered by D106149, which will not be part of this patch eventually.

add missing feature and a trivial test case

tianshilei1992 edited the summary of this revision. (Show Details)Jul 20 2021, 2:20 PM
tianshilei1992 added inline comments.Jul 20 2021, 2:21 PM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
3296

The logic seems problematic here. Need to revise later.

llvm/test/Transforms/OpenMP/parallel_level_fold.ll
1

The enhancement of the test case is still WIP.

add assertion

add noinline to the microtrask function to avoid us accidentally doing the wrong thing. I'll put a patch up that removes those noinline in the module pass.

more conservative

tianshilei1992 retitled this revision from [WIP][AbstractAttributor] Fold __kmpc_parallel_level if possible to [AbstractAttributor] Fold __kmpc_parallel_level if possible.Jul 21 2021, 4:31 PM
jdoerfert added inline comments.Jul 21 2021, 11:30 PM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
3314
3659
3678
tianshilei1992 added inline comments.Jul 22 2021, 8:41 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
3314

Seems unnecessary because this variable is only written in the function call but I can do it.

tianshilei1992 marked 3 inline comments as done.

rebase and fixed comments

jdoerfert accepted this revision.Jul 22 2021, 9:30 AM

LG, some minor comments below.

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

mark __kmpc_parallel_51 as noinline to make this sound.

3671
3671–3672
This revision is now accepted and ready to land.Jul 22 2021, 9:30 AM
tianshilei1992 marked 3 inline comments as done.

fix comments

Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 10:08 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
3671

I changed this a little bit. If CallerKernelInfoAA.ParallelLevels is empty, we can only tell we currently cannot fold it, but it doesn't mean it cannot be folded in the future. If the size is more than 1, yeah, definitely it is pessimistic.

jdoerfert added inline comments.Jul 22 2021, 11:35 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
3675

not nullptr but it shuld continue to be none

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

Aha, I recall it. Yeah, will do it.

rebase and fix comments

tianshilei1992 marked an inline comment as done.Jul 22 2021, 11:37 AM

add __attribute__((noinline)) to __kmpc_parallel_level

jhuber6 added inline comments.Jul 23 2021, 1:11 PM
openmp/libomptarget/deviceRTLs/interface.h
444 ↗(On Diff #361315)

Isn't there a NOINLINE definition in target_impl.h?

tianshilei1992 marked an inline comment as done.

rebase

rebase and update

This revision was landed with ongoing or failed builds.Jul 26 2021, 7:46 PM
This revision was automatically updated to reflect the committed changes.