[llvm-branch-commits] [mlir] a55a0a3 - [mlir] Remove over specified memory effects

2021-01-14 Thread Andrew Young via llvm-branch-commits

Author: Andrew Young
Date: 2021-01-14T14:49:41-08:00
New Revision: a55a0a3056b8163d9e709b534bd737730fbb5d44

URL: 
https://github.com/llvm/llvm-project/commit/a55a0a3056b8163d9e709b534bd737730fbb5d44
DIFF: 
https://github.com/llvm/llvm-project/commit/a55a0a3056b8163d9e709b534bd737730fbb5d44.diff

LOG: [mlir] Remove over specified memory effects

The standard and gpu dialect both have `alloc` operations which use the
memory effect `MemAlloc`.  In both cases, it is specified on both  the
operation itself and on the result.  This results in two memory effects
being created for these operations.  When `MemAlloc` is defined on an
operation, it represents some background effect which the compiler
cannot reason about, and  inhibits the ability of the compiler to
remove dead `std.alloc` operations.  This change removes the uneeded
`MemAlloc` effect from these operations and leaves the effect on the
result, which allows dead allocs to be erased.

There is the same problem, but to a lesser extent, with MemFree, MemRead
and MemWrite. Over-specifying these traits is not currently inhibiting
any optimization.

Differential Revision: https://reviews.llvm.org/D94662

Added: 


Modified: 
mlir/docs/Interfaces.md
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/test/Dialect/Linalg/sparse_1d.mlir
mlir/test/Dialect/Linalg/sparse_2d.mlir
mlir/test/Dialect/Linalg/sparse_3d.mlir
mlir/test/Transforms/canonicalize.mlir

Removed: 




diff  --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md
index 4fe8421295ec..7f2920bae775 100644
--- a/mlir/docs/Interfaces.md
+++ b/mlir/docs/Interfaces.md
@@ -118,7 +118,7 @@ access to derived objects by providing a virtual interface 
that must be
 implemented. As an example, many analyses and transformations want to reason
 about the side effects of an operation to improve performance and correctness.
 The side effects of an operation are generally tied to the semantics of a
-specific operation, for example an `affine.load` operation has a `write` effect
+specific operation, for example an `affine.load` operation has a `read` effect
 (as the name may suggest).
 
 These interfaces are defined by overriding the

