void setBaseName();
ScopStmt *Statement;
+ /// @brief Flag to indicate reduction like accesses
+ ///
+ /// An access is reduction like if it is part of a load-store chain in which
+ /// both access the same memory location (use the same LLVM-IR value
+ /// as pointer reference). Furthermore, between the load and the store there
+ /// is exactly one binary operator which is known to be associative and
+ /// commutative.
+ ///
+ /// TODO:
+ ///
+ /// We can later lift the constraint that the same LLVM-IR value defines the
+ /// memory location to handle scops such as the following:
+ ///
+ /// for i
+ /// for j
+ /// sum[i+j] = sum[i] + 3;
+ ///
+ /// Here not all iterations access the same memory location, but iterations
+ /// for which j = 0 holds do. After lifing the equality check in ScopInfo,
+ /// subsequent transformations do not only need check if a statement is
+ /// reduction like, but they also need to verify that that the reduction
+ /// property is only exploited for statement instances that load from and
+ /// store to the same data location. Doing so at dependence analysis time
+ /// could allow us to handle the above example.
+ bool IsReductionLike = false;
+
const Instruction *Inst;
/// Updated access relation read from JSCOP file.
/// @brief Get the type of a memory access.
enum AccessType getType() { return Type; }
+ /// @brief Is this a reduction like access?
+ bool isReductionLike() const { return IsReductionLike; }
+
/// @brief Is this a read memory access?
bool isRead() const { return Type == MemoryAccess::READ; }
/// @brief Set the updated access relation read from JSCOP file.
void setNewAccessRelation(isl_map *newAccessRelation);
+ /// @brief Mark this a reduction like access
+ void markReductionLike() { IsReductionLike = true; }
+
/// @brief Align the parameters in the access relation to the scop context
void realignParams();
MemoryAccessVec MemAccs;
std::map<const Instruction *, MemoryAccess *> InstructionToAccess;
- /// @brief Flag to indicate reduction like statements.
- ///
- /// A statement is reduction like if it contains exactly one load and one
- /// store both accessing the same memory location (use the same LLVM-IR value
- /// as pointer reference). Furthermore, between the load and the store there
- /// is exactly one binary operator which is known to be associative and
- /// commutative.
- ///
- /// TODO:
- ///
- /// We can later lift the constraint that the same LLVM-IR value defines the
- /// memory location to handle scops such as the following:
- ///
- /// for i
- /// for j
- /// sum[i+j] = sum[i] + 3;
- ///
- /// Here not all iterations access the same memory location, but iterations
- /// for which j = 0 holds do. After lifing the equality check in ScopInfo,
- /// subsequent transformations do not only need check if a statement is
- /// reduction like, but they also need to verify that that the reduction
- /// property is only exploited for statement instances that load from and
- /// store to the same data location. Doing so at dependence analysis time
- /// could allow us to handle the above example.
- bool IsReductionLike = false;
//@}
/// The BasicBlock represented by this statement.
public:
~ScopStmt();
- /// @brief Return true iff this statement is a reduction like statement
- bool isReductionLike() const { return IsReductionLike; }
-
/// @brief Get an isl_ctx pointer.
isl_ctx *getIslCtx() const;
// Step 1)
RED = isl_union_map_empty(isl_union_map_get_space(RAW));
- for (auto *Stmt : S) {
- if (!Stmt->isReductionLike())
- continue;
- isl_set *Domain = Stmt->getDomain();
- isl_map *Identity =
- isl_map_from_domain_and_range(isl_set_copy(Domain), Domain);
- RED = isl_union_map_add_map(RED, Identity);
+ for (ScopStmt *Stmt : S) {
+ for (MemoryAccess *MA : *Stmt) {
+ if (!MA->isReductionLike())
+ continue;
+ isl_set *AccDom = isl_map_domain(MA->getAccessRelation());
+ isl_map *Identity =
+ isl_map_from_domain_and_range(isl_set_copy(AccDom), AccDom);
+ RED = isl_union_map_add_map(RED, Identity);
+ break;
+ }
}
// Step 2)
}
void MemoryAccess::print(raw_ostream &OS) const {
+ OS.indent(8) << "Reduction like: " << isReductionLike() << "\n";
switch (Type) {
case READ:
OS.indent(12) << "ReadAccess := \n";
BinOp->getOpcode() == Instruction::FMul))
return;
- // Valid reduction like statement
- IsReductionLike = true;
+ // Valid reduction like access
+ MemAccs[0]->markReductionLike();
+ MemAccs[1]->markReductionLike();
}
std::string ScopStmt::getDomainStr() const { return stringFromIslObj(Domain); }
void ScopStmt::print(raw_ostream &OS) const {
OS << "\t" << getBaseName() << "\n";
- OS.indent(8) << "Reduction like: " << isReductionLike() << "\n";
-
OS.indent(12) << "Domain :=\n";
if (Domain) {