[llvm-commits] [polly] r152238 - in /polly/trunk: include/polly/Dependences.h lib/Analysis/Dependences.cpp
Tobias Grosser
grosser at fim.uni-passau.de
Wed Mar 7 09:42:50 PST 2012
Author: grosser
Date: Wed Mar 7 11:42:49 2012
New Revision: 152238
URL: http://llvm.org/viewvc/llvm-project?rev=152238&view=rev
Log:
Dependences: Simplify isParallelDimension
Modified:
polly/trunk/include/polly/Dependences.h
polly/trunk/lib/Analysis/Dependences.cpp
Modified: polly/trunk/include/polly/Dependences.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Dependences.h?rev=152238&r1=152237&r2=152238&view=diff
==============================================================================
--- polly/trunk/include/polly/Dependences.h (original)
+++ polly/trunk/include/polly/Dependences.h Wed Mar 7 11:42:49 2012
@@ -26,6 +26,7 @@
#include "polly/ScopPass.h"
#include <map>
+#include "isl/ctx.h"
struct isl_union_map;
struct isl_union_set;
@@ -80,7 +81,8 @@
///
/// @return bool Returns true, if executing parallelDimension in parallel is
/// valid for the scattering domain subset given.
- bool isParallelDimension(isl_set *LoopDomain, unsigned ParallelDimension);
+ bool isParallelDimension(__isl_take isl_set *LoopDomain,
+ unsigned ParallelDimension);
/// @brief Check if a loop is parallel
///
Modified: polly/trunk/lib/Analysis/Dependences.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=152238&r1=152237&r2=152238&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/Dependences.cpp (original)
+++ polly/trunk/lib/Analysis/Dependences.cpp Wed Mar 7 11:42:49 2012
@@ -172,106 +172,63 @@
return schedule;
}
-bool Dependences::isParallelDimension(isl_set *loopDomain,
- unsigned parallelDimension) {
+bool Dependences::isParallelDimension(__isl_take isl_set *Domain,
+ unsigned ParallelDim) {
+ isl_union_map *Schedule, *Deps;
+ isl_union_set *ScheduleSubset;
Scop *S = &getCurScop();
- isl_union_map *schedule = getCombinedScheduleForSpace(S, parallelDimension);
- // Calculate distance vector.
- isl_union_set *scheduleSubset;
- isl_union_map *scheduleDeps, *restrictedDeps;
- isl_union_map *scheduleDeps_war, *restrictedDeps_war;
- isl_union_map *scheduleDeps_waw, *restrictedDeps_waw;
-
- scheduleSubset = isl_union_set_from_set(isl_set_copy(loopDomain));
-
- scheduleDeps = isl_union_map_apply_range(isl_union_map_copy(RAW),
- isl_union_map_copy(schedule));
- scheduleDeps = isl_union_map_apply_domain(scheduleDeps,
- isl_union_map_copy(schedule));
-
- scheduleDeps_war = isl_union_map_apply_range(isl_union_map_copy(WAR),
- isl_union_map_copy(schedule));
- scheduleDeps_war = isl_union_map_apply_domain(scheduleDeps_war,
- isl_union_map_copy(schedule));
-
- scheduleDeps_waw = isl_union_map_apply_range(isl_union_map_copy(WAW),
- isl_union_map_copy(schedule));
- scheduleDeps_waw = isl_union_map_apply_domain(scheduleDeps_waw, schedule);
+ Schedule = getCombinedScheduleForSpace(S, ParallelDim);
+ Deps = getDependences(TYPE_ALL);
+
+ ScheduleSubset = isl_union_set_from_set(Domain);
+ Deps = isl_union_map_apply_range(Deps, isl_union_map_copy(Schedule));
+ Deps = isl_union_map_apply_domain(Deps, Schedule);
// Dependences need to originate and to terminate in the scheduling space
// enumerated by this loop.
- restrictedDeps = isl_union_map_intersect_domain(scheduleDeps,
- isl_union_set_copy(scheduleSubset));
- restrictedDeps = isl_union_map_intersect_range(restrictedDeps,
- isl_union_set_copy(scheduleSubset));
-
- isl_union_set *distance = isl_union_map_deltas(restrictedDeps);
-
- restrictedDeps_war = isl_union_map_intersect_domain(scheduleDeps_war,
- isl_union_set_copy(scheduleSubset));
- restrictedDeps_war = isl_union_map_intersect_range(restrictedDeps_war,
- isl_union_set_copy(scheduleSubset));
+ Deps = isl_union_map_intersect_domain(Deps,
+ isl_union_set_copy(ScheduleSubset));
+ Deps = isl_union_map_intersect_range(Deps, ScheduleSubset);
- isl_union_set *distance_war = isl_union_map_deltas(restrictedDeps_war);
+ isl_union_set *Distance = isl_union_map_deltas(Deps);
- restrictedDeps_waw = isl_union_map_intersect_domain(scheduleDeps_waw,
- isl_union_set_copy(scheduleSubset));
- restrictedDeps_waw = isl_union_map_intersect_range(restrictedDeps_waw,
- scheduleSubset);
-
- isl_union_set *distance_waw = isl_union_map_deltas(restrictedDeps_waw);
-
- isl_space *Space = isl_space_set_alloc(S->getIslCtx(), 0, parallelDimension);
+ isl_space *Space = isl_space_set_alloc(S->getIslCtx(), 0, ParallelDim);
// [0, 0, 0, 0] - All zero
- isl_set *allZero = isl_set_universe(isl_space_copy(Space));
- unsigned dimensions = isl_space_dim(Space, isl_dim_set);
+ isl_set *AllZero = isl_set_universe(isl_space_copy(Space));
+ unsigned Dimensions = isl_space_dim(Space, isl_dim_set);
- for (unsigned i = 0; i < dimensions; i++)
- allZero = isl_set_fix_si(allZero, isl_dim_set, i, 0);
+ for (unsigned i = 0; i < Dimensions; i++)
+ AllZero = isl_set_fix_si(AllZero, isl_dim_set, i, 0);
- allZero = isl_set_align_params(allZero, S->getParamSpace());
+ AllZero = isl_set_align_params(AllZero, S->getParamSpace());
// All zero, last unknown.
// [0, 0, 0, ?]
- isl_set *lastUnknown = isl_set_universe(isl_space_copy(Space));
+ isl_set *LastUnknown = isl_set_universe(Space);
- for (unsigned i = 0; i < dimensions - 1; i++)
- lastUnknown = isl_set_fix_si(lastUnknown, isl_dim_set, i, 0);
+ for (unsigned i = 0; i < Dimensions - 1; i++)
+ LastUnknown = isl_set_fix_si(LastUnknown, isl_dim_set, i, 0);
- lastUnknown = isl_set_align_params(lastUnknown, S->getParamSpace());
+ LastUnknown = isl_set_align_params(LastUnknown, S->getParamSpace());
// Valid distance vectors
- isl_set *validDistances = isl_set_subtract(lastUnknown, allZero);
- validDistances = isl_set_complement(validDistances);
- isl_union_set *validDistancesUS = isl_union_set_from_set(validDistances);
-
- isl_union_set *nonValid = isl_union_set_subtract(distance,
- isl_union_set_copy(validDistancesUS));
-
- isl_union_set *nonValid_war = isl_union_set_subtract(distance_war,
- isl_union_set_copy(validDistancesUS));
-
- isl_union_set *nonValid_waw = isl_union_set_subtract(distance_waw,
- validDistancesUS);
- bool is_parallel = isl_union_set_is_empty(nonValid)
- && isl_union_set_is_empty(nonValid_war)
- && isl_union_set_is_empty(nonValid_waw);
-
- isl_space_free(Space);
- isl_union_set_free(nonValid);
- isl_union_set_free(nonValid_war);
- isl_union_set_free(nonValid_waw);
-
- return is_parallel;
+ isl_set *ValidDistances = isl_set_subtract(LastUnknown, AllZero);
+ ValidDistances = isl_set_complement(ValidDistances);
+ isl_union_set *ValidDistancesUS = isl_union_set_from_set(ValidDistances);
+ isl_union_set *Invalid = isl_union_set_subtract(Distance, ValidDistancesUS);
+
+ bool IsParallel = isl_union_set_is_empty(Invalid);
+ isl_union_set_free(Inalid);
+ return IsParallel;
}
bool Dependences::isParallelFor(const clast_for *f) {
- isl_set *loopDomain = isl_set_from_cloog_domain(f->domain);
- assert(loopDomain && "Cannot access domain of loop");
+ isl_set *Domain = isl_set_from_cloog_domain(f->domain);
+ assert(Domain && "Cannot access domain of loop");
- return isParallelDimension(loopDomain, isl_set_n_dim(loopDomain));
+ return isParallelDimension(isl_set_copy(Domain), isl_set_n_dim(Domain));
}
void Dependences::printScop(raw_ostream &OS) const {
More information about the llvm-commits
mailing list