[PATCH] D98765: [Polly] Refabricating isReductionParallel() and getMinimalDependenceDistance() from Integer Set Libarary(ISL) to take the C++ wrapper

Prateek Pardeshi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 02:12:03 PDT 2021


prateekpardeshi created this revision.
prateekpardeshi added a reviewer: Meinersbur.
prateekpardeshi added a project: Polly.
Herald added a reviewer: bollu.
prateekpardeshi requested review of this revision.
Herald added a project: LLVM.

Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:

- Refabricating `isReductionParallel()` and `getMinimalDependenceDistance()` to take C++ bindings instead of reference-counting in C isl lib.
- Addition of manage_copy() to be used as reference for C objects instead of `isReductionParallel()` and `getMinimalDependenceDistance()`

Tests:

- `ninja opt`: Passed ✔️
- `ninja check-polly-tests` : Passed ✔️
- `ninja polly-update-format`: Passed ✔️


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98765

Files:
  polly/include/polly/CodeGen/IslAst.h
  polly/lib/CodeGen/IslAst.cpp
  polly/lib/CodeGen/IslNodeBuilder.cpp


Index: polly/lib/CodeGen/IslNodeBuilder.cpp
===================================================================
--- polly/lib/CodeGen/IslNodeBuilder.cpp
+++ polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -778,7 +778,7 @@
   bool Vector = PollyVectorizerChoice == VECTORIZER_POLLY;
 
   if (Vector && IslAstInfo::isInnermostParallel(isl::manage_copy(For)) &&
-      !IslAstInfo::isReductionParallel(For)) {
+      !IslAstInfo::isReductionParallel(isl::manage_copy(For))) {
     int VectorWidth = getNumberOfIterations(isl::manage_copy(For));
     if (1 < VectorWidth && VectorWidth <= 16 && !hasPartialAccesses(For)) {
       createForVector(For, VectorWidth);
@@ -790,8 +790,8 @@
     createForParallel(For);
     return;
   }
-  bool Parallel =
-      (IslAstInfo::isParallel(For) && !IslAstInfo::isReductionParallel(For));
+  bool Parallel = (IslAstInfo::isParallel(For) &&
+                   !IslAstInfo::isReductionParallel(isl::manage_copy(For)));
   createForSequential(isl::manage(For), Parallel);
 }
 
Index: polly/lib/CodeGen/IslAst.cpp
===================================================================
--- polly/lib/CodeGen/IslAst.cpp
+++ polly/lib/CodeGen/IslAst.cpp
@@ -171,7 +171,8 @@
 static isl_printer *cbPrintFor(__isl_take isl_printer *Printer,
                                __isl_take isl_ast_print_options *Options,
                                __isl_keep isl_ast_node *Node, void *) {
-  isl_pw_aff *DD = IslAstInfo::getMinimalDependenceDistance(Node);
+  isl_pw_aff *DD =
+      IslAstInfo::getMinimalDependenceDistance(isl::manage_copy(Node));
   const std::string BrokenReductionsStr = getBrokenReductionsStr(Node);
   const std::string KnownParallelStr = "#pragma known-parallel";
   const std::string DepDisPragmaStr = "#pragma minimal dependence distance: ";
@@ -478,7 +479,7 @@
             NumInnermostParallel++;
           if (IslAstInfo::isOutermostParallel(isl::manage_copy(Node)))
             NumOutermostParallel++;
-          if (IslAstInfo::isReductionParallel(Node))
+          if (IslAstInfo::isReductionParallel(isl::manage_copy(Node)))
             NumReductionParallel++;
           if (IslAstInfo::isExecutedInParallel(Node))
             NumExecutedInParallel++;
@@ -608,8 +609,8 @@
   return Payload && Payload->IsOutermostParallel;
 }
 
-bool IslAstInfo::isReductionParallel(__isl_keep isl_ast_node *Node) {
-  IslAstUserPayload *Payload = getNodePayload(isl::manage_copy(Node));
+bool IslAstInfo::isReductionParallel(const isl::ast_node &Node) {
+  IslAstUserPayload *Payload = getNodePayload(Node);
   return Payload && Payload->IsReductionParallel;
 }
 
@@ -630,7 +631,7 @@
     return false;
 
   return isOutermostParallel(isl::manage_copy(Node)) &&
-         !isReductionParallel(Node);
+         !isReductionParallel(isl::manage_copy(Node));
 }
 
 __isl_give isl_union_map *
@@ -640,8 +641,8 @@
 }
 
 __isl_give isl_pw_aff *
-IslAstInfo::getMinimalDependenceDistance(__isl_keep isl_ast_node *Node) {
-  IslAstUserPayload *Payload = getNodePayload(isl::manage_copy(Node));
+IslAstInfo::getMinimalDependenceDistance(const isl::ast_node &Node) {
+  IslAstUserPayload *Payload = getNodePayload(Node);
   return Payload ? Payload->MinimalDependenceDistance.copy() : nullptr;
 }
 
Index: polly/include/polly/CodeGen/IslAst.h
===================================================================
--- polly/include/polly/CodeGen/IslAst.h
+++ polly/include/polly/CodeGen/IslAst.h
@@ -151,7 +151,7 @@
   static bool isInnermostParallel(const isl::ast_node &Node);
 
   /// Is this loop a reduction parallel loop?
-  static bool isReductionParallel(__isl_keep isl_ast_node *Node);
+  static bool isReductionParallel(const isl::ast_node &Node);
 
   /// Will the loop be run as thread parallel?
   static bool isExecutedInParallel(__isl_keep isl_ast_node *Node);
@@ -161,7 +161,7 @@
 
   /// Get minimal dependence distance or nullptr if not available.
   static __isl_give isl_pw_aff *
-  getMinimalDependenceDistance(__isl_keep isl_ast_node *Node);
+  getMinimalDependenceDistance(const isl::ast_node &Node);
 
   /// Get the nodes broken reductions or a nullptr if not available.
   static MemoryAccessSet *getBrokenReductions(__isl_keep isl_ast_node *Node);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98765.331185.patch
Type: text/x-patch
Size: 4203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210317/167bf9cd/attachment.bin>


More information about the llvm-commits mailing list