Skip to content

Commit

Permalink
Enable optional OpenMPOpt (rust-lang#492)
Browse files Browse the repository at this point in the history
* Enable openmpopt

* build omp only on 13+

* Add attributor post openmpopt

* Add OpenMPOpt

Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
wsmoses and Ubuntu authored Feb 6, 2022
1 parent 925a5b4 commit 8964ab6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#if LLVM_VERSION_MAJOR >= 13
#include "llvm/Transforms/IPO/Attributor.h"
#include "llvm/Transforms/IPO/OpenMPOpt.h"
#include "llvm/Transforms/Utils/Mem2Reg.h"
#endif

#include "CApi.h"
Expand All @@ -82,7 +83,7 @@ llvm::cl::opt<bool> EnzymeAttributor("enzyme-attributor", cl::init(false),
cl::Hidden,
cl::desc("Run attributor post Enzyme"));

llvm::cl::opt<bool> EnzymeOMPOpt("enzyme-omp-opt", cl::init(true), cl::Hidden,
llvm::cl::opt<bool> EnzymeOMPOpt("enzyme-omp-opt", cl::init(false), cl::Hidden,
cl::desc("Whether to enable openmp opt"));

#if LLVM_VERSION_MAJOR >= 14
Expand Down Expand Up @@ -1751,6 +1752,11 @@ class Enzyme : public ModulePass {
#if LLVM_VERSION_MAJOR >= 13
if (Logic.PostOpt && EnzymeOMPOpt) {
OpenMPOptPass().run(M, Logic.PPC.MAM);
/// Attributor is run second time for promoted args to get attributes.
AttributorPass().run(M, Logic.PPC.MAM);
for (auto &F : M)
if (!F.empty())
PromotePass().run(F, Logic.PPC.FAM);
changed = true;
}
#endif
Expand Down Expand Up @@ -1814,9 +1820,18 @@ class Enzyme : public ModulePass {
}

#if LLVM_VERSION_MAJOR >= 13
if (Logic.PostOpt && EnzymeOMPOpt) {
OpenMPOptPass().run(M, Logic.PPC.MAM);
changed = true;
if (Logic.PostOpt) {
if (EnzymeOMPOpt) {
auto &MAM = Logic.PPC.MAM;
auto &FAM = Logic.PPC.FAM;
OpenMPOptPass().run(M, MAM);
/// Attributor is run second time for promoted args to get attributes.
AttributorPass().run(M, MAM);
for (auto &F : M)
if (!F.empty())
PromotePass().run(F, FAM);
changed = true;
}
}
#endif

Expand Down

0 comments on commit 8964ab6

Please sign in to comment.