Skip to content

Commit 8964ab6

Browse files
wsmosesUbuntu
and
Ubuntu
authored
Enable optional OpenMPOpt (rust-lang#492)
* Enable openmpopt * build omp only on 13+ * Add attributor post openmpopt * Add OpenMPOpt Co-authored-by: Ubuntu <ubuntu@ip-172-31-66-106.ec2.internal>
1 parent 925a5b4 commit 8964ab6

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

enzyme/Enzyme/Enzyme.cpp

+19-4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#if LLVM_VERSION_MAJOR >= 13
6666
#include "llvm/Transforms/IPO/Attributor.h"
6767
#include "llvm/Transforms/IPO/OpenMPOpt.h"
68+
#include "llvm/Transforms/Utils/Mem2Reg.h"
6869
#endif
6970

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

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

8889
#if LLVM_VERSION_MAJOR >= 14
@@ -1751,6 +1752,11 @@ class Enzyme : public ModulePass {
17511752
#if LLVM_VERSION_MAJOR >= 13
17521753
if (Logic.PostOpt && EnzymeOMPOpt) {
17531754
OpenMPOptPass().run(M, Logic.PPC.MAM);
1755+
/// Attributor is run second time for promoted args to get attributes.
1756+
AttributorPass().run(M, Logic.PPC.MAM);
1757+
for (auto &F : M)
1758+
if (!F.empty())
1759+
PromotePass().run(F, Logic.PPC.FAM);
17541760
changed = true;
17551761
}
17561762
#endif
@@ -1814,9 +1820,18 @@ class Enzyme : public ModulePass {
18141820
}
18151821

18161822
#if LLVM_VERSION_MAJOR >= 13
1817-
if (Logic.PostOpt && EnzymeOMPOpt) {
1818-
OpenMPOptPass().run(M, Logic.PPC.MAM);
1819-
changed = true;
1823+
if (Logic.PostOpt) {
1824+
if (EnzymeOMPOpt) {
1825+
auto &MAM = Logic.PPC.MAM;
1826+
auto &FAM = Logic.PPC.FAM;
1827+
OpenMPOptPass().run(M, MAM);
1828+
/// Attributor is run second time for promoted args to get attributes.
1829+
AttributorPass().run(M, MAM);
1830+
for (auto &F : M)
1831+
if (!F.empty())
1832+
PromotePass().run(F, FAM);
1833+
changed = true;
1834+
}
18201835
}
18211836
#endif
18221837

0 commit comments

Comments
 (0)