This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Add AAExecutionDomainInfo interface to OpenMPOpt
ClosedPublic

Authored by jhuber6 on Apr 29 2021, 2:53 PM.

Details

Summary

Add the AAExecutionDomainInfo attributor instance to OpenMPOpt.
This will infer information relating to domain information that an
instruction might be expecting in. Right now this only includes a very
crude check for instructions that will be executed by the master thread
by comparing a thread-id function with a constant zero.

Diff Detail

Event Timeline

jhuber6 created this revision.Apr 29 2021, 2:53 PM
jhuber6 requested review of this revision.Apr 29 2021, 2:53 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript

Looks like a reasonable start, some comments:

Hook it up to the globalization to make it easier to test it. We also need negative tests and such, swapped conditions, swapped edges, ...

llvm/include/llvm/Transforms/IPO/Attributor.h
3851 ↗(On Diff #341661)

Comments are copy&paste but I don't assume we need these functions at all.
The interface we want is below/

3866 ↗(On Diff #341661)

Nit: take references

llvm/lib/Transforms/IPO/AttributorAttributes.cpp
4347 ↗(On Diff #341661)

Not needed

8150 ↗(On Diff #341661)
8177 ↗(On Diff #341661)

-Master
+MainThreadOnly or FirstThreadOnly


I don't get the TrueBB part, you don't know which successor the block you are looking at is from the code below. Make it "SuccBB" and check the condition first, then check if this is the successor under which the condition is tid == 0.


Given that we have all the openmp specific functions in here we should move this into OpenMPOpt.

8185 ↗(On Diff #341661)
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
1166

I assume this is only for testing, right?

jhuber6 updated this revision to Diff 342423.May 3 2021, 9:25 AM
jhuber6 edited the summary of this revision. (Show Details)
jhuber6 removed reviewers: uenoku, homerdin, baziotis.

Moving to OpenMPOpt.

jdoerfert added inline comments.May 3 2021, 9:43 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
2281

return how many blocks are single threaded of how many, as string: "3/7 BBs thread 0 only"

2312

You could use a set, during initialize put all blocks in the set, remove one if you cannot argue it's single threaded. you know something changed if the size at the end of update is not the size at the beginning. That should make things a lot simpler, whenever you fail to show single threaded, remove it from the set right away, no need to communicate booleans all over the place and check the set all the time to update "changed".

2333

also check if it is an equality, this would allow tid >= 0, I think.

2369

Move down to the usage, also IsSingleThreadOnly

2380–2382
2444

unreachable for all but function. See the other createForPosition

jhuber6 updated this revision to Diff 342489.May 3 2021, 11:59 AM

Making suggested changes.

jdoerfert accepted this revision.May 3 2021, 1:27 PM

LG, two minor nits.

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

Here and elsewhere, if the type is trivial, use it. 4 vs 9 chars but better readability.
E is not a good variable name for a BB.

2339–2341
This revision is now accepted and ready to land.May 3 2021, 1:27 PM
jhuber6 updated this revision to Diff 342533.May 3 2021, 1:42 PM
jhuber6 retitled this revision from [Attributor][WIP] Add AAExecutionDomainInfo interface to [Attributor] Add AAExecutionDomainInfo interface to OpenMPOpt.
jhuber6 edited the summary of this revision. (Show Details)

Fixing nits.

Hi,
The added test llvm/test/Transforms/OpenMP/single_threaded_execution.ll fails in release builds when assertions are disabled.
You probably need to add ; REQUIRES: asserts like it is done in llvm/test/CodeGen/Mips/brind-tailcall.ll.

Hi,
The added test llvm/test/Transforms/OpenMP/single_threaded_execution.ll fails in release builds when assertions are disabled.
You probably need to add ; REQUIRES: asserts like it is done in llvm/test/CodeGen/Mips/brind-tailcall.ll.

Thanks, seems like someone already fixed it in 05146fe5171076eaec3ef6a9eeeab4c8a33acf15.