This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Adding flags for disabling the following optimizations: Deglobalization SPMDization State machine rewrites Folding
ClosedPublic

Authored by mcornelius on Jul 26 2021, 9:11 AM.

Details

Summary

This work provides four flags to disable four different sets of OpenMP optimizations. These flags take effect in llvm/lib/Transforms/IPO/OpenMPOpt.cpp and include the following:

  • openmp-opt-disable-deglobalization: Defaults to false, adding this flag sets the variable DisableOpenMPOptDeglobalization to true. This prevents AA registration for HeapToStack and HeapToShared.
  • openmp-opt-disable-spmdization: Defaults to false, adding this flag sets the variable DisableOpenMPOptSPMDization to true. This indicates a pessimistic fixpoint in changeToSPMDMode.
  • openmp-opt-disable-folding: Defaults to false, adding this flag sets the variable DisableOpenMPOptFolding to true. This indicates a pessimistic fixpoint in the attributor init for AAFoldRuntimeCall.
  • openmp-opt-disable-state-machine-rewrite: Defaults to false, adding this flag sets the variable DisableOpenMPOptStateMachineRewrite to true. This first prevents changes to the state machine in rewriteDeviceCodeStateMachine by returning before changes are made, and if a custom state machine is built in buildCustomStateMachine, stops by returning a pessimistic fixpoint.

Diff Detail

Event Timeline

mcornelius created this revision.Jul 26 2021, 9:11 AM
mcornelius requested review of this revision.Jul 26 2021, 9:11 AM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert added inline comments.Jul 26 2021, 9:33 AM
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
71 ↗(On Diff #361686)

I recommend to not seed AAHeapToStack / AAHeapToShared in OpenMP-Opt if the flag is set.
If you want to keep the current model use a external storage location that you can declare as extern in the other TU:

static cl::opt<unsigned, true> MaxInitializationChainLengthX(
  ┊ "attributor-max-initialization-chain-length", cl::Hidden,
  ┊ cl::desc(
  ┊ ┊ ┊ "Maximal number of chained initializations (to avoid stack overflows)"),
  ┊ cl::location(MaxInitializationChainLength), cl::init(1024));
unsigned llvm::MaxInitializationChainLength;
jhuber6 added inline comments.Jul 26 2021, 10:51 AM
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
68 ↗(On Diff #361686)

Could this be one flag if you just remove static here and declare it extern in the other file?

extern cl::opt<bool> DisableOpenMPOptDeglobalization;
71 ↗(On Diff #361686)

Might be a better option since AAHeapToStack isn't necessarily coupled to OpenMP.

Patch description missing.

jdoerfert retitled this revision from Adding flags for disabling the following optimizations: Deglobalization SPMDization State machine rewrites Folding to [OpenMP] Adding flags for disabling the following optimizations: Deglobalization SPMDization State machine rewrites Folding.Jul 26 2021, 2:10 PM

[OpenMP] Changed the disable deglobalization flag from two flags to one, and modified where this flag takes effect

(note that arc does not update review's description from locally-updated commit message)

mcornelius edited the summary of this revision. (Show Details)Jul 26 2021, 2:51 PM
mcornelius edited the summary of this revision. (Show Details)Jul 26 2021, 2:52 PM
mcornelius edited the summary of this revision. (Show Details)

Adding tests

mcornelius edited the summary of this revision. (Show Details)Jul 26 2021, 9:18 PM

Why not add the RUN lines to existing tests and then us a different check prefix, FileCheck --check-prefix=NOOPT

Fixed tests

Rebasing and fixing tests

Fixed a test

Tidying up the diff, fixing SPMDization test

jhuber6 accepted this revision.Jul 29 2021, 2:03 PM

LGTM,

I'll land it for you later.

This revision is now accepted and ready to land.Jul 29 2021, 2:03 PM
This revision was landed with ongoing or failed builds.Jul 29 2021, 4:28 PM
This revision was automatically updated to reflect the committed changes.