diff  --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td 
b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index 457477f7f3c1..915347e0647e 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -806,8 +806,7 @@ def GPU_WaitOp : GPU_Op<"wait", [GPU_AsyncOpInterface]> {
 
 def GPU_AllocOp : GPU_Op<"alloc", [
 GPU_AsyncOpInterface,
-AttrSizedOperandSegments,
-MemoryEffects<[MemAlloc]>
+AttrSizedOperandSegments
   ]> {
 
   let summary = "GPU memory allocation operation.";
@@ -831,7 +830,7 @@ def GPU_AllocOp : GPU_Op<"alloc", [
 
   let arguments = (ins Variadic:$asyncDependencies,
Variadic:$dynamicSizes, 
Variadic:$symbolOperands);
-  let results = (outs Res]>:$memref,
+  let results = (outs Res:$memref,
  Optional:$asyncToken);
 
   let extraClassDeclaration = [{
@@ -844,9 +843,7 @@ def GPU_AllocOp : GPU_Op<"alloc", [
   }];
 }
 
-def GPU_DeallocOp : GPU_Op<"dealloc", [
-GPU_AsyncOpInterface, MemoryEffects<[MemFree]>
-  ]> {
+def GPU_DeallocOp : GPU_Op<"dealloc", [GPU_AsyncOpInterface]> {
 
   let summary = "GPU memory deallocation operation";
 
@@ -879,9 +876,7 @@ def GPU_DeallocOp : GPU_Op<"dealloc", [
   }];
 }
 
-def GPU_MemcpyOp : GPU_Op<"memcpy", [
-GPU_AsyncOpInterface, MemoryEffects<[MemRead, MemWrite]>
-  ]> {
+def GPU_MemcpyOp : GPU_Op<"memcpy", [GPU_AsyncOpInterface]> {
 
   let summary = "GPU memcpy operation";
 

diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td 
b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 3ae7ad54b80f..6eabe1179234 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -170,7 +170,6 @@ class AllocLikeOp traits = []> :
 Std_Op]>,
   AttrSizedOperandSegments
 ], traits)> {
 
@@ -1507,8 +1506,7 @@ def SinOp : FloatUnaryOp<"sin"> {
 // DeallocOp
 
//===--===//
 
-def DeallocOp : Std_Op<"dealloc",
-[MemoryEffects<[MemFree]>, MemRefsNormalizable]> {
+def DeallocOp : Std_Op<"dealloc", [MemRefsNormalizable]> {
   let summary = "memory deallocation operation";
   let description = [{
 The `dealloc` operation frees the region of memory referenced by a memref

diff  --git a/mlir/test/Dialect/Linalg/sparse_1d.mlir 
b/mlir/test/Dialect/Linalg/sparse_1d.mlir
index 0d471244f77a..9f7fbe471409 100644
--- a/mlir/test/Dialect/Linalg/sparse_1d.mlir
+++ b/mlir/test/Dialect/Linalg/sparse_1d.mlir
@@ -863,7 +863,6 @@ func @two_way_inv_alt(%arga: tensor<16xf32>,
 // CHECK:   %[[VAL_3:.*]] = constant 0 : index
 // CHECK:   %[[VAL_4:.*]] = c

[llvm-branch-commits] [mlir] a55a0a3 - [mlir] Remove over specified memory effects

2021-01-14 Thread Andrew Young via llvm-branch-commits

Author: Andrew Young
Date: 2021-01-14T14:49:41-08:00
New Revision: a55a0a3056b8163d9e709b534bd737730fbb5d44

URL: 
https://github.com/llvm/llvm-project/commit/a55a0a3056b8163d9e709b534bd737730fbb5d44
DIFF: 
https://github.com/llvm/llvm-project/commit/a55a0a3056b8163d9e709b534bd737730fbb5d44.diff

LOG: [mlir] Remove over specified memory effects

The standard and gpu dialect both have `alloc` operations which use the
memory effect `MemAlloc`.  In both cases, it is specified on both  the
operation itself and on the result.  This results in two memory effects
being created for these operations.  When `MemAlloc` is defined on an
operation, it represents some background effect which the compiler
cannot reason about, and  inhibits the ability of the compiler to
remove dead `std.alloc` operations.  This change removes the uneeded
`MemAlloc` effect from these operations and leaves the effect on the
result, which allows dead allocs to be erased.

There is the same problem, but to a lesser extent, with MemFree, MemRead
and MemWrite. Over-specifying these traits is not currently inhibiting
any optimization.

Differential Revision: https://reviews.llvm.org/D94662

Added: 


Modified: 
mlir/docs/Interfaces.md
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/test/Dialect/Linalg/sparse_1d.mlir
mlir/test/Dialect/Linalg/sparse_2d.mlir
mlir/test/Dialect/Linalg/sparse_3d.mlir
mlir/test/Transforms/canonicalize.mlir

Removed: 




diff  --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md
index 4fe8421295ec..7f2920bae775 100644
--- a/mlir/docs/Interfaces.md
+++ b/mlir/docs/Interfaces.md
@@ -118,7 +118,7 @@ access to derived objects by providing a virtual interface 
that must be
 implemented. As an example, many analyses and transformations want to reason
 about the side effects of an operation to improve performance and correctness.
 The side effects of an operation are generally tied to the semantics of a
-specific operation, for example an `affine.load` operation has a `write` effect
+specific operation, for example an `affine.load` operation has a `read` effect
 (as the name may suggest).
 
 These interfaces are defined by overriding the

diff  --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td 
b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index 457477f7f3c1..915347e0647e 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -806,8 +806,7 @@ def GPU_WaitOp : GPU_Op<"wait", [GPU_AsyncOpInterface]> {
 
 def GPU_AllocOp : GPU_Op<"alloc", [
 GPU_AsyncOpInterface,
-AttrSizedOperandSegments,
-MemoryEffects<[MemAlloc]>
+AttrSizedOperandSegments
   ]> {
 
   let summary = "GPU memory allocation operation.";
@@ -831,7 +830,7 @@ def GPU_AllocOp : GPU_Op<"alloc", [
 
   let arguments = (ins Variadic:$asyncDependencies,
Variadic:$dynamicSizes, 
Variadic:$symbolOperands);
-  let results = (outs Res]>:$memref,
+  let results = (outs Res:$memref,
  Optional:$asyncToken);
 
   let extraClassDeclaration = [{
@@ -844,9 +843,7 @@ def GPU_AllocOp : GPU_Op<"alloc", [
   }];
 }
 
-def GPU_DeallocOp : GPU_Op<"dealloc", [
-GPU_AsyncOpInterface, MemoryEffects<[MemFree]>
-  ]> {
+def GPU_DeallocOp : GPU_Op<"dealloc", [GPU_AsyncOpInterface]> {
 
   let summary = "GPU memory deallocation operation";
 
@@ -879,9 +876,7 @@ def GPU_DeallocOp : GPU_Op<"dealloc", [
   }];
 }
 
-def GPU_MemcpyOp : GPU_Op<"memcpy", [
-GPU_AsyncOpInterface, MemoryEffects<[MemRead, MemWrite]>
-  ]> {
+def GPU_MemcpyOp : GPU_Op<"memcpy", [GPU_AsyncOpInterface]> {
 
   let summary = "GPU memcpy operation";
 

diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td 
b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 3ae7ad54b80f..6eabe1179234 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -170,7 +170,6 @@ class AllocLikeOp traits = []> :
 Std_Op]>,
   AttrSizedOperandSegments
 ], traits)> {
 
@@ -1507,8 +1506,7 @@ def SinOp : FloatUnaryOp<"sin"> {
 // DeallocOp
 
//===--===//
 
-def DeallocOp : Std_Op<"dealloc",
-[MemoryEffects<[MemFree]>, MemRefsNormalizable]> {
+def DeallocOp : Std_Op<"dealloc", [MemRefsNormalizable]> {
   let summary = "memory deallocation operation";
   let description = [{
 The `dealloc` operation frees the region of memory referenced by a memref

diff  --git a/mlir/test/Dialect/Linalg/sparse_1d.mlir 
b/mlir/test/Dialect/Linalg/sparse_1d.mlir
index 0d471244f77a..9f7fbe471409 100644
--- a/mlir/test/Dialect/Linalg/sparse_1d.mlir
+++ b/mlir/test/Dialect/Linalg/sparse_1d.mlir
@@ -863,7 +863,6 @@ func @two_way_inv_alt(%arga: tensor<16xf32>,
 // CHECK:   %[[VAL_3:.*]] = constant 0 : index
 // CHECK:   %[[VAL_4:.*]] = c

[llvm-branch-commits] [mlir] 91f17ba - [mlir] Print the correct tool name in mlirTranslateMain

2021-01-05 Thread Andrew Young via llvm-branch-commits

Author: Andrew Young
Date: 2021-01-05T19:17:01-08:00
New Revision: 91f17ba24e86bfdd6e794e564f1e562b1d25e156

URL: 
https://github.com/llvm/llvm-project/commit/91f17ba24e86bfdd6e794e564f1e562b1d25e156
DIFF: 
https://github.com/llvm/llvm-project/commit/91f17ba24e86bfdd6e794e564f1e562b1d25e156.diff

LOG: [mlir] Print the correct tool name in mlirTranslateMain

The passed in tool name is not used, causing the wrong tool name to be 
printed by the help text.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D94120

Added: 
mlir/test/mlir-translate/commandline.mlir

Modified: 
mlir/lib/Translation/Translation.cpp

Removed: 




diff  --git a/mlir/lib/Translation/Translation.cpp 
b/mlir/lib/Translation/Translation.cpp
index 5c5ecb7e46c4..3c17ea237085 100644
--- a/mlir/lib/Translation/Translation.cpp
+++ b/mlir/lib/Translation/Translation.cpp
@@ -157,7 +157,7 @@ LogicalResult mlir::mlirTranslateMain(int argc, char **argv,
llvm::cl::Required);
   registerAsmPrinterCLOptions();
   registerMLIRContextCLOptions();
-  llvm::cl::ParseCommandLineOptions(argc, argv, "MLIR translation driver\n");
+  llvm::cl::ParseCommandLineOptions(argc, argv, toolName);
 
   std::string errorMessage;
   auto input = openInputFile(inputFilename, &errorMessage);

diff  --git a/mlir/test/mlir-translate/commandline.mlir 
b/mlir/test/mlir-translate/commandline.mlir
new file mode 100644
index ..e55e7346cf48
--- /dev/null
+++ b/mlir/test/mlir-translate/commandline.mlir
@@ -0,0 +1,2 @@
+// RUN: mlir-translate --help | FileCheck %s
+// CHECK: OVERVIEW: MLIR Translation Testing Tool
\ No newline at end of file



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits