Skip to content

Commit 5b87371

Browse files
committed
[TSAR, Tfm, Interchange] Add source-to-source transformation to interchange loops in a nest.
Merged in loop-interchange (pull request)
2 parents 3c13f47 + df1220c commit 5b87371

File tree

8 files changed

+685
-2
lines changed

8 files changed

+685
-2
lines changed

include/tsar/Analysis/Memory/DIClientServerInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ struct DIClientServerInfo {
7272
std::function<DIMemory *(DIMemory *)> getMemory = [](DIMemory *M) {
7373
return M;
7474
};
75+
std::function<DIMemory *(DIMemory *)> getClientMemory = [](DIMemory *M) {
76+
return M;
77+
};
7578

7679
/// Alias tree on server or on client or nullptr.
7780
DIAliasTree *DIAT = nullptr;

include/tsar/Support/DiagnosticKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ def error_expect_function_param : Error<"expected function parameter name">;
186186
def note_record_member_unknown: Error<"record has no member '%0'">;
187187
def note_declared_here: Note<"declared here">;
188188

189+
def warn_disable_loop_interchange: Warning<"disable loop interchange">;
190+
def note_interchange_induction_mismatch: Note<"unable to find an interchangeable loop with the '%0' induction variable">;
191+
def note_interchange_irregular_loop_nest: Note<"irregular loop structure prevents transformation (use the 'nostrict' clause to force transformation)">;
192+
def warn_interchange_not_canonical: Warning<"unable to interchange loop being not in a canonical loop form">;
193+
def warn_interchange_not_perfect: Warning<"unable to interchange not perfectly nested loop">;
194+
def warn_interchange_not_for_loop: Warning<"unable to interchange not for-loop">;
195+
def warn_interchange_dependency: Warning<"unable to interchange loop with data dependencies (use the 'nostrict' clause to force transformation)">;
196+
def warn_interchange_no_analysis: Warning<"absence of analysis results prevents loop interchange (use the 'nostrict' clause to force transformation">;
189197

190198
// Fortran-specific diagnostics.
191199
def warn_fortran_no_execution_part: Warning<"unable to locate execution-part statmenets">;

include/tsar/Support/Directives.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ def Propagate : Clause<"propagate", Transform>;
132132

133133
def Rename : Clause<"rename", Transform>;
134134

135+
def LoopInterchange : Clause<"interchange", Transform,
136+
[LParen, PPIdentifier, Comma, PPIdentifier, RParen]>;
137+
135138
def Replace : Clause<"replace", Transform,
136139
[ZeroOrOne<[LParen, Identifier, ZeroOrMore<[Comma, Identifier]>, RParen]>]>;
137140

include/tsar/Transform/Clang/Passes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,11 @@ ModulePass * createClangStructureReplacementPass();
8181
/// Initialize a pass to perform replacement of access to structure fields
8282
/// with separate variables.
8383
void initializeClangStructureReplacementPassPass(PassRegistry &Registry);
84+
85+
/// Create a pass to intergchange loops in a loop nest.
86+
FunctionPass * createClangLoopInterchange();
87+
88+
/// Initialize a pass to intergchange loops in a loop nest.
89+
void initializeClangLoopInterchangePass(PassRegistry &Registry);
8490
}
8591
#endif//TSAR_CLANG_TRANSFORM_PASSES_H

lib/Analysis/Memory/DIClientServerInfo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ DIClientServerInfo::DIClientServerInfo(llvm::Pass &P, llvm::Function &F) {
6262
auto Itr = MemoryMatcher->find<Origin>(M);
6363
return Itr != MemoryMatcher->end() ? Itr->get<Clone>() : nullptr;
6464
};
65+
getClientMemory = [MemoryMatcher](DIMemory *M) {
66+
assert(M && "Memory must not be null!");
67+
auto Itr = MemoryMatcher->find<Clone>(M);
68+
return Itr != MemoryMatcher->end() ? Itr->get<Origin>() : nullptr;
69+
};
6570
if (auto R = Socket->getAnalysis<
6671
DIEstimateMemoryPass, DIDependencyAnalysisPass>(F)) {
6772
DIAT = &R->value<DIEstimateMemoryPass *>()->getAliasTree();
@@ -131,4 +136,3 @@ DIDependenceSet *DIMemoryClientServerInfo::findFromClient(const Loop &L) const {
131136
}
132137
return nullptr;
133138
}
134-

lib/Transform/Clang/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(TRANSFORM_SOURCES Passes.cpp ExprPropagation.cpp Inline.cpp RenameLocal.cpp
22
DeadDeclsElimination.cpp Format.cpp OpenMPAutoPar.cpp
3-
SharedMemoryAutoPar.cpp DVMHSMAutoPar.cpp StructureReplacement.cpp)
3+
SharedMemoryAutoPar.cpp DVMHSMAutoPar.cpp StructureReplacement.cpp
4+
LoopInterchange.cpp)
45

56
if(MSVC_IDE)
67
file(GLOB_RECURSE TRANSFORM_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}

0 commit comments

Comments
 (0